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

[Cairo1] Fix GasBuiltin handling #1789

Merged
merged 9 commits into from
Jun 12, 2024
Merged

[Cairo1] Fix GasBuiltin handling #1789

merged 9 commits into from
Jun 12, 2024

Conversation

fmoletta
Copy link
Member

@fmoletta fmoletta commented Jun 12, 2024

Fixes bug reported by #1788
Changes:

  • Load initial_gas in load_arguments
  • Remove writing of initial_gas into program in create_entry_code
  • Account for the memory cell occupated by initial_gas when loading arguments & serializaing input
  • Fix segmant arena data size used to calculate initial ap_offset in load_arguments

Testing:

  • Add a test containg the reported failing program

Copy link

github-actions bot commented Jun 12, 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.869 s ±  0.037 s    [User: 26.063 s, System: 0.804 s]
  Range (min … max):   26.843 s … 26.895 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 1
  Time (mean ± σ):     26.567 s ±  0.039 s    [User: 25.789 s, System: 0.776 s]
  Range (min … max):   26.540 s … 26.594 s    2 runs
 
Summary
  'hyper_threading_pr threads: 1' ran
    1.01 ± 0.00 times faster than 'hyper_threading_main 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 ± σ):     15.145 s ±  0.004 s    [User: 26.714 s, System: 0.768 s]
  Range (min … max):   15.142 s … 15.147 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 2
  Time (mean ± σ):     14.964 s ±  0.010 s    [User: 26.264 s, System: 0.855 s]
  Range (min … max):   14.957 s … 14.972 s    2 runs
 
Summary
  'hyper_threading_pr threads: 2' ran
    1.01 ± 0.00 times faster than 'hyper_threading_main 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.960 s ±  0.041 s    [User: 37.944 s, System: 0.957 s]
  Range (min … max):   10.931 s … 10.989 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 4
  Time (mean ± σ):     10.884 s ±  0.003 s    [User: 37.838 s, System: 0.924 s]
  Range (min … max):   10.882 s … 10.887 s    2 runs
 
Summary
  'hyper_threading_pr threads: 4' ran
    1.01 ± 0.00 times faster than 'hyper_threading_main 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.735 s ±  0.220 s    [User: 37.888 s, System: 1.036 s]
  Range (min … max):   10.579 s … 10.890 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 6
  Time (mean ± σ):     10.404 s ±  0.072 s    [User: 38.210 s, System: 0.992 s]
  Range (min … max):   10.353 s … 10.455 s    2 runs
 
Summary
  'hyper_threading_pr threads: 6' ran
    1.03 ± 0.02 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.307 s ±  0.033 s    [User: 38.431 s, System: 1.012 s]
  Range (min … max):   10.284 s … 10.330 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 8
  Time (mean ± σ):     10.410 s ±  0.075 s    [User: 38.178 s, System: 0.928 s]
  Range (min … max):   10.356 s … 10.463 s    2 runs
 
Summary
  'hyper_threading_main threads: 8' ran
    1.01 ± 0.01 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.242 s ±  0.097 s    [User: 38.894 s, System: 0.939 s]
  Range (min … max):   10.174 s … 10.311 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 16
  Time (mean ± σ):     10.534 s ±  0.110 s    [User: 38.548 s, System: 1.109 s]
  Range (min … max):   10.457 s … 10.612 s    2 runs
 
Summary
  'hyper_threading_main threads: 16' ran
    1.03 ± 0.01 times faster than 'hyper_threading_pr threads: 16'


Copy link

codecov bot commented Jun 12, 2024

Codecov Report

Attention: Patch coverage is 96.96970% with 1 line in your changes missing coverage. Please review.

Project coverage is 94.79%. Comparing base (3f9428e) to head (c748f1d).

Files Patch % Lines
cairo1-run/src/cairo_run.rs 96.96% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1789   +/-   ##
=======================================
  Coverage   94.78%   94.79%           
=======================================
  Files         102      102           
  Lines       40122    40141   +19     
=======================================
+ Hits        38031    38050   +19     
  Misses       2091     2091           

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

@fmoletta fmoletta marked this pull request as ready for review June 12, 2024 15:48
Copy link

Benchmark Results for unmodified programs 🚀

