Skip to content

[DNM] Return builtin stats from a contract execution #1252

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

JulianGCalderon
Copy link
Contributor

@JulianGCalderon JulianGCalderon commented Jun 12, 2025

This PR adds support for returning builtin stats from a contract execution.

The Native builtin stats SHOULD be the same as the ones from a VM execution. We have not tested this thoroughly and it may not be the case. We should compare with the Cairo VM to ensure that we are increase the builtin counters correctly.

NOTE: The CI is failing because this is a breaking change.

Copy link

Benchmark results Main vs HEAD.

Base

Command Mean [s] Min [s] Max [s] Relative
base dict_insert.cairo (JIT) 5.165 ± 0.039 5.112 5.247 1.01 ± 0.01
base dict_insert.cairo (AOT) 5.096 ± 0.039 5.035 5.164 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head dict_insert.cairo (JIT) 5.169 ± 0.089 5.039 5.322 1.02 ± 0.02
head dict_insert.cairo (AOT) 5.075 ± 0.063 4.978 5.170 1.00

Base

Command Mean [s] Min [s] Max [s] Relative
base dict_snapshot.cairo (JIT) 5.032 ± 0.029 4.988 5.083 1.02 ± 0.01
base dict_snapshot.cairo (AOT) 4.943 ± 0.033 4.859 4.979 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head dict_snapshot.cairo (JIT) 5.172 ± 0.064 5.043 5.225 1.03 ± 0.02
head dict_snapshot.cairo (AOT) 5.003 ± 0.061 4.906 5.099 1.00

Base

Command Mean [s] Min [s] Max [s] Relative
base factorial_2M.cairo (JIT) 5.435 ± 0.019 5.396 5.467 1.00 ± 0.01
base factorial_2M.cairo (AOT) 5.418 ± 0.062 5.329 5.499 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head factorial_2M.cairo (JIT) 5.452 ± 0.060 5.321 5.545 1.01 ± 0.02
head factorial_2M.cairo (AOT) 5.394 ± 0.070 5.324 5.516 1.00

Base

Command Mean [s] Min [s] Max [s] Relative
base fib_2M.cairo (JIT) 4.946 ± 0.021 4.900 4.972 1.02 ± 0.01
base fib_2M.cairo (AOT) 4.867 ± 0.021 4.841 4.904 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head fib_2M.cairo (JIT) 5.191 ± 0.059 5.088 5.267 1.02 ± 0.02
head fib_2M.cairo (AOT) 5.083 ± 0.110 4.913 5.319 1.00

Base

Command Mean [s] Min [s] Max [s] Relative
base linear_search.cairo (JIT) 5.169 ± 0.044 5.095 5.233 1.03 ± 0.01
base linear_search.cairo (AOT) 5.004 ± 0.030 4.960 5.072 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head linear_search.cairo (JIT) 5.432 ± 0.090 5.250 5.592 1.06 ± 0.02
head linear_search.cairo (AOT) 5.145 ± 0.075 4.977 5.249 1.00

Base

Command Mean [s] Min [s] Max [s] Relative
base logistic_map.cairo (JIT) 5.213 ± 0.021 5.175 5.241 1.03 ± 0.01
base logistic_map.cairo (AOT) 5.048 ± 0.036 4.980 5.089 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head logistic_map.cairo (JIT) 5.309 ± 0.024 5.266 5.344 1.04 ± 0.01
head logistic_map.cairo (AOT) 5.084 ± 0.034 5.034 5.144 1.00

Copy link

Benchmarking results

Benchmark for program dict_insert

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 11.541 ± 0.082 11.401 11.703 2.32 ± 0.02
cairo-native (embedded AOT) 4.975 ± 0.036 4.931 5.056 1.00
cairo-native (embedded JIT using LLVM's ORC Engine) 5.046 ± 0.033 4.982 5.104 1.01 ± 0.01

Benchmark for program dict_snapshot

Open benchmarks
Command Mean [ms] Min [ms] Max [ms] Relative
Cairo-vm (Rust, Cairo 1) 808.6 ± 4.0 801.8 814.7 1.00
cairo-native (embedded AOT) 4870.0 ± 33.1 4806.7 4908.3 6.02 ± 0.05
cairo-native (embedded JIT using LLVM's ORC Engine) 4981.5 ± 69.1 4928.1 5158.6 6.16 ± 0.09

Benchmark for program factorial_2M

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 5.367 ± 0.039 5.316 5.456 1.01 ± 0.01
cairo-native (embedded AOT) 5.326 ± 0.037 5.286 5.416 1.00 ± 0.01
cairo-native (embedded JIT using LLVM's ORC Engine) 5.324 ± 0.035 5.271 5.374 1.00

Benchmark for program fib_2M

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 5.209 ± 0.044 5.161 5.321 1.05 ± 0.01
cairo-native (embedded AOT) 4.945 ± 0.053 4.856 5.017 1.00
cairo-native (embedded JIT using LLVM's ORC Engine) 5.019 ± 0.065 4.877 5.103 1.01 ± 0.02

Benchmark for program linear_search

Open benchmarks
Command Mean [ms] Min [ms] Max [ms] Relative
Cairo-vm (Rust, Cairo 1) 834.9 ± 8.1 822.9 852.3 1.00
cairo-native (embedded AOT) 4932.9 ± 50.7 4876.0 5011.5 5.91 ± 0.08
cairo-native (embedded JIT using LLVM's ORC Engine) 5132.3 ± 44.2 5061.6 5206.3 6.15 ± 0.08

Benchmark for program logistic_map

Open benchmarks
Command Mean [ms] Min [ms] Max [ms] Relative
Cairo-vm (Rust, Cairo 1) 549.8 ± 11.0 535.5 571.9 1.00
cairo-native (embedded AOT) 5135.7 ± 66.5 4993.7 5187.8 9.34 ± 0.22
cairo-native (embedded JIT using LLVM's ORC Engine) 5330.2 ± 40.7 5284.4 5412.3 9.70 ± 0.21

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Please upload report for BASE (main@b92123c). Learn more about missing BASE report.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1252   +/-   ##
=======================================
  Coverage        ?   80.19%           
=======================================
  Files           ?      112           
  Lines           ?    29981           
  Branches        ?        0           
=======================================
  Hits            ?    24042           
  Misses          ?     5939           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants