cairo_native
cairo_native copied to clipboard
[2.11.1] Implement blake libfunc
This PR implements both blake related libfuncs
Closes #1148, #1149
/// The blake2s compress function, which takes a state, a byte count, and a message, and returns a
/// new state.
/// `byte_count` should be the total number of bytes hashed after hashing the current `msg`.
pub extern fn blake2s_compress(
state: Blake2sState, byte_count: u32, msg: Blake2sInput,
) -> Blake2sState nopanic;
/// Similar to `blake2s_compress`, but used for the final block of the message.
pub extern fn blake2s_finalize(
state: Blake2sState, byte_count: u32, msg: Blake2sInput,
) -> Blake2sState nopanic;
Checklist
- [X] Linked to Github Issue
- [X] Unit tests added
- [ ] Integration tests added.
- [ ] This change requires new documentation.
- [ ] Documentation has been added/updated.
Benchmark results Main vs HEAD.
Base
| Command | Mean [s] | Min [s] | Max [s] | Relative |
|---|---|---|---|---|
base dict_insert.cairo (JIT) |
2.544 ± 0.036 | 2.485 | 2.587 | 1.04 ± 0.02 |
base dict_insert.cairo (AOT) |
2.447 ± 0.037 | 2.397 | 2.540 | 1.00 |
Head
| Command | Mean [s] | Min [s] | Max [s] | Relative |
|---|---|---|---|---|
head dict_insert.cairo (JIT) |
2.604 ± 0.029 | 2.563 | 2.665 | 1.03 ± 0.01 |
head dict_insert.cairo (AOT) |
2.528 ± 0.019 | 2.501 | 2.569 | 1.00 |
Base
| Command | Mean [s] | Min [s] | Max [s] | Relative |
|---|---|---|---|---|
base dict_snapshot.cairo (JIT) |
2.212 ± 0.015 | 2.186 | 2.230 | 1.00 ± 0.02 |
base dict_snapshot.cairo (AOT) |
2.209 ± 0.045 | 2.156 | 2.288 | 1.00 |
Head
| Command | Mean [s] | Min [s] | Max [s] | Relative |
|---|---|---|---|---|
head dict_snapshot.cairo (JIT) |
2.314 ± 0.014 | 2.291 | 2.340 | 1.04 ± 0.01 |
head dict_snapshot.cairo (AOT) |
2.225 ± 0.021 | 2.189 | 2.253 | 1.00 |
Base
| Command | Mean [s] | Min [s] | Max [s] | Relative |
|---|---|---|---|---|
base factorial_2M.cairo (JIT) |
2.638 ± 0.042 | 2.576 | 2.738 | 1.02 ± 0.02 |
base factorial_2M.cairo (AOT) |
2.590 ± 0.033 | 2.519 | 2.637 | 1.00 |
Head
| Command | Mean [s] | Min [s] | Max [s] | Relative |
|---|---|---|---|---|
head factorial_2M.cairo (JIT) |
2.623 ± 0.016 | 2.592 | 2.649 | 1.01 ± 0.01 |
head factorial_2M.cairo (AOT) |
2.585 ± 0.021 | 2.562 | 2.627 | 1.00 |
Base
| Command | Mean [s] | Min [s] | Max [s] | Relative |
|---|---|---|---|---|
base fib_2M.cairo (JIT) |
2.137 ± 0.026 | 2.090 | 2.169 | 1.00 ± 0.03 |
base fib_2M.cairo (AOT) |
2.137 ± 0.053 | 2.079 | 2.225 | 1.00 |
Head
| Command | Mean [s] | Min [s] | Max [s] | Relative |
|---|---|---|---|---|
head fib_2M.cairo (JIT) |
2.249 ± 0.034 | 2.204 | 2.320 | 1.03 ± 0.02 |
head fib_2M.cairo (AOT) |
2.182 ± 0.012 | 2.166 | 2.201 | 1.00 |
Base
| Command | Mean [s] | Min [s] | Max [s] | Relative |
|---|---|---|---|---|
base heavy_circuit.cairo (JIT) |
13.960 ± 0.080 | 13.853 | 14.056 | 1.00 ± 0.02 |
base heavy_circuit.cairo (AOT) |
13.928 ± 0.279 | 13.561 | 14.226 | 1.00 |
Head
| Command | Mean [s] | Min [s] | Max [s] | Relative |
|---|---|---|---|---|
head heavy_circuit.cairo (JIT) |
11.077 ± 0.062 | 11.001 | 11.209 | 1.03 ± 0.01 |
head heavy_circuit.cairo (AOT) |
10.739 ± 0.061 | 10.682 | 10.845 | 1.00 |
Base
| Command | Mean [s] | Min [s] | Max [s] | Relative |
|---|---|---|---|---|
base linear_search.cairo (JIT) |
2.461 ± 0.035 | 2.421 | 2.521 | 1.06 ± 0.03 |
base linear_search.cairo (AOT) |
2.321 ± 0.055 | 2.269 | 2.461 | 1.00 |
Head
| Command | Mean [s] | Min [s] | Max [s] | Relative |
|---|---|---|---|---|
head linear_search.cairo (JIT) |
2.417 ± 0.018 | 2.396 | 2.447 | 1.06 ± 0.01 |
head linear_search.cairo (AOT) |
2.284 ± 0.025 | 2.243 | 2.323 | 1.00 |
Base
| Command | Mean [s] | Min [s] | Max [s] | Relative |
|---|---|---|---|---|
base logistic_map.cairo (JIT) |
2.571 ± 0.032 | 2.514 | 2.606 | 1.06 ± 0.02 |
base logistic_map.cairo (AOT) |
2.415 ± 0.027 | 2.366 | 2.452 | 1.00 |
Head
| Command | Mean [s] | Min [s] | Max [s] | Relative |
|---|---|---|---|---|
head logistic_map.cairo (JIT) |
2.550 ± 0.015 | 2.521 | 2.572 | 1.07 ± 0.01 |
head logistic_map.cairo (AOT) |
2.374 ± 0.022 | 2.358 | 2.421 | 1.00 |
Benchmarking results
Benchmark for program dict_insert
Open benchmarks
| Command | Mean [s] | Min [s] | Max [s] | Relative |
|---|---|---|---|---|
Cairo-vm (Rust, Cairo 1) |
11.005 ± 0.073 | 10.888 | 11.101 | 4.34 ± 0.08 |
cairo-native (embedded AOT) |
2.535 ± 0.040 | 2.480 | 2.620 | 1.00 |
cairo-native (embedded JIT using LLVM's ORC Engine) |
2.613 ± 0.024 | 2.576 | 2.657 | 1.03 ± 0.02 |
Benchmark for program dict_snapshot
Open benchmarks
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
Cairo-vm (Rust, Cairo 1) |
525.5 ± 4.2 | 519.4 | 531.1 | 1.00 |
cairo-native (embedded AOT) |
2180.3 ± 21.8 | 2139.6 | 2200.8 | 4.15 ± 0.05 |
cairo-native (embedded JIT using LLVM's ORC Engine) |
2271.6 ± 15.5 | 2242.4 | 2300.8 | 4.32 ± 0.05 |
Benchmark for program factorial_2M
Open benchmarks
| Command | Mean [s] | Min [s] | Max [s] | Relative |
|---|---|---|---|---|
Cairo-vm (Rust, Cairo 1) |
4.816 ± 0.041 | 4.770 | 4.891 | 1.85 ± 0.03 |
cairo-native (embedded AOT) |
2.609 ± 0.032 | 2.572 | 2.657 | 1.00 |
cairo-native (embedded JIT using LLVM's ORC Engine) |
2.625 ± 0.015 | 2.604 | 2.656 | 1.01 ± 0.01 |
Benchmark for program fib_2M
Open benchmarks
| Command | Mean [s] | Min [s] | Max [s] | Relative |
|---|---|---|---|---|
Cairo-vm (Rust, Cairo 1) |
4.765 ± 0.038 | 4.731 | 4.843 | 2.29 ± 0.05 |
cairo-native (embedded AOT) |
2.085 ± 0.039 | 2.047 | 2.163 | 1.00 |
cairo-native (embedded JIT using LLVM's ORC Engine) |
2.141 ± 0.013 | 2.128 | 2.169 | 1.03 ± 0.02 |
Benchmark for program heavy_circuit
Open benchmarks
| Command | Mean [s] | Min [s] | Max [s] | Relative |
|---|---|---|---|---|
Cairo-vm (Rust, Cairo 1) |
9.743 ± 0.169 | 9.529 | 9.988 | 1.00 |
cairo-native (embedded AOT) |
15.014 ± 0.098 | 14.903 | 15.246 | 1.54 ± 0.03 |
cairo-native (embedded JIT using LLVM's ORC Engine) |
15.226 ± 0.093 | 15.123 | 15.431 | 1.56 ± 0.03 |
Benchmark for program linear_search
Open benchmarks
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
Cairo-vm (Rust, Cairo 1) |
578.8 ± 8.0 | 567.1 | 595.0 | 1.00 |
cairo-native (embedded AOT) |
2292.7 ± 39.6 | 2229.9 | 2370.2 | 3.96 ± 0.09 |
cairo-native (embedded JIT using LLVM's ORC Engine) |
2383.9 ± 30.8 | 2331.2 | 2432.2 | 4.12 ± 0.08 |
Benchmark for program logistic_map
Open benchmarks
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
|---|---|---|---|---|
Cairo-vm (Rust, Cairo 1) |
378.0 ± 3.9 | 374.5 | 387.9 | 1.00 |
cairo-native (embedded AOT) |
2331.5 ± 44.8 | 2269.2 | 2400.1 | 6.17 ± 0.13 |
cairo-native (embedded JIT using LLVM's ORC Engine) |
2492.2 ± 21.4 | 2461.5 | 2522.4 | 6.59 ± 0.09 |
Codecov Report
:x: Patch coverage is 96.69811% with 7 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 81.60%. Comparing base (1574511) to head (7ceb9ac).
| Files with missing lines | Patch % | Lines |
|---|---|---|
| src/libfuncs/blake.rs | 94.91% | 3 Missing :warning: |
| src/types.rs | 0.00% | 3 Missing :warning: |
| src/metadata/runtime_bindings.rs | 96.55% | 1 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## main #1160 +/- ##
==========================================
+ Coverage 81.46% 81.60% +0.13%
==========================================
Files 105 107 +2
Lines 25875 26082 +207
==========================================
+ Hits 21079 21284 +205
- Misses 4796 4798 +2
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
✅ Code is now correctly formatted.