Skip to content

Conversation

@DiegoCivi
Copy link
Contributor

@DiegoCivi DiegoCivi commented Nov 6, 2025

Implement Squashed Felt252 Dict Entries libfunc

Implements the SquashedFelt252Dict libfunc:

  • SquashedFelt252DictConcreteLibfunc::IntoEntries

Closes #1151

Introduces Breaking Changes?

No.

Checklist

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

@codecov-commenter
Copy link

codecov-commenter commented Nov 6, 2025

Codecov Report

❌ Patch coverage is 93.14079% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.60%. Comparing base (72ccf62) to head (7f9ae99).

Files with missing lines Patch % Lines
src/libfuncs/squashed_dict.rs 93.71% 11 Missing ⚠️
src/runtime.rs 90.90% 6 Missing ⚠️
src/metadata/runtime_bindings.rs 93.75% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1446      +/-   ##
==========================================
+ Coverage   81.47%   81.60%   +0.12%     
==========================================
  Files         105      106       +1     
  Lines       25759    26033     +274     
==========================================
+ Hits        20987    21244     +257     
- Misses       4772     4789      +17     

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

@github-actions
Copy link

github-actions bot commented Nov 6, 2025

Benchmark results Main vs HEAD.

Base

Command Mean [s] Min [s] Max [s] Relative
base dict_insert.cairo (JIT) 1.957 ± 0.021 1.927 1.995 1.05 ± 0.02
base dict_insert.cairo (AOT) 1.868 ± 0.019 1.843 1.911 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head dict_insert.cairo (JIT) 1.991 ± 0.022 1.953 2.031 1.05 ± 0.01
head dict_insert.cairo (AOT) 1.903 ± 0.014 1.877 1.923 1.00

Base

Command Mean [s] Min [s] Max [s] Relative
base dict_snapshot.cairo (JIT) 1.646 ± 0.018 1.608 1.672 1.07 ± 0.02
base dict_snapshot.cairo (AOT) 1.532 ± 0.016 1.509 1.559 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head dict_snapshot.cairo (JIT) 1.689 ± 0.018 1.659 1.708 1.07 ± 0.02
head dict_snapshot.cairo (AOT) 1.582 ± 0.015 1.561 1.606 1.00

Base

Command Mean [s] Min [s] Max [s] Relative
base factorial_2M.cairo (JIT) 2.031 ± 0.029 1.997 2.090 1.02 ± 0.02
base factorial_2M.cairo (AOT) 1.986 ± 0.015 1.970 2.012 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head factorial_2M.cairo (JIT) 2.070 ± 0.024 2.029 2.100 1.02 ± 0.01
head factorial_2M.cairo (AOT) 2.030 ± 0.018 1.994 2.057 1.00

Base

Command Mean [s] Min [s] Max [s] Relative
base fib_2M.cairo (JIT) 1.543 ± 0.010 1.530 1.563 1.04 ± 0.01
base fib_2M.cairo (AOT) 1.487 ± 0.009 1.474 1.499 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head fib_2M.cairo (JIT) 1.603 ± 0.015 1.575 1.625 1.03 ± 0.01
head fib_2M.cairo (AOT) 1.560 ± 0.012 1.540 1.581 1.00

Base

Command Mean [s] Min [s] Max [s] Relative
base heavy_circuit.cairo (JIT) 13.064 ± 0.186 12.802 13.318 1.00 ± 0.02
base heavy_circuit.cairo (AOT) 13.008 ± 0.106 12.817 13.123 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head heavy_circuit.cairo (JIT) 13.210 ± 0.051 13.139 13.297 1.03 ± 0.00
head heavy_circuit.cairo (AOT) 12.775 ± 0.023 12.735 12.808 1.00

Base

Command Mean [s] Min [s] Max [s] Relative
base linear_search.cairo (JIT) 1.822 ± 0.017 1.789 1.847 1.09 ± 0.02
base linear_search.cairo (AOT) 1.680 ± 0.024 1.650 1.712 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head linear_search.cairo (JIT) 1.772 ± 0.016 1.745 1.788 1.09 ± 0.01
head linear_search.cairo (AOT) 1.628 ± 0.014 1.606 1.652 1.00

Base

Command Mean [s] Min [s] Max [s] Relative
base logistic_map.cairo (JIT) 1.947 ± 0.013 1.928 1.969 1.10 ± 0.02
base logistic_map.cairo (AOT) 1.775 ± 0.023 1.730 1.814 1.00

