Skip to content
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

feat: add TestLessThanOrEqualAddress core hint #43

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

HermanObst
Copy link
Collaborator

@HermanObst HermanObst commented Sep 3, 2024

Context: port of the Starknet OS to Rust.

We need an implementation of TestLessThanOrEqualAddress hint used by the Starknet OS while being executed in some blocks.

Checklist

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

whichqua and others added 2 commits August 29, 2024 12:03
Problem: we need an implementation of the hints used by the Starknet OS
in the secp syscalls. These hints rely on private primitives in
`cairo-vm` and need to be implemented here.

Solution: this PR adds an implementation of all the hints that require
`cairo-vm` primitives in the `cairo-vm` repository.
Copy link

github-actions bot commented Sep 3, 2024

**Hyper Thereading Benchmark results**




hyperfine -r 2 -n "hyper_threading_main threads: 1" 'RAYON_NUM_THREADS=1 ./hyper_threading_main' -n "hyper_threading_pr threads: 1" 'RAYON_NUM_THREADS=1 ./hyper_threading_pr'
Benchmark 1: hyper_threading_main threads: 1
  Time (mean ± σ):     26.236 s ±  0.045 s    [User: 25.450 s, System: 0.784 s]
  Range (min … max):   26.204 s … 26.268 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 1
  Time (mean ± σ):     26.596 s ±  0.010 s    [User: 25.739 s, System: 0.855 s]
  Range (min … max):   26.589 s … 26.603 s    2 runs
 
Summary
  'hyper_threading_main threads: 1' ran
    1.01 ± 0.00 times faster than 'hyper_threading_pr threads: 1'




hyperfine -r 2 -n "hyper_threading_main threads: 2" 'RAYON_NUM_THREADS=2 ./hyper_threading_main' -n "hyper_threading_pr threads: 2" 'RAYON_NUM_THREADS=2 ./hyper_threading_pr'
Benchmark 1: hyper_threading_main threads: 2
  Time (mean ± σ):     14.344 s ±  0.001 s    [User: 25.440 s, System: 0.835 s]
  Range (min … max):   14.343 s … 14.345 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 2
  Time (mean ± σ):     14.884 s ±  0.025 s    [User: 26.284 s, System: 0.811 s]
  Range (min … max):   14.867 s … 14.902 s    2 runs
 
Summary
  'hyper_threading_main threads: 2' ran
    1.04 ± 0.00 times faster than 'hyper_threading_pr threads: 2'




hyperfine -r 2 -n "hyper_threading_main threads: 4" 'RAYON_NUM_THREADS=4 ./hyper_threading_main' -n "hyper_threading_pr threads: 4" 'RAYON_NUM_THREADS=4 ./hyper_threading_pr'
Benchmark 1: hyper_threading_main threads: 4
  Time (mean ± σ):     10.336 s ±  0.150 s    [User: 37.732 s, System: 1.003 s]
  Range (min … max):   10.230 s … 10.442 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 4
  Time (mean ± σ):     10.519 s ±  0.006 s    [User: 38.278 s, System: 0.975 s]
  Range (min … max):   10.515 s … 10.524 s    2 runs
 
Summary
  'hyper_threading_main threads: 4' ran
    1.02 ± 0.01 times faster than 'hyper_threading_pr threads: 4'




hyperfine -r 2 -n "hyper_threading_main threads: 6" 'RAYON_NUM_THREADS=6 ./hyper_threading_main' -n "hyper_threading_pr threads: 6" 'RAYON_NUM_THREADS=6 ./hyper_threading_pr'
Benchmark 1: hyper_threading_main threads: 6
  Time (mean ± σ):     10.422 s ±  0.171 s    [User: 38.117 s, System: 1.015 s]
  Range (min … max):   10.301 s … 10.544 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 6
  Time (mean ± σ):     10.320 s ±  0.205 s    [User: 38.836 s, System: 1.038 s]
  Range (min … max):   10.175 s … 10.465 s    2 runs
 
Summary
  'hyper_threading_pr threads: 6' ran
    1.01 ± 0.03 times faster than 'hyper_threading_main threads: 6'




hyperfine -r 2 -n "hyper_threading_main threads: 8" 'RAYON_NUM_THREADS=8 ./hyper_threading_main' -n "hyper_threading_pr threads: 8" 'RAYON_NUM_THREADS=8 ./hyper_threading_pr'
Benchmark 1: hyper_threading_main threads: 8
  Time (mean ± σ):     10.494 s ±  0.002 s    [User: 38.568 s, System: 0.927 s]
  Range (min … max):   10.492 s … 10.495 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 8
  Time (mean ± σ):     10.591 s ±  0.030 s    [User: 38.938 s, System: 1.027 s]
  Range (min … max):   10.570 s … 10.613 s    2 runs
 
Summary
  'hyper_threading_main threads: 8' ran
    1.01 ± 0.00 times faster than 'hyper_threading_pr threads: 8'




hyperfine -r 2 -n "hyper_threading_main threads: 16" 'RAYON_NUM_THREADS=16 ./hyper_threading_main' -n "hyper_threading_pr threads: 16" 'RAYON_NUM_THREADS=16 ./hyper_threading_pr'
Benchmark 1: hyper_threading_main threads: 16
  Time (mean ± σ):     10.248 s ±  0.068 s    [User: 38.862 s, System: 1.058 s]
  Range (min … max):   10.200 s … 10.296 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 16
  Time (mean ± σ):     10.419 s ±  0.113 s    [User: 39.293 s, System: 1.038 s]
  Range (min … max):   10.339 s … 10.498 s    2 runs
 
Summary
  'hyper_threading_main threads: 16' ran
    1.02 ± 0.01 times faster than 'hyper_threading_pr threads: 16'


