-
Notifications
You must be signed in to change notification settings - Fork 61
Description
I ran a Hello World + Fibonacci benchmark comparing Virgil with Rust and TinyGo (the two most often cited Wasm compilers) — the results seem to good to be true!
Virgil outperforms both Rust and TinyGo by orders of magnitude in terms of both compiler speed and executable file sizes. Yes, the 0.00s compile time is correct — time(1) reports to the nearest 1/100s (when I compiled my first Virgil program it was so fast I thought it hadn't run).
The Numbers
wasm
| Compile time (secs) | Executable size (B) | Execution time (secs) | |
|---|---|---|---|
| go | 4.13s | 428,547 | 0.62s |
| rust | 0.33s | 2,054,632 | 1.80s |
| virgil | 0.00s | 8,802 | 0.96s |
wasm-optimised
| Compile time (secs) | Executable size (B) | Execution time (secs) | |
|---|---|---|---|
| go | 3.88s | 191,265 | 0.62s |
| rust | 0.80s | 301,363 | 0.66s |
| virgil | 0.01s | 7,891 | 1.07s |
x86-64-linux
| Compile time (secs) | Executable size (B) | Execution time (secs) | |
|---|---|---|---|
| go | 1.94s | 503,640 | 0.39s |
| rust | 0.30s | 3,853,504 | 1.53s |
| virgil | 0.01s | 20,552 | 0.63s |
x86-64-linux-optimised
| Compile time (secs) | Executable size (B) | Execution time (secs) | |
|---|---|---|---|
| go | 2.04s | 140,056 | 0.38s |
| rust | 2.73s | 1,653,736 | 0.32s |
| virgil | 0.01s | 19,552 | 0.64s |
WebAssembly Performance
- The Virgil compiler is ~50x faster than the Rust compiler and over 300x faster than the TinyGo compiler.
- The optimised Virgil executable is over 35x smaller than the Rust executable and over 20x smaller than TinyGo executable.
- The TinyGo executable runs ~7% faster than the Rust executable and ~83% faster than the Virgil executable (executed on the wasmtime runtime).
x86-64 Performance
- The Virgil compiler is ~30x faster than the Rust compiler and ~200x faster than the TinyGo compiler.
- The optimised Virgil executable is ~80x smaller than the Rust executable and ~7x smaller than TinyGo executable.
Notes
-
Virgil Wasm code generated with the compiler
-opt=alloption ran slower than without it but the executable size was ~10% smaller, so currently there's not a lot to be gained using the-opt=alloption. -
Importing the
fmtpackage increased the size of the TinyGo Wasm executable from 8KB to 191KB (an increase of 183KB), whereas importing the VirgilStringscomponent increased the size of the Virgil Wasm executable from 3.6KB to 7.9KB (an increase of only 4.3KB). -
The compiled Wasm files were executed with
wasmtime-cli 0.39.1
Details
The raw data along with source code and platform information is attached.
go-results.txt
rust-results.txt
virgil-results.txt