Head

Command Mean [s] Min [s] Max [s] Relative
head logistic_map.cairo (JIT) 1.894 ± 0.022 1.872 1.941 1.11 ± 0.02
head logistic_map.cairo (AOT) 1.711 ± 0.014 1.688 1.738 1.00

@github-actions
Copy link

github-actions bot commented Nov 6, 2025

Benchmarking results

Benchmark for program dict_insert

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 11.289 ± 0.070 11.192 11.390 5.69 ± 0.09
cairo-native (embedded AOT) 1.983 ± 0.030 1.947 2.057 1.00
cairo-native (embedded JIT using LLVM's ORC Engine) 2.067 ± 0.035 2.012 2.129 1.04 ± 0.02

Benchmark for program dict_snapshot

Open benchmarks
Command Mean [ms] Min [ms] Max [ms] Relative
Cairo-vm (Rust, Cairo 1) 591.1 ± 10.1 575.5 605.0 1.00
cairo-native (embedded AOT) 1682.9 ± 24.6 1640.9 1711.5 2.85 ± 0.06
cairo-native (embedded JIT using LLVM's ORC Engine) 1816.0 ± 35.4 1763.9 1867.9 3.07 ± 0.08

Benchmark for program factorial_2M

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 5.036 ± 0.051 4.992 5.170 2.33 ± 0.04
cairo-native (embedded AOT) 2.167 ± 0.051 2.105 2.255 1.00 ± 0.03
cairo-native (embedded JIT using LLVM's ORC Engine) 2.163 ± 0.033 2.119 2.212 1.00

Benchmark for program fib_2M

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 4.922 ± 0.025 4.879 4.956 3.05 ± 0.04
cairo-native (embedded AOT) 1.614 ± 0.022 1.590 1.664 1.00
cairo-native (embedded JIT using LLVM's ORC Engine) 1.649 ± 0.016 1.629 1.675 1.02 ± 0.02

Benchmark for program heavy_circuit

Open benchmarks
Command Mean [s] Min [s] Max [s] Relative
Cairo-vm (Rust, Cairo 1) 10.167 ± 0.113 9.997 10.335 1.00
cairo-native (embedded AOT) 14.293 ± 0.196 14.043 14.586 1.41 ± 0.02
cairo-native (embedded JIT using LLVM's ORC Engine) 14.847 ± 0.108 14.670 14.984 1.46 ± 0.02

Benchmark for program linear_search

Open benchmarks
Command Mean [ms] Min [ms] Max [ms] Relative
Cairo-vm (Rust, Cairo 1) 614.7 ± 17.9 599.0 655.3 1.00
cairo-native (embedded AOT) 1709.2 ± 24.4 1673.6 1750.4 2.78 ± 0.09
cairo-native (embedded JIT using LLVM's ORC Engine) 1883.6 ± 43.1 1824.0 1968.1 3.06 ± 0.11

Benchmark for program logistic_map

Open benchmarks
Command Mean [ms] Min [ms] Max [ms] Relative
Cairo-vm (Rust, Cairo 1) 517.4 ± 12.9 506.2 542.9 1.00
cairo-native (embedded AOT) 1780.5 ± 20.4 1747.5 1815.7 3.44 ± 0.09
cairo-native (embedded JIT using LLVM's ORC Engine) 1980.6 ± 41.9 1915.7 2042.8 3.83 ± 0.12

@gabrielbosio gabrielbosio added the libfuncs Library Function implementations label Dec 3, 2025
We were creating the array in mlir and the passing it
to runtime so it could be modified. This commit deletes
the mlir creation of the array and creates in runtime. This
reduces a lot of code and complexity of the libfunc.
@github-actions
Copy link

github-actions bot commented Dec 5, 2025

✅ Code is now correctly formatted.

pub unsafe extern "C" fn cairo_native__dict_into_entries(
dict_ptr: *const FeltDict,
data_prefix_offset: u64,
tuple_stride: u64,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am receiving the size of the tuple from the MLIR code because I was unable to create it on the runtime side. I tried to do it like this:

let tuple_stride = Layout::new::<[u8; 32]>()
    .extend(dict.layout).unwrap().0
    .extend(dict.layout)

To my understanding, this is the way to calculate the Layout of a struct<felt252, T, T>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

libfuncs Library Function implementations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[2.11.1] Implement Squashed Felt252 Dict Entries Libfunc

4 participants