Copy link

github-actions bot commented Sep 3, 2024

Benchmark Results for unmodified programs 🚀

Command Mean [s] Min [s] Max [s] Relative
base big_factorial 2.080 ± 0.025 2.050 2.128 1.00
head big_factorial 2.130 ± 0.017 2.103 2.160 1.02 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base big_fibonacci 2.071 ± 0.059 2.039 2.235 1.00 ± 0.04
head big_fibonacci 2.070 ± 0.068 2.024 2.235 1.00
Command Mean [s] Min [s] Max [s] Relative
base blake2s_integration_benchmark 7.567 ± 0.092 7.439 7.720 1.00
head blake2s_integration_benchmark 7.664 ± 0.135 7.537 8.010 1.01 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base compare_arrays_200000 2.177 ± 0.039 2.138 2.251 1.00
head compare_arrays_200000 2.192 ± 0.038 2.140 2.270 1.01 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base dict_integration_benchmark 1.447 ± 0.022 1.421 1.497 1.01 ± 0.02
head dict_integration_benchmark 1.439 ± 0.015 1.415 1.471 1.00
Command Mean [s] Min [s] Max [s] Relative
base field_arithmetic_get_square_benchmark 1.220 ± 0.011 1.205 1.239 1.00
head field_arithmetic_get_square_benchmark 1.230 ± 0.024 1.205 1.291 1.01 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base integration_builtins 7.679 ± 0.083 7.538 7.789 1.00
head integration_builtins 7.768 ± 0.140 7.585 8.106 1.01 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base keccak_integration_benchmark 7.883 ± 0.200 7.731 8.385 1.00
head keccak_integration_benchmark 8.012 ± 0.206 7.795 8.500 1.02 ± 0.04
Command Mean [s] Min [s] Max [s] Relative
base linear_search 2.157 ± 0.045 2.116 2.253 1.00 ± 0.02
head linear_search 2.148 ± 0.021 2.111 2.172 1.00
Command Mean [s] Min [s] Max [s] Relative
base math_cmp_and_pow_integration_benchmark 1.501 ± 0.011 1.490 1.516 1.00 ± 0.01
head math_cmp_and_pow_integration_benchmark 1.500 ± 0.010 1.483 1.515 1.00
Command Mean [s] Min [s] Max [s] Relative
base math_integration_benchmark 1.455 ± 0.019 1.440 1.500 1.00 ± 0.02
head math_integration_benchmark 1.451 ± 0.011 1.437 1.473 1.00
Command Mean [s] Min [s] Max [s] Relative
base memory_integration_benchmark 1.233 ± 0.032 1.203 1.307 1.01 ± 0.04
head memory_integration_benchmark 1.226 ± 0.039 1.195 1.322 1.00
Command Mean [s] Min [s] Max [s] Relative
base operations_with_data_structures_benchmarks 1.558 ± 0.020 1.539 1.610 1.00
head operations_with_data_structures_benchmarks 1.565 ± 0.014 1.552 1.597 1.00 ± 0.02
Command Mean [ms] Min [ms] Max [ms] Relative
base pedersen 527.0 ± 5.1 521.2 535.6 1.00
head pedersen 528.7 ± 4.6 521.8 537.8 1.00 ± 0.01
Command Mean [ms] Min [ms] Max [ms] Relative
base poseidon_integration_benchmark 752.7 ± 9.2 739.7 768.8 1.01 ± 0.01
head poseidon_integration_benchmark 744.8 ± 3.8 739.5 751.5 1.00
Command Mean [s] Min [s] Max [s] Relative
base secp_integration_benchmark 1.881 ± 0.018 1.858 1.918 1.05 ± 0.02
head secp_integration_benchmark 1.784 ± 0.022 1.760 1.835 1.00
Command Mean [ms] Min [ms] Max [ms] Relative
base set_integration_benchmark 644.6 ± 2.3 641.7 647.7 1.00
head set_integration_benchmark 647.7 ± 8.7 639.6 669.5 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base uint256_integration_benchmark 4.378 ± 0.296 4.172 4.944 1.03 ± 0.07
head uint256_integration_benchmark 4.236 ± 0.038 4.177 4.293 1.00

@HermanObst HermanObst changed the title feat: add TestLessThanOrEqualAddress core hint [WIP] feat: add TestLessThanOrEqualAddress core hint Sep 3, 2024
@@ -0,0 +1,9 @@
set -e

DIR="/Users/hermanobst/starkware/snos/tests/integration/contracts/blockifier_contracts/feature_contracts/cairo1"
Copy link

Choose a reason for hiding this comment

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

Probably not needed?

@HermanObst HermanObst force-pushed the ho/add-test-less-than-or-equal-core-hint branch from 32f6de0 to 78b4689 Compare September 4, 2024 18:28
@notlesh notlesh mentioned this pull request Sep 9, 2024
6 tasks
kkovaacs and others added 3 commits September 11, 2024 16:27
We've discovered that using the `cairo-vm` crate in our projects brings
in a lot of unnecessary dependencies and in the end leads to our binary
being linked with the `libbz2` library.

Turns out that neither of these is actually required and this happens
because the `zip` crate has a large number of features enabled by
default.

This change disables all `zip` features except `deflate` which the code
actually uses.
@ftheirs ftheirs force-pushed the ho/add-test-less-than-or-equal-core-hint branch from 78b4689 to a581ba5 Compare September 11, 2024 20:33
@HermanObst HermanObst changed the title [WIP] feat: add TestLessThanOrEqualAddress core hint feat: add TestLessThanOrEqualAddress core hint Sep 15, 2024
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.

5 participants