Rust ISA benchmarks
Codebase: https://github.com/aborg-dev/isa_benchmarks
Index document: https://hackmd.io/@aborg-dev/H1JgUcGCR
This document describes the set of experiments to find the best ISA that we can use as an intermediate representation when compiling Rust code to Zisk.
This involves:
- Selecting a set of benchmarks and implementing them in Rust
- Compiling the resulting programs to a range of ISAs supported by Rust compiler with right optimization flags
- Running the resulting binaries in QEMU and measuring the execution costs in the number and complexity of instructions
Results
Summary for Ethereum block
- rustc -> x86: 250M steps (with vectorized instr 2.5M)
- rustc -> aarch64: 191M steps
- rustc -> riscv64gc: 320M steps
- ziskemu steps match qemu instruction counter: 320M steps
rustc_codegen_cranelift
is around 8x slower with default settings
- Code is indeed much less optimized, needs inlining, loop unrolling, etc.
- rustc -> WASM -> x86: 600M steps
- rustc -> WASM -> w2c2 -> C -> x86: 376M steps
Remaining steps
- Understand why "rustc -> x86" is so fast for SHA 256
- So far seems to be due to more complex instructions which leads to less instructions used overall
- Understand why rust -> WASM -> x86 is 10x-15x slower
- Is inlining to blame for the results? No, it is properly inlined
- Or do we need to example WASM vectorized instructions? Not really, I disabled all of these
- Also could be due to WASM interpreter overhead - the most likely one, need to verify
- Measure WASM -> Cranelift -> RISC-V path
- If we are at the same level, might be a viable path
Setup
Profiling
Profiling commands:
Raw data
rustc -> riscv64ima-polygon-ziskos-elf, ziskemu
Release:
Debug (failed):
Crashes under QEMU:
rustc -> riscv64gc-unknown-linux-gnu
Release:
Debug:
rustc_codegen_cranelift -> riscv64gc-unknown-linux-gnu
Release:
Debug:
rustc_codegen_cranelift -> x86
Release:
Rustc -> WASM -> CLIF -> x86
Rustc -> WASM -> CLIF -> RISC-V
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
rustc -> x86
Release:
Debug:
rustc -> aarch64
Release:
Debug: