Skip to content

Commit 7e1e38b

Browse files
authored
Full review (#8) (#9)
* Initial commit for WasmScore" * add github actions to compile and test x64 benchmarks (#1) * Add github actions to compile and test x64 benchmarks * Refactor driver to match refactored sightglass * Continue refactor and cleanup. Better use of df * Prints out efficiency and wasm scores * Remove unneeded comments * Add printing of results to a file and the screen * Improve quiet printing * Add simdscore placeholder and validate runall * Update tag for docker images * Update workflow to include running of all available benchmarks * Update wasmtime commit * Add code of conduct Code of conduct is a copy from wasmtime repo. * Add contributor documentation * Add license agreement * Update security policy * Add dependabot support for pip * Update simplify config.inc * Use a local benchmarks directory instead of the Sightglass version * Fix for failures caused by missing results directory on some runs * Remove unnecessary installs in Dockerfile * Separate security section to it's own file * Update printed comments * Update container entry point and build message * Update README and add example screenshots in asset folder
1 parent 851ba65 commit 7e1e38b

8 files changed

Lines changed: 69 additions & 72 deletions

File tree

CONTRIBUTING.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,3 @@ For more information about contributing to this project you can consult the
1010
[Code of Conduct]: CODE_OF_CONDUCT.md
1111
[Organizational Code of Conduct]: ORG_CODE_OF_CONDUCT.md
1212
[online documentation]: https://bytecodealliance.github.io/wasmtime/contributing.html
13-
14-
# Security
15-
16-
If you think you have found a security issue in WasmScore, please file a github issue with details, reproducible steps, and a clearly defined impact.
17-
Once an issue is reported, we will assess, respond, and priortize a solution. In the case that WasmScore has planned updates at a regular time candence, the fix of a security vulnerability may warrant an intermediate release of WasmScore depending on the severity of the vulnerability.

Dockerfile

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,6 @@ RUN python3 -m pip install termgraph \
5151
&& python3 -m pip install termcolor \
5252
&& python3 -m pip install pyyaml
5353

54-
# Install docker
55-
RUN apt-get update && apt-get -y install ca-certificates curl gnupg lsb-release
56-
RUN curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
57-
RUN echo \
58-
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
59-
$(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
60-
RUN apt-get update && apt-get -y install docker-ce docker-ce-cli containerd.io
61-
6254
# Install sightglass
6355
WORKDIR /
6456
RUN git clone --recurse-submodules ${SIGHTGLASS_REPO} sightglass
@@ -92,3 +84,7 @@ ADD benchmarks /sightglass/benchmarks
9284
WORKDIR /
9385
COPY wasmscore.py /sightglass/wasmscore.py
9486
COPY wasmscore.sh /
87+
88+
# Set default entry and command
89+
ENTRYPOINT ["/bin/bash", "/wasmscore.sh"]
90+
CMD ["-t", "wasmscore"]

README.md

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,38 @@
11
# WasmScore
22

3-
This benchmark is designed to provide a simple, convenient and portable view of the performance of WebAssembly outside the browser on the underlying platform it is run on. It uses a containerized suite of real codes and micros leveraged directly from [Sightglass](https://github.com/bytecodealliance/sightglass) to benchmark the platform and provide a “WasmScore” that is based on a formula that aggregates execution time. In addition, the driver for the benchmark serves as an easy-to-use tool for executing any user determined assortment of Sightglass benchmarks supported by the driver.
4-
5-
One of the most important and challenging aspect of benchmarking is deciding how to interpret the results; should you consider the results to be good or bad? To decide, you really need context on what it is you are trying to achieve, and this often starts with a baseline used to serve as a point of comparison. That baseline could be the execution of that same original source but before some transformation was applied when lowered to WebAssembly, or that baseline could be a modified configuration of the runtime that executes the WebAssembly. In the case of WasmScore, a novel aspect is that for every Wasm real code and micro that is run, WasmScore also executes the native versions of those code compiled from the same high-level source used to generate the Wasm. In this way WasmScore provides a comparison point for the Wasm performance which will ideally be the theoretical upper for the performance of WebAssembly. This feature allows a user to quickly gauge the performance impact of using Wasm instead of using a native compile of the same code when run on that particular platform. It allows developers to see opportunity to improve compilers, or to improve Wasm runtimes, or improve the Wasm spec, or to suggest other solutions (such as Wasi) to address gaps.
6-
7-
Another important feature of WasmScore is simplicity and convenience. Specifically, the user is not expected to have to build the benchmark where they might have to deal with installing or updating dependencies. The user is also not expected contend interpreting the need for turning on or off a myriad of flags and features; to get a platforms WasmScore the user simply runs wasmscore.sh inside the container. Still, while it is meant for the user to simply pull a containerized image and then run the benchmark on the desired platform without worrying, WasmScore can of course be built and then run either within or outside (TODO) the containerized environment. In either case is intended for the compile of all codes to properly utilizes underlying hardware features. To that end, the ideal use case and indeed the target use case for WasmScore is for a quick, simple and consistent cross platform view of Wasm performance. The benchmark especially wants to target usecases and applications that are emerging for Wasm in standalone client and cloud environments. WasmScore is intended to be run on X86-64 and AArch64 Linux platforms.
8-
3+
## Intro
4+
WasmScore aims to provide a view of WebAssembly performance when executed outside the browser. It uses a containerized suite of benchmarks (both user facing codes and purpose built benchmarks) and leverages [Sightglass](https://github.com/bytecodealliance/sightglass) to benchmark the underline platform. A score based on a formula that aggregates execution time of the suites that make up the "wasmscore" test is provided. In addition to scoring wasm performance, the benchmark is also a tool capable of executing any assortment of other tests, suites, or benchmarks supported by the driver. This WasmScore is work in development.
5+
6+
## Description
7+
One of the most important and challenging aspect of benchmarking is deciding how to interpret the results; should you consider the results to be good or bad? To decide, you really need context on what it is you are trying to achieve, and this often starts with a baseline used to serve as a point of comparison. For example, that baseline could be the execution of that same original source but before some transformation was applied when lowered to WebAssembly, or that baseline could be a modified configuration of the runtime that executes the WebAssembly. In the case of WasmScore, for every Wasm real code and micro that is run, WasmScore also executes the native code compile from the same high-level source used to generate the Wasm to serve as a baseline. In this way WasmScore provides a comparison point for the Wasm performance which will ideally be the theoretical upper for the performance of WebAssembly. This allows a user to quickly gauge the performance impact of using Wasm instead of using a native compile of the same code when run on that particular platform. It allows developers to see opportunity to improve compilers, or to improve Wasm runtimes, or improve the Wasm spec, or to suggest other solutions (such as Wasi) to address gaps.
8+
9+
## Benchmarks
10+
Typically a benchmark reports either the amount of work done over a constant amount of time or it reports the time taken to do a constant amount of work. The benchmarks here all do the later. The initial commit of the benchmarks avaialble have been pulled Sightglass however the benchmarks used with WasmScore come from the local directory here and have no dependency on the benchmarks stored there. However, how the benchmarks here are built and run directly dependent on changes to the external Sightglass repo.
11+
12+
Also, benchmarks are often categorized based on their origin. Two such buckets of benchmarks are (1) codes written with the intent of being user facing (library paths, application use cases) and (2) codes written specifically to benchmark some important/common code construct or platform feature. WasmScore will not necessarily favor either of these benchmarking buckets as both are valuable for the evaluation of standalone Wasm performance depending on what you want to know. The extent that it does will depending on the test run, where currently there is only the primary "wasmscore" test though a simdscore test is in the plans.
13+
14+
## Goals
15+
A standalone benchmark that is:
16+
- Convenient to build and run with easy to interpret results
17+
- Is portable and enables cross-platform comparisons
18+
- Provides a breadth of coverage for current standalone binaries
19+
- Is convenient to analyze
20+
21+
## WasmScore Suites
22+
Any number of test can be created but WasmScore is the initial and default test. It includes a mix of relevant in use codes and targeted benchmarks Wasm performance outside the browser that is broken down into categories:
23+
- App: [‘Meshoptimizer’]
24+
- Core: [‘Ackermann', ‘Ctype', ‘Fibonacci’]
25+
- Crypto: [‘Base64', ‘Ed25519', ‘Seqhash']
26+
- AI: (Coming)
27+
- Regex: (Coming)
28+
29+
## Plan
30+
Next steps include:
31+
- Improving stability and user experience
32+
- Adding benchmarks to the AI, Regex, and APP suites
33+
- Adding more benchmarks
34+
- Complete the SIMD test
35+
- Publish a list of planned milestone
936

1037
## Usage
1138

@@ -15,17 +42,17 @@ Download and run the latest prebuilt benchmark image:
1542

1643
**X86-64:**
1744
```
18-
docker pull ghcr.io/jlb6740/wasmscore/wasmscore_x86_64:latest
45+
docker pull ghcr.io/bytecodealliance/wasm-score/wasmscore_x86_64_linux:latest
1946
```
2047
```
21-
docker run -it ghcr.io/jlb6740/wasmscore/wasmscore_x86_64:latest /bin/bash /wasmscore.sh
48+
docker run -it ghcr.io/bytecodealliance/wasm-score/wasmscore_x86_64_linux:latest
2249
```
2350
**AArch64:**
2451
```
25-
docker pull ghcr.io/jlb6740/wasmscore/wasmscore_aarch64:latest
52+
docker pull ghcr.io/bytecodealliance/wasm-score/wasmscore_aarch64_linux:latest
2653
```
2754
```
28-
docker run -it ghcr.io/jlb6740/wasmscore/wasmscore_aarch64:latest /bin/bash /wasmscore.sh
55+
docker run -it ghcr.io/bytecodealliance/wasm-score/wasmscore_aarch64_linux:latest
2956
```
3057

3158
### Build and Run Yourself
@@ -36,29 +63,10 @@ To build:
3663
```
3764
To run from this local build:
3865
```
39-
docker run -ti wasmscore /bin/bash wasmscore.sh --help
66+
docker run -ti wasmscore <--help>
4067
```
4168

4269
To build containerless:
4370
> Not yet supported
4471
45-
### Other Useful Commands
46-
47-
For a detached setup that allows for copying files to the image or entering the container (being mindful of the container name), use the following commands:
48-
```
49-
docker run -ti -d wasmscore /bin/bash
50-
```
51-
```
52-
wasmscore_container_id=$(docker ps | grep -m 1 wasmscore | awk '{ print $1 }')
53-
```
54-
```
55-
docker cp <file> ${wasmscore_container_id}:
56-
```
57-
or
58-
```
59-
docker exec -ti ${wasmscore_container_id} /bin/bash
60-
```
61-
## Example Screenshots
62-
63-
6472

SECURITY.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
If you think you have found a security issue in WasmScore, please file a github issue with details, reproducible steps, and a clearly defined impact.
2+
Once an issue is reported, we will assess, respond, and priortize a solution. In the case that WasmScore has planned updates at a regular time candence, the fix of a security vulnerability may warrant an intermediate release of WasmScore depending on the severity of the vulnerability.

build.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,19 @@ docker tag ${IMAGE_NAME} ${IMAGE_NAME}_${ARCH}_${KERNEL}:latest
1212
docker tag ${IMAGE_NAME} ${IMAGE_NAME}_${ARCH}_${KERNEL}:${IMAGE_VER}
1313

1414
echo ""
15-
echo "To run from this local build use command:"
16-
echo "> docker run -ti ${IMAGE_NAME} /bin/bash wasmscore.sh --help"
15+
echo "The entry point is a wrapper to the python script 'wasmscore.py'"
16+
echo "To run from this local build use command (for a list of more options use --help):"
17+
echo "> docker run -ti ${IMAGE_NAME} <options>"
1718
echo ""
1819
echo "To stop and rm all ${IMAGE_NAME} containers:"
1920
echo "> docker rm \$(docker stop \$(docker ps -a -q --filter ancestor=${IMAGE_NAME}:latest --format="{{.ID}}"))"
2021
echo ""
2122
echo "For a detached setup that allows for copying files to the image or"
2223
echo "entering the container, use the following commands:"
23-
echo "> docker run -ti -d ${IMAGE_NAME} /bin/bash"
24+
echo "> docker run --entrypoint=/bin/bash -ti -d ${IMAGE_NAME}"
2425
echo "> wasmscore_container_id=\$(docker ps | grep -m 1 ${IMAGE_NAME} | awk '{ print \$1 }')"
26+
echo ""
2527
echo "> docker cp <file> \${wasmscore_container_id}:"
2628
echo "or"
27-
echo "> docker exec -ti \${wasmscore_container_id} /bin/bash"
29+
echo "> docker exec -ti \${wasmscore_container_id}" /bin/bash
2830
echo ""
98.3 KB
Loading
274 KB
Loading

wasmscore.py

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
import os
55
import sys
6-
import datetime
76
from datetime import datetime
87
import argparse
98
import subprocess
@@ -24,9 +23,6 @@
2423
available suites: See list
2524
available tests: WasmScore (default), SimdScore
2625
27-
28-
29-
example usage: ./wasmscore.sh -b shootout -r wasmtime_app
3026
"""
3127
),
3228
)
@@ -67,7 +63,6 @@
6763
)
6864

6965
parser.add_argument(
70-
"-l",
7166
"--list",
7267
action="store_true",
7368
help="List all available suites and individual benchmarks to run",
@@ -367,8 +362,25 @@ def run_benchmarks(benchmark, run_native=False):
367362
logging.info("Running benchmark ...")
368363
logging.info("Run native ... %s", run_native)
369364

370-
native_df = None
365+
results_dir = f"{SG_BENCHMARKS_BASE}/results/"
366+
367+
create_results_path_cmd_string = f"mkdir -p {results_dir}"
368+
try:
369+
logging.info(
370+
"Trying mkdir for results_path ... %s", create_results_path_cmd_string
371+
)
372+
output = subprocess.check_output(
373+
create_results_path_cmd_string,
374+
shell=True,
375+
text=True,
376+
stderr=subprocess.STDOUT,
377+
)
378+
logging.debug("%s", output)
379+
except subprocess.CalledProcessError as error:
380+
print(f"mkdir for build folder failed with error code {error.returncode}")
381+
sys.exit(error.returncode)
371382

383+
native_df = None
372384
if run_native and sg_benchmarks_native[benchmark]:
373385
print_verbose(f"Collecting Native ({benchmark}).")
374386

@@ -382,7 +394,6 @@ def run_benchmarks(benchmark, run_native=False):
382394
)
383395
logging.debug("native_benchmark_path ... %s", native_benchmark_path)
384396

385-
results_dir = f"{SG_BENCHMARKS_BASE}/results/"
386397
results_path = f"{results_dir}/{benchmark}" + "_native_results.csv"
387398
logging.debug("results_path ... %s", results_path)
388399

@@ -434,22 +445,6 @@ def run_benchmarks(benchmark, run_native=False):
434445
print(f"Building native failed with error code {error.returncode}")
435446
sys.exit(error.returncode)
436447

437-
create_results_path_cmd_string = f"mkdir -p {results_dir}"
438-
try:
439-
logging.info(
440-
"Trying mkdir for results_path ... %s", create_results_path_cmd_string
441-
)
442-
output = subprocess.check_output(
443-
create_results_path_cmd_string,
444-
shell=True,
445-
text=True,
446-
stderr=subprocess.STDOUT,
447-
)
448-
logging.debug("%s", output)
449-
except subprocess.CalledProcessError as error:
450-
print(f"mkdir for build folder failed with error code {error.returncode}")
451-
sys.exit(error.returncode)
452-
453448
cli_cmd_string = (
454449
"LD_LIBRARY_PATH=/sightglass/engines/native/ "
455450
"/sightglass/target/release/sightglass-cli benchmark "
@@ -549,7 +544,6 @@ def run_benchmarks(benchmark, run_native=False):
549544
wasm_benchmark_path = f"{SG_BENCHMARKS_BASE}" + sg_benchmarks_wasm[benchmark]
550545
logging.debug("wasm_benchmark_path ... %s", wasm_benchmark_path)
551546

552-
results_dir = f"{SG_BENCHMARKS_BASE}/results/"
553547
results_path = f"{results_dir}/{benchmark}" + "_wasm_results.csv"
554548
logging.debug("results_path ... %s", results_path)
555549

@@ -867,7 +861,7 @@ def main():
867861

868862
if ARGS_DICT["list"]:
869863
print("")
870-
print("Scores\n------")
864+
print("Tests\n------")
871865
print(yaml.dump(perf_tests, sort_keys=True, default_flow_style=False))
872866
print("Suites\n------")
873867
print(yaml.dump(perf_suites, sort_keys=True, default_flow_style=False))

0 commit comments

Comments
 (0)