-
Notifications
You must be signed in to change notification settings - Fork 45
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
Implement runtime with dynamic dispatch #1051
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76e49df
to
a468e23
Compare
Benchmark results Main vs HEAD.Base
Head
Base
Head
Base
Head
Base
Head
Base
Head
Base
Head
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1051 +/- ##
==========================================
- Coverage 80.94% 80.80% -0.14%
==========================================
Files 108 108
Lines 29978 29557 -421
==========================================
- Hits 24266 23885 -381
+ Misses 5712 5672 -40 ☔ View full report in Codecov by Sentry. |
Benchmarking resultsBenchmark for program
|
Command | Mean [s] | Min [s] | Max [s] | Relative |
---|---|---|---|---|
Cairo-vm (Rust, Cairo 1) |
21.192 ± 0.208 | 20.947 | 21.569 | 5.31 ± 0.08 |
cairo-native (embedded AOT) |
3.994 ± 0.044 | 3.918 | 4.057 | 1.00 |
cairo-native (embedded JIT using LLVM's ORC Engine) |
4.037 ± 0.026 | 4.013 | 4.084 | 1.01 ± 0.01 |
Benchmark for program dict_snapshot
Open benchmarks
Command | Mean [s] | Min [s] | Max [s] | Relative |
---|---|---|---|---|
Cairo-vm (Rust, Cairo 1) |
6.015 ± 0.043 | 5.955 | 6.098 | 1.57 ± 0.02 |
cairo-native (embedded AOT) |
3.822 ± 0.032 | 3.772 | 3.875 | 1.00 |
cairo-native (embedded JIT using LLVM's ORC Engine) |
3.893 ± 0.030 | 3.844 | 3.936 | 1.02 ± 0.01 |
Benchmark for program factorial_2M
Open benchmarks
Command | Mean [s] | Min [s] | Max [s] | Relative |
---|---|---|---|---|
Cairo-vm (Rust, Cairo 1) |
14.661 ± 0.109 | 14.433 | 14.813 | 3.58 ± 0.04 |
cairo-native (embedded AOT) |
4.093 ± 0.029 | 4.055 | 4.145 | 1.00 |
cairo-native (embedded JIT using LLVM's ORC Engine) |
4.184 ± 0.032 | 4.134 | 4.242 | 1.02 ± 0.01 |
Benchmark for program fib_2M
Open benchmarks
Command | Mean [s] | Min [s] | Max [s] | Relative |
---|---|---|---|---|
Cairo-vm (Rust, Cairo 1) |
14.561 ± 0.104 | 14.334 | 14.735 | 3.98 ± 0.05 |
cairo-native (embedded AOT) |
3.662 ± 0.033 | 3.615 | 3.726 | 1.00 |
cairo-native (embedded JIT using LLVM's ORC Engine) |
3.703 ± 0.033 | 3.653 | 3.748 | 1.01 ± 0.01 |
Benchmark for program linear_search
Open benchmarks
Command | Mean [s] | Min [s] | Max [s] | Relative |
---|---|---|---|---|
Cairo-vm (Rust, Cairo 1) |
6.027 ± 0.060 | 5.917 | 6.113 | 1.58 ± 0.02 |
cairo-native (embedded AOT) |
3.810 ± 0.027 | 3.771 | 3.857 | 1.00 |
cairo-native (embedded JIT using LLVM's ORC Engine) |
3.993 ± 0.044 | 3.936 | 4.099 | 1.05 ± 0.01 |
Benchmark for program logistic_map
Open benchmarks
Command | Mean [s] | Min [s] | Max [s] | Relative |
---|---|---|---|---|
Cairo-vm (Rust, Cairo 1) |
5.838 ± 0.078 | 5.722 | 5.979 | 1.51 ± 0.04 |
cairo-native (embedded AOT) |
3.856 ± 0.074 | 3.778 | 3.970 | 1.00 |
cairo-native (embedded JIT using LLVM's ORC Engine) |
3.994 ± 0.066 | 3.924 | 4.088 | 1.04 ± 0.03 |
94ca074
to
be15f36
Compare
23138a4
to
5005809
Compare
f62b6d7
to
46872ae
Compare
8d6bac7
to
1880fbe
Compare
azteca1998
previously approved these changes
Jan 16, 2025
edg-l
previously approved these changes
Jan 20, 2025
505ee41
gabrielbosio
approved these changes
Jan 22, 2025
edg-l
approved these changes
Jan 23, 2025
azteca1998
approved these changes
Jan 24, 2025
azteca1998
pushed a commit
that referenced
this pull request
Feb 4, 2025
* Load dynamic runtime globals * Implement dynamic runtime bindings * Use dynamic runtime set_costs_builtin * Remove phantom data from RuntimeBindingsMeta * Remove symbol register in JIT executor * Remove runtime linking in AOT executor * Remove cairo_native__get_version check * Use original name for runtime globals * Remove no_mangle attribute * Remove AOT standalone benchmarks --------- Co-authored-by: Edgar <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implements runtime with dynamic dispatch.
Depends on #1052
Previously, runtime function were defined in a different crate
cairo_native_runtime
, compiled as a static library (.a
), and linked to the starknet contract.This PR gets rid of the runtime static library completely, by defining a global for each runtime function. On execution, it will access the global to find the runtime function. This global is originally empty, but when loading the executor, the caller sets the globals, making them point to the correct functions (located in the callers binary).
This PR is a POC and should be tested thoroughly. As this new approach adds an additional level of indirection when calling the runtime, we should check that it doesn't introduce benchmark regressions.
Implementation Details
The
build_function
method declares the global if not yet declared, accesses it, and calls the function.The
setup_runtime
function sets the value of all defined globals with their corresponding location. It is called when loading the executors.Since we are using rust's runtime, instead of contract's runtime, we can call
set_costs_builtin
directly, instead of looking for the symbol.I removed the hyperfine standalone AOT benches, as adapting it to the new dynamic runtime is difficult, and probably not worth it.
Roadmap
Why is it faster? We should take a closer look at it.
Checklist