Skip to content

Conversation

@FrancoGiachetta
Copy link
Contributor

Use Montgomery representation for Felts

Closes #NA

Introduces Breaking Changes?

Yes/No.

These PRs should be merged after this one right away, in that order.

Checklist

  • Linked to Github Issue.
  • Unit tests added.
  • Integration tests added.
  • This change requires new documentation.
    • Documentation has been added/updated.

@github-actions
Copy link

github-actions bot commented Oct 31, 2025

Benchmark results Main vs HEAD.

Base

Command Mean [s] Min [s] Max [s] Relative
base dict_insert.cairo (JIT) 1.969 ± 0.013 1.947 1.985 1.03 ± 0.01
base dict_insert.cairo (AOT) 1.904 ± 0.016 1.873 1.932 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head dict_insert.cairo (JIT) 2.034 ± 0.047 1.984 2.119 1.04 ± 0.03
head dict_insert.cairo (AOT) 1.947 ± 0.041 1.900 2.051 1.00

Base

Command Mean [s] Min [s] Max [s] Relative
base dict_snapshot.cairo (JIT) 1.706 ± 0.018 1.678 1.732 1.07 ± 0.02
base dict_snapshot.cairo (AOT) 1.600 ± 0.018 1.566 1.625 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head dict_snapshot.cairo (JIT) 1.764 ± 0.041 1.728 1.866 1.04 ± 0.03
head dict_snapshot.cairo (AOT) 1.701 ± 0.031 1.637 1.740 1.00

Base

Command Mean [s] Min [s] Max [s] Relative
base factorial_2M.cairo (JIT) 2.108 ± 0.020 2.083 2.152 1.02 ± 0.01
base factorial_2M.cairo (AOT) 2.061 ± 0.017 2.035 2.099 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head factorial_2M.cairo (JIT) 1.700 ± 0.034 1.656 1.769 1.03 ± 0.03
head factorial_2M.cairo (AOT) 1.651 ± 0.042 1.596 1.739 1.00

Base

Command Mean [s] Min [s] Max [s] Relative
base fib_2M.cairo (JIT) 1.652 ± 0.012 1.638 1.671 1.04 ± 0.01
base fib_2M.cairo (AOT) 1.587 ± 0.018 1.563 1.611 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head fib_2M.cairo (JIT) 1.705 ± 0.038 1.665 1.794 1.04 ± 0.02
head fib_2M.cairo (AOT) 1.633 ± 0.014 1.614 1.662 1.00

Base

Command Mean [s] Min [s] Max [s] Relative
base linear_search.cairo (JIT) 1.760 ± 0.016 1.738 1.788 1.08 ± 0.02
base linear_search.cairo (AOT) 1.630 ± 0.018 1.598 1.651 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head linear_search.cairo (JIT) 1.798 ± 0.011 1.782 1.816 1.06 ± 0.02
head linear_search.cairo (AOT) 1.699 ± 0.022 1.660 1.731 1.00

Base

Command Mean [s] Min [s] Max [s] Relative
base logistic_map.cairo (JIT) 1.926 ± 0.019 1.896 1.961 1.09 ± 0.01
base logistic_map.cairo (AOT) 1.762 ± 0.010 1.747 1.778 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head logistic_map.cairo (JIT) 1.907 ± 0.011 1.886 1.918 1.11 ± 0.02
head logistic_map.cairo (AOT) 1.724 ± 0.029 1.671 1.777 1.00

@github-actions
Copy link

github-actions bot commented Oct 31, 2025

Benchmarking results

