-
Notifications
You must be signed in to change notification settings - Fork 107
Better benchmarks #684
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I tried to compile libstd with mir inlining for fairer comparison with cg_llvm, as the later uses an optimized sysroot, while cg_clif doesn't. However I hit a rustc bug: rust-lang/rust#63802. |
$ # Bench cg_llvm, cg_clif+cg_clif sysroot, cg_clif+cg_llvm sysroot
$ hyperfine --prepare "cargo clean" "cargo build" "CHANNEL=release ../cargo.sh build" 'RUSTFLAGS="-Zcodegen-backend=/home/bjorn/Documenten/cg_clif/target/release/librustc_codegen_cranelift.so -Cpanic=abort" cargo build --target x86_64-unknown-linux-gnu'
Benchmark #1: cargo build
Time (mean ± σ): 31.611 s ± 1.041 s [User: 84.973 s, System: 3.935 s]
Range (min … max): 30.514 s … 33.711 s 10 runs
Benchmark #2: CHANNEL=release ../cargo.sh build
Time (mean ± σ): 31.211 s ± 1.130 s [User: 66.759 s, System: 5.140 s]
Range (min … max): 29.462 s … 32.760 s 10 runs
Benchmark #3: RUSTFLAGS="-Zcodegen-backend=/home/bjorn/Documenten/cg_clif/target/release/librustc_codegen_cranelift.so -Cpanic=abort" cargo build --target x86_64-unknown-linux-gnu
Time (mean ± σ): 29.833 s ± 1.501 s [User: 66.105 s, System: 4.819 s]
Range (min … max): 27.988 s … 32.409 s 10 runs
Summary
'RUSTFLAGS="-Zcodegen-backend=/home/bjorn/Documenten/cg_clif/target/release/librustc_codegen_cranelift.so -Cpanic=abort" cargo build --target x86_64-unknown-linux-gnu' ran
1.05 ± 0.06 times faster than 'CHANNEL=release ../cargo.sh build'
1.06 ± 0.06 times faster than 'cargo build' Difference between cg_clif (compiled in release mode) and cg_llvm is within noise. This is despite cg_llvm using multiple threads for optimizations unlike cg_clif and cg_clif containing a lot of sanity checks. $ # Bench cg_llvm with single thread optimization
$ hyperfine --prepare "cargo clean" "RUSTFLAGS=-Ccodegen-units=1 cargo build"
Benchmark #1: RUSTFLAGS=-Ccodegen-units=1 cargo build
Time (mean ± σ): 35.033 s ± 1.427 s [User: 69.766 s, System: 3.784 s]
Range (min … max): 33.336 s … 38.439 s 10 runs |
Keeping the incremental data gives cg_clif a huge advantage over cg_llvm though: $ hyperfine --prepare "rm -r target/debug/deps" --warmup 1 "cargo build" "RUSTFLAGS=-Ccodegen-units=1 cargo build" "CHANNEL=release ../cargo.sh build" 'RUSTFLAGS="-Zcodegen-backend=/home/bjorn/Documenten/cg_clif/target/release/librustc_codegen_cranelift.so -Cpanic=abort" cargo build --target x86_64-unknown-linux-gnu'
Benchmark #1: cargo build
Time (mean ± σ): 28.747 s ± 1.363 s [User: 76.805 s, System: 2.840 s]
Range (min … max): 26.742 s … 30.305 s 10 runs
Benchmark #2: RUSTFLAGS=-Ccodegen-units=1 cargo build
Time (mean ± σ): 34.041 s ± 2.252 s [User: 63.653 s, System: 2.885 s]
Range (min … max): 31.641 s … 38.352 s 10 runs
Benchmark #3: CHANNEL=release ../cargo.sh build
Time (mean ± σ): 20.232 s ± 1.091 s [User: 28.533 s, System: 1.291 s]
Range (min … max): 18.719 s … 21.881 s 10 runs
Benchmark #4: RUSTFLAGS="-Zcodegen-backend=/home/bjorn/Documenten/cg_clif/target/release/librustc_codegen_cranelift.so -Cpanic=abort" cargo build --target x86_64-unknown-linux-gnu
Time (mean ± σ): 20.707 s ± 2.022 s [User: 28.811 s, System: 1.252 s]
Range (min … max): 18.844 s … 25.844 s 10 runs
Summary
'CHANNEL=release ../cargo.sh build' ran
1.02 ± 0.11 times faster than 'RUSTFLAGS="-Zcodegen-backend=/home/bjorn/Documenten/cg_clif/target/release/librustc_codegen_cranelift.so -Cpanic=abort" cargo build --target x86_64-unknown-linux-gnu'
1.42 ± 0.10 times faster than 'cargo build'
1.68 ± 0.14 times faster than 'RUSTFLAGS=-Ccodegen-units=1 cargo build' |
Speeds up simple-raytracer by 7% (cc #684)
Speeds up simple-raytracer by 30% (cc #684) Also reduces the size of the simple-raytracer binary from 9.2MB to 8.6MB
Runtime of simple-raytracer:
cg_clif is b9dc950 |
After 15b9834:
(benched on faster machine than previous comments) There is now pretty much no difference between cg_clif and cg_llvm. 🎉 |
5b17cf2 added simple-raytracer as benchmark. |
Just tried to compile veloren using cg_clif. I was surprised by the huge gap between cg_clif and cg_llvm:
I haven't tried running the compiled version though as threads are not yet supported. |
Currently only compilation and execution of very simple crates is benchmarked. An example of a useful benchmark would be https://github.com/ebobby/simple-raytracer.
The text was updated successfully, but these errors were encountered: