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

fix : Fix CairoRunner::get_memory_holes #1027

Merged
merged 20 commits into from
Apr 21, 2023
Merged

Conversation

fmoletta
Copy link
Member

@fmoletta fmoletta commented Apr 20, 2023

This PR aims to fix the get_memory_holes method which was uncorreclty counting memory holes for builtin segments.
In the python VM, all addresses in the builtin's segment are marked as accessed before counting memory holes. In this PR, builtin segments are skipped when counting memory holes instead.

Changes:

  • Skip builtin segements when counting memory holes

  • Check amount of memory holes for all tests in cairo_run_test

  • Remove duplicated tests in cairo_run_test

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.

@fmoletta fmoletta marked this pull request as ready for review April 20, 2023 20:14
CHANGELOG.md Outdated Show resolved Hide resolved
@github-actions
Copy link

github-actions bot commented Apr 20, 2023

Benchmark Results for unmodified programs 🚀

Command Mean [s] Min [s] Max [s] Relative
base blake2s_integration_benchmark 2.771 ± 0.017 2.753 2.812 1.00
head blake2s_integration_benchmark 2.772 ± 0.032 2.747 2.858 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base compare_arrays_200000 3.388 ± 0.041 3.344 3.474 1.00 ± 0.01
head compare_arrays_200000 3.377 ± 0.022 3.343 3.421 1.00
Command Mean [s] Min [s] Max [s] Relative
base dict_integration_benchmark 2.544 ± 0.022 2.527 2.603 1.00
head dict_integration_benchmark 2.557 ± 0.017 2.534 2.590 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base factorial_multirun 4.113 ± 0.056 4.066 4.247 1.01 ± 0.02
head factorial_multirun 4.077 ± 0.039 4.053 4.184 1.00
Command Mean [s] Min [s] Max [s] Relative
base fibonacci_1000_multirun 3.282 ± 0.020 3.263 3.314 1.00 ± 0.01
head fibonacci_1000_multirun 3.272 ± 0.016 3.258 3.308 1.00
Command Mean [ms] Min [ms] Max [ms] Relative
base field_arithmetic_get_square_benchmark 129.1 ± 0.7 128.1 130.6 1.00
head field_arithmetic_get_square_benchmark 129.1 ± 0.6 128.2 130.1 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base integration_builtins 3.346 ± 0.029 3.311 3.416 1.00 ± 0.01
head integration_builtins 3.333 ± 0.015 3.309 3.352 1.00
Command Mean [s] Min [s] Max [s] Relative
base keccak_integration_benchmark 3.018 ± 0.007 3.005 3.030 1.00
head keccak_integration_benchmark 3.019 ± 0.014 3.004 3.053 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base linear_search 3.496 ± 0.017 3.467 3.523 1.01 ± 0.01
head linear_search 3.471 ± 0.016 3.456 3.512 1.00
Command Mean [s] Min [s] Max [s] Relative
base math_cmp_and_pow_integration_benchmark 2.920 ± 0.015 2.906 2.959 1.00 ± 0.01
head math_cmp_and_pow_integration_benchmark 2.915 ± 0.013 2.905 2.951 1.00
Command Mean [s] Min [s] Max [s] Relative
base math_integration_benchmark 2.636 ± 0.016 2.612 2.663 1.00 ± 0.01
head math_integration_benchmark 2.625 ± 0.008 2.614 2.635 1.00
Command Mean [s] Min [s] Max [s] Relative
base memory_integration_benchmark 2.339 ± 0.007 2.324 2.348 1.00 ± 0.01
head memory_integration_benchmark 2.331 ± 0.020 2.308 2.371 1.00
Command Mean [s] Min [s] Max [s] Relative
base operations_with_data_structures_benchmarks 2.345 ± 0.024 2.324 2.397 1.00
head operations_with_data_structures_benchmarks 2.347 ± 0.020 2.325 2.398 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base pedersen 3.354 ± 0.026 3.330 3.410 1.00 ± 0.01
head pedersen 3.346 ± 0.015 3.328 3.378 1.00
Command Mean [s] Min [s] Max [s] Relative
base poseidon_integration_benchmark 1.465 ± 0.004 1.459 1.472 1.00
head poseidon_integration_benchmark 1.475 ± 0.005 1.466 1.483 1.01 ± 0.00
Command Mean [s] Min [s] Max [s] Relative
base secp_integration_benchmark 2.631 ± 0.014 2.618 2.665 1.00
head secp_integration_benchmark 2.635 ± 0.015 2.621 2.674 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base set_integration_benchmark 1.943 ± 0.008 1.937 1.959 1.00
head set_integration_benchmark 1.946 ± 0.008 1.935 1.961 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base uint256_integration_benchmark 4.121 ± 0.012 4.101 4.139 1.00 ± 0.00
head uint256_integration_benchmark 4.112 ± 0.010 4.101 4.137 1.00

@codecov
Copy link

codecov bot commented Apr 20, 2023

Codecov Report

Merging #1027 (342efdb) into main (cdc28b0) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main    #1027   +/-   ##
=======================================
  Coverage   98.07%   98.07%           
=======================================
  Files          78       78           
  Lines       32498    32541   +43     
=======================================
+ Hits        31873    31916   +43     
  Misses        625      625           
Impacted Files Coverage Δ
src/vm/runners/cairo_runner.rs 98.10% <100.00%> (+0.02%) ⬆️
src/vm/vm_memory/memory_segments.rs 98.99% <100.00%> (+<0.01%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@MegaRedHand MegaRedHand added this pull request to the merge queue Apr 21, 2023
Merged via the queue into main with commit 593d9a7 Apr 21, 2023
15 checks passed
@MegaRedHand MegaRedHand deleted the fix-get-memory-holes branch April 21, 2023 17:55
kariy pushed a commit to dojoengine/cairo-rs that referenced this pull request Jun 23, 2023
* Add test

* Ignore builtin segments in get_memory_holes

* Improve test

* Add memory holes check for cairo_run_test tests

* Fix broken condition

* Make memory_holes check optional & customizable

* Fix bounds

* Add a test with deliberately created memory holes

* Fix test value

* Remove duplicated tests + add memory hole value to some tests

* Add memory holes value + remove duplicated tests + fix typo

* Fix test values

* Add changelog entry

* Link PR in Changelog

* Mark breaking change in changelog

* fmt

* Fix test value

* Fix codecov-patch diff
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