-
Notifications
You must be signed in to change notification settings - Fork 44
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
Open
JulianGCalderon
wants to merge
10
commits into
main
Choose a base branch
from
dynamic-runtime
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+374
−1,077
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
JulianGCalderon
force-pushed
the
dynamic-runtime
branch
from
January 14, 2025 17:30
76e49df
to
a468e23
Compare
Benchmark results Main vs HEAD.
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1051 +/- ##
==========================================
- Coverage 80.95% 80.82% -0.14%
==========================================
Files 108 108
Lines 29938 29517 -421
==========================================
- Hits 24237 23856 -381
+ Misses 5701 5661 -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) |
20.981 ± 0.208 | 20.790 | 21.512 | 5.53 ± 0.12 |
cairo-native (embedded AOT) |
3.795 ± 0.072 | 3.699 | 3.899 | 1.00 |
cairo-native (embedded JIT using LLVM's ORC Engine) |
3.826 ± 0.024 | 3.785 | 3.871 | 1.01 ± 0.02 |
Benchmark for program dict_snapshot
Open benchmarks
Command | Mean [s] | Min [s] | Max [s] | Relative |
---|---|---|---|---|
Cairo-vm (Rust, Cairo 1) |
5.877 ± 0.090 | 5.793 | 6.041 | 1.56 ± 0.03 |
cairo-native (embedded AOT) |
3.798 ± 0.062 | 3.694 | 3.901 | 1.01 ± 0.02 |
cairo-native (embedded JIT using LLVM's ORC Engine) |
3.768 ± 0.045 | 3.721 | 3.847 | 1.00 |
Benchmark for program factorial_2M
Open benchmarks
Command | Mean [s] | Min [s] | Max [s] | Relative |
---|---|---|---|---|
Cairo-vm (Rust, Cairo 1) |
15.201 ± 0.141 | 14.958 | 15.345 | 3.75 ± 0.05 |
cairo-native (embedded AOT) |
4.053 ± 0.037 | 4.002 | 4.102 | 1.00 |
cairo-native (embedded JIT using LLVM's ORC Engine) |
4.186 ± 0.064 | 4.099 | 4.274 | 1.03 ± 0.02 |
Benchmark for program fib_2M
Open benchmarks
Command | Mean [s] | Min [s] | Max [s] | Relative |
---|---|---|---|---|
Cairo-vm (Rust, Cairo 1) |
14.916 ± 0.103 | 14.791 | 15.083 | 4.20 ± 0.06 |
cairo-native (embedded AOT) |
3.552 ± 0.041 | 3.506 | 3.619 | 1.00 |
cairo-native (embedded JIT using LLVM's ORC Engine) |
3.632 ± 0.055 | 3.549 | 3.714 | 1.02 ± 0.02 |
Benchmark for program linear_search
Open benchmarks
Command | Mean [s] | Min [s] | Max [s] | Relative |
---|---|---|---|---|
Cairo-vm (Rust, Cairo 1) |
5.896 ± 0.069 | 5.781 | 5.995 | 1.60 ± 0.03 |
cairo-native (embedded AOT) |
3.694 ± 0.053 | 3.642 | 3.783 | 1.00 |
cairo-native (embedded JIT using LLVM's ORC Engine) |
3.830 ± 0.035 | 3.778 | 3.892 | 1.04 ± 0.02 |
Benchmark for program logistic_map
Open benchmarks
Command | Mean [s] | Min [s] | Max [s] | Relative |
---|---|---|---|---|
Cairo-vm (Rust, Cairo 1) |
5.853 ± 0.087 | 5.745 | 6.004 | 1.48 ± 0.03 |
cairo-native (embedded AOT) |
3.954 ± 0.046 | 3.871 | 4.021 | 1.00 |
cairo-native (embedded JIT using LLVM's ORC Engine) |
4.097 ± 0.031 | 4.060 | 4.156 | 1.04 ± 0.01 |
JulianGCalderon
force-pushed
the
dynamic-runtime
branch
11 times, most recently
from
January 15, 2025 18:49
94ca074
to
be15f36
Compare
JulianGCalderon
force-pushed
the
dynamic-runtime
branch
5 times, most recently
from
January 15, 2025 19:33
23138a4
to
5005809
Compare
JulianGCalderon
force-pushed
the
dynamic-runtime
branch
3 times, most recently
from
January 15, 2025 21:11
f62b6d7
to
46872ae
Compare
JulianGCalderon
force-pushed
the
dynamic-runtime
branch
from
January 16, 2025 15:40
8d6bac7
to
1880fbe
Compare
JulianGCalderon
requested review from
edg-l,
igaray,
azteca1998,
jrchatruc,
entropidelic,
fmoletta,
Oppen,
pefontana and
gabrielbosio
as code owners
January 16, 2025 15:52
azteca1998
approved these changes
Jan 16, 2025
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