Benchmark for program dict_insert

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 11.010 ± 0.092 10.910 11.229 5.27 ± 0.09
cairo-native (embedded AOT) 2.089 ± 0.030 2.055 2.151 1.00
cairo-native (embedded JIT using LLVM's ORC Engine) 2.157 ± 0.022 2.127 2.199 1.03 ± 0.02

Benchmark for program dict_snapshot

Open benchmarks
Command Mean [ms] Min [ms] Max [ms] Relative
Cairo-vm (Rust, Cairo 1) 596.8 ± 5.4 589.7 605.9 1.00
cairo-native (embedded AOT) 1756.9 ± 27.1 1705.5 1799.2 2.94 ± 0.05
cairo-native (embedded JIT using LLVM's ORC Engine) 1862.6 ± 16.9 1827.3 1884.5 3.12 ± 0.04

Benchmark for program factorial_2M

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 4.867 ± 0.014 4.851 4.888 2.75 ± 0.05
cairo-native (embedded AOT) 1.771 ± 0.034 1.709 1.819 1.00
cairo-native (embedded JIT using LLVM's ORC Engine) 1.835 ± 0.037 1.780 1.902 1.04 ± 0.03

Benchmark for program factorial_2M_inv

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 12.934 ± 0.121 12.738 13.091 2.04 ± 0.02
cairo-native (embedded AOT) 6.342 ± 0.023 6.299 6.389 1.00
cairo-native (embedded JIT using LLVM's ORC Engine) 6.373 ± 0.027 6.324 6.408 1.00 ± 0.01

Benchmark for program fib_2M

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 4.788 ± 0.027 4.746 4.825 2.72 ± 0.04
cairo-native (embedded AOT) 1.760 ± 0.021 1.718 1.788 1.00
cairo-native (embedded JIT using LLVM's ORC Engine) 1.832 ± 0.030 1.773 1.870 1.04 ± 0.02

Benchmark for program linear_search

Open benchmarks
Command Mean [ms] Min [ms] Max [ms] Relative
Cairo-vm (Rust, Cairo 1) 642.6 ± 6.2 634.5 654.5 1.00
cairo-native (embedded AOT) 1786.9 ± 29.9 1750.6 1845.7 2.78 ± 0.05
cairo-native (embedded JIT using LLVM's ORC Engine) 1949.5 ± 25.3 1890.8 1978.8 3.03 ± 0.05

Benchmark for program logistic_map

Open benchmarks
Command Mean [ms] Min [ms] Max [ms] Relative
Cairo-vm (Rust, Cairo 1) 538.5 ± 8.2 521.4 547.5 1.00
cairo-native (embedded AOT) 1800.3 ± 20.2 1770.1 1823.5 3.34 ± 0.06
cairo-native (embedded JIT using LLVM's ORC Engine) 1947.6 ± 33.0 1913.9 2010.2 3.62 ± 0.08

@github-actions
Copy link

github-actions bot commented Nov 7, 2025

✅ Code is now correctly formatted.

@codecov-commenter
Copy link

codecov-commenter commented Dec 5, 2025

Codecov Report

❌ Patch coverage is 78.31169% with 167 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.55%. Comparing base (5df2d2c) to head (23e2aad).

Files with missing lines Patch % Lines
src/starknet.rs 0.84% 117 Missing ⚠️
src/libfuncs/starknet.rs 50.00% 26 Missing ⚠️
src/libfuncs/bounded_int.rs 48.27% 15 Missing ⚠️
src/libfuncs/cast.rs 91.30% 4 Missing ⚠️
src/libfuncs/felt252.rs 83.33% 2 Missing ⚠️
src/libfuncs/bytes31.rs 90.00% 1 Missing ⚠️
src/utils/montgomery.rs 99.70% 1 Missing ⚠️
src/values.rs 97.56% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1443      +/-   ##
==========================================
+ Coverage   79.52%   79.55%   +0.02%     
==========================================
  Files         108      109       +1     
  Lines       26667    27121     +454     
==========================================
+ Hits        21208    21576     +368     
- Misses       5459     5545      +86     

☔ 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.

@FrancoGiachetta
Copy link
Contributor Author

FrancoGiachetta commented Dec 23, 2025

Ran a benchmark of 1000 blocks (1470000-1471000) using this commit: 685735f. The results only show a clear regression in native's performance compared to previous versions of it. This is probably related to greater use of syscalls, and other non-felt related libfuncs, which made this change to have not positive effects but rather negative ones over natives performance.
Since will this most certainly the case for the majority of the blocks, I don't see any advantages of having this feature in the code.

block-speedup-distribution
call-throughput-distribution
execution-time-by-contract-class
execution-time-by-gas-usage
tx-speedup-distribution

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.

3 participants