Command Mean [s] Min [s] Max [s] Relative
base big_factorial 2.067 ± 0.015 2.046 2.095 1.01 ± 0.01
head big_factorial 2.056 ± 0.025 2.033 2.113 1.00
Command Mean [s] Min [s] Max [s] Relative
base big_fibonacci 2.008 ± 0.010 1.997 2.023 1.00
head big_fibonacci 2.013 ± 0.023 1.989 2.067 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base blake2s_integration_benchmark 7.619 ± 0.061 7.497 7.697 1.00
head blake2s_integration_benchmark 7.656 ± 0.104 7.561 7.926 1.00 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base compare_arrays_200000 2.157 ± 0.044 2.125 2.275 1.01 ± 0.02
head compare_arrays_200000 2.130 ± 0.013 2.109 2.153 1.00
Command Mean [s] Min [s] Max [s] Relative
base dict_integration_benchmark 1.411 ± 0.011 1.399 1.434 1.00
head dict_integration_benchmark 1.412 ± 0.006 1.403 1.422 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base field_arithmetic_get_square_benchmark 1.215 ± 0.018 1.199 1.253 1.00 ± 0.02
head field_arithmetic_get_square_benchmark 1.215 ± 0.006 1.205 1.224 1.00
Command Mean [s] Min [s] Max [s] Relative
base integration_builtins 7.690 ± 0.046 7.608 7.765 1.00
head integration_builtins 7.793 ± 0.459 7.574 9.083 1.01 ± 0.06
Command Mean [s] Min [s] Max [s] Relative
base keccak_integration_benchmark 7.978 ± 0.179 7.819 8.457 1.01 ± 0.03
head keccak_integration_benchmark 7.890 ± 0.094 7.777 8.095 1.00
Command Mean [s] Min [s] Max [s] Relative
base linear_search 2.114 ± 0.047 2.076 2.228 1.01 ± 0.02
head linear_search 2.099 ± 0.015 2.077 2.120 1.00
Command Mean [s] Min [s] Max [s] Relative
base math_cmp_and_pow_integration_benchmark 1.470 ± 0.018 1.455 1.510 1.00
head math_cmp_and_pow_integration_benchmark 1.474 ± 0.029 1.454 1.548 1.00 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base math_integration_benchmark 1.449 ± 0.019 1.435 1.500 1.00
head math_integration_benchmark 1.454 ± 0.012 1.440 1.483 1.00 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base memory_integration_benchmark 1.192 ± 0.008 1.178 1.203 1.00
head memory_integration_benchmark 1.202 ± 0.007 1.192 1.211 1.01 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base operations_with_data_structures_benchmarks 1.542 ± 0.026 1.523 1.594 1.01 ± 0.02
head operations_with_data_structures_benchmarks 1.533 ± 0.007 1.523 1.540 1.00
Command Mean [ms] Min [ms] Max [ms] Relative
base pedersen 513.1 ± 1.2 511.1 515.1 1.00
head pedersen 514.6 ± 5.3 510.6 527.2 1.00 ± 0.01
Command Mean [ms] Min [ms] Max [ms] Relative
base poseidon_integration_benchmark 745.0 ± 3.4 739.9 751.1 1.00 ± 0.01
head poseidon_integration_benchmark 744.3 ± 6.9 735.9 756.3 1.00
Command Mean [s] Min [s] Max [s] Relative
base secp_integration_benchmark 1.814 ± 0.026 1.791 1.862 1.00 ± 0.02
head secp_integration_benchmark 1.813 ± 0.010 1.802 1.836 1.00
Command Mean [ms] Min [ms] Max [ms] Relative
base set_integration_benchmark 663.5 ± 2.0 661.4 666.9 1.00
head set_integration_benchmark 669.6 ± 15.6 662.2 713.6 1.01 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base uint256_integration_benchmark 4.230 ± 0.046 4.196 4.349 1.00
head uint256_integration_benchmark 4.279 ± 0.167 4.186 4.748 1.01 ± 0.04

@fmoletta fmoletta added this pull request to the merge queue Jun 12, 2024
Merged via the queue into main with commit 5d11811 Jun 12, 2024
73 checks passed
@fmoletta fmoletta deleted the fix-sa-and-gas-handling branch June 12, 2024 18:44
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.

None yet

3 participants