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] Append return values to the output segment when running in proof_mode #1597

Merged
merged 18 commits into from
Feb 6, 2024

Conversation

fmoletta
Copy link
Contributor

@fmoletta fmoletta commented Feb 1, 2024

This involves:

  • Forcing the output builtin to be included when running cairo 1 programs in proof_mode (And manually setting it's stop_ptr and segment_size)
  • Adding extra instructions in the proof_mode_header (after calling the first program instruction and before initiating the infinite loop) to copy the return values into the output builtin segment

Testing:

  • This new behaviour was tested manually by printing out the memory when running the available test programs to ensure that it behaves correctly with one or more return values and all flags enabled.

  • There is currently no way to create a test for this behaviour without some code refactors that escape the scope of the PR.

Also in this PR:

  • Restored a test that was accidentally removed when solving merge conflicts in a previous PR

Copy link

github-actions bot commented Feb 1, 2024

Benchmark Results for unmodified programs 🚀

Command Mean [s] Min [s] Max [s] Relative
base big_factorial 2.285 ± 0.007 2.271 2.295 1.00 ± 0.00
head big_factorial 2.280 ± 0.009 2.269 2.295 1.00
Command Mean [s] Min [s] Max [s] Relative
base big_fibonacci 2.266 ± 0.009 2.256 2.287 1.00
head big_fibonacci 2.275 ± 0.010 2.264 2.294 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base blake2s_integration_benchmark 8.286 ± 0.044 8.208 8.356 1.00 ± 0.01
head blake2s_integration_benchmark 8.273 ± 0.044 8.235 8.370 1.00
Command Mean [s] Min [s] Max [s] Relative
base compare_arrays_200000 2.336 ± 0.025 2.310 2.384 1.01 ± 0.01
head compare_arrays_200000 2.318 ± 0.014 2.297 2.343 1.00
Command Mean [s] Min [s] Max [s] Relative
base dict_integration_benchmark 1.458 ± 0.004 1.451 1.464 1.00
head dict_integration_benchmark 1.460 ± 0.010 1.452 1.486 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base field_arithmetic_get_square_benchmark 1.300 ± 0.017 1.287 1.338 1.00 ± 0.01
head field_arithmetic_get_square_benchmark 1.294 ± 0.007 1.282 1.304 1.00
Command Mean [s] Min [s] Max [s] Relative
base integration_builtins 8.311 ± 0.038 8.267 8.392 1.00
head integration_builtins 8.344 ± 0.058 8.280 8.447 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base keccak_integration_benchmark 8.596 ± 0.131 8.504 8.952 1.01 ± 0.02
head keccak_integration_benchmark 8.546 ± 0.059 8.490 8.675 1.00
Command Mean [s] Min [s] Max [s] Relative
base linear_search 2.348 ± 0.014 2.335 2.384 1.00
head linear_search 2.356 ± 0.023 2.328 2.416 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base math_cmp_and_pow_integration_benchmark 1.594 ± 0.013 1.585 1.630 1.01 ± 0.01
head math_cmp_and_pow_integration_benchmark 1.582 ± 0.005 1.575 1.591 1.00
Command Mean [s] Min [s] Max [s] Relative
base math_integration_benchmark 1.454 ± 0.012 1.446 1.489 1.00 ± 0.01
head math_integration_benchmark 1.452 ± 0.014 1.439 1.490 1.00
Command Mean [s] Min [s] Max [s] Relative
base memory_integration_benchmark 1.273 ± 0.005 1.268 1.284 1.01 ± 0.01
head memory_integration_benchmark 1.266 ± 0.004 1.262 1.271 1.00
Command Mean [s] Min [s] Max [s] Relative
base operations_with_data_structures_benchmarks 1.609 ± 0.010 1.597 1.629 1.00
head operations_with_data_structures_benchmarks 1.636 ± 0.019 1.609 1.662 1.02 ± 0.01
Command Mean [ms] Min [ms] Max [ms] Relative
base pedersen 611.1 ± 10.4 605.6 640.4 1.01 ± 0.02
head pedersen 606.7 ± 2.5 603.0 611.5 1.00
Command Mean [s] Min [s] Max [s] Relative
base poseidon_integration_benchmark 1.058 ± 0.005 1.054 1.070 1.00
head poseidon_integration_benchmark 1.064 ± 0.005 1.058 1.073 1.01 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base secp_integration_benchmark 1.935 ± 0.011 1.925 1.964 1.00
head secp_integration_benchmark 1.941 ± 0.018 1.927 1.989 1.00 ± 0.01
Command Mean [ms] Min [ms] Max [ms] Relative
base set_integration_benchmark 755.6 ± 5.0 752.0 768.9 1.00 ± 0.01
head set_integration_benchmark 754.4 ± 4.3 750.6 765.8 1.00
Command Mean [s] Min [s] Max [s] Relative
base uint256_integration_benchmark 4.567 ± 0.032 4.528 4.629 1.00
head uint256_integration_benchmark 4.576 ± 0.036 4.536 4.632 1.00 ± 0.01

Copy link

codecov bot commented Feb 1, 2024

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (dea2723) 97.13% compared to head (982894d) 97.16%.

Files Patch % Lines
cairo1-run/src/main.rs 98.27% 1 Missing ⚠️
vm/src/vm/vm_core.rs 87.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1597      +/-   ##
==========================================
+ Coverage   97.13%   97.16%   +0.02%     
==========================================
  Files          91       91              
  Lines       37263    37324      +61     
==========================================
+ Hits        36196    36264      +68     
+ Misses       1067     1060       -7     

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

@fmoletta fmoletta changed the title Append return values to the output segment when running in proof_mode [cairo1-run] Append return values to the output segment when running in proof_mode Feb 1, 2024
@fmoletta fmoletta linked an issue Feb 1, 2024 that may be closed by this pull request
@fmoletta fmoletta changed the title [cairo1-run] Append return values to the output segment when running in proof_mode [Cairo1] Append return values to the output segment when running in proof_mode Feb 1, 2024
@fmoletta fmoletta marked this pull request as ready for review February 1, 2024 21:49
@juanbono
Copy link
Collaborator

juanbono commented Feb 5, 2024

We should work on adding the required changes to test this

@fmoletta fmoletta added this pull request to the merge queue Feb 6, 2024
Merged via the queue into main with commit aeb6d19 Feb 6, 2024
50 of 51 checks passed
@fmoletta fmoletta deleted the append-return-values-to-output branch February 6, 2024 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Cairo1] Append returned values to the Output builtin segment
3 participants