Skip to content

Improve memory_segments coverage #2110

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

Merged
merged 3 commits into from
Jun 2, 2025
Merged

Conversation

DiegoCivi
Copy link
Contributor

@DiegoCivi DiegoCivi commented May 30, 2025

Improve memory_segments coverage

Description

Aims to omprove the test coverage on memory_segments. It ads the following tests:

  • Test for calling .write_arg() with an invalid type.
  • Test for calling .gen_arg() with a vector of Relocatables.
  • Test for calling .is_valid_memory_value() with a felt.

Fixes #2108

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.

Copy link

github-actions bot commented May 30, 2025

**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 ± σ):     25.730 s ±  0.023 s    [User: 24.957 s, System: 0.769 s]
  Range (min … max):   25.713 s … 25.746 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 1
  Time (mean ± σ):     25.695 s ±  0.004 s    [User: 24.900 s, System: 0.792 s]
  Range (min … max):   25.692 s … 25.697 s    2 runs
 
Summary
  hyper_threading_pr threads: 1 ran
    1.00 ± 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 ± σ):     14.451 s ±  0.089 s    [User: 25.178 s, System: 0.822 s]
  Range (min … max):   14.388 s … 14.514 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 2
  Time (mean ± σ):     14.368 s ±  0.058 s    [User: 25.087 s, System: 0.798 s]
  Range (min … max):   14.327 s … 14.408 s    2 runs
 
Summary
  hyper_threading_pr threads: 2 ran
    1.01 ± 0.01 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.296 s ±  0.191 s    [User: 37.012 s, System: 0.978 s]
  Range (min … max):   10.161 s … 10.431 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 4
  Time (mean ± σ):     10.265 s ±  0.397 s    [User: 37.724 s, System: 0.997 s]
  Range (min … max):    9.984 s … 10.545 s    2 runs
 
Summary
  hyper_threading_pr threads: 4 ran
    1.00 ± 0.04 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.225 s ±  0.103 s    [User: 37.796 s, System: 0.964 s]
  Range (min … max):   10.152 s … 10.298 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 6
  Time (mean ± σ):     10.286 s ±  0.221 s    [User: 37.379 s, System: 0.988 s]
  Range (min … max):   10.130 s … 10.442 s    2 runs
 
Summary
  hyper_threading_main threads: 6 ran
    1.01 ± 0.02 times faster than hyper_threading_pr 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.279 s ±  0.188 s    [User: 37.961 s, System: 0.973 s]
  Range (min … max):   10.146 s … 10.413 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 8
  Time (mean ± σ):     10.161 s ±  0.095 s    [User: 38.028 s, System: 1.006 s]
  Range (min … max):   10.094 s … 10.228 s    2 runs
 
Summary
  hyper_threading_pr threads: 8 ran
    1.01 ± 0.02 times faster than hyper_threading_main 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.106 s ±  0.031 s    [User: 38.346 s, System: 1.085 s]
  Range (min … max):   10.084 s … 10.128 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 16
  Time (mean ± σ):     10.188 s ±  0.001 s    [User: 38.538 s, System: 1.095 s]
  Range (min … max):   10.187 s … 10.188 s    2 runs
 
Summary
  hyper_threading_main threads: 16 ran
    1.01 ± 0.00 times faster than hyper_threading_pr threads: 16


Copy link

github-actions bot commented May 30, 2025

Benchmark Results for unmodified programs 🚀

Command Mean [s] Min [s] Max [s] Relative
base big_factorial 2.094 ± 0.030 2.062 2.166 1.00 ± 0.02
head big_factorial 2.092 ± 0.009 2.073 2.106 1.00
Command Mean [s] Min [s] Max [s] Relative
base big_fibonacci 2.022 ± 0.011 2.007 2.045 1.00 ± 0.01
head big_fibonacci 2.014 ± 0.010 1.999 2.031 1.00
Command Mean [s] Min [s] Max [s] Relative
base blake2s_integration_benchmark 7.699 ± 0.040 7.643 7.756 1.01 ± 0.01
head blake2s_integration_benchmark 7.621 ± 0.078 7.530 7.770 1.00
Command Mean [s] Min [s] Max [s] Relative
base compare_arrays_200000 2.143 ± 0.016 2.114 2.162 1.00 ± 0.01
head compare_arrays_200000 2.142 ± 0.018 2.113 2.179 1.00
Command Mean [s] Min [s] Max [s] Relative
base dict_integration_benchmark 1.379 ± 0.012 1.359 1.391 1.00
head dict_integration_benchmark 1.387 ± 0.017 1.371 1.422 1.01 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base field_arithmetic_get_square_benchmark 1.189 ± 0.008 1.175 1.199 1.00
head field_arithmetic_get_square_benchmark 1.196 ± 0.010 1.180 1.214 1.01 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base integration_builtins 7.682 ± 0.046 7.644 7.780 1.01 ± 0.01
head integration_builtins 7.632 ± 0.055 7.567 7.703 1.00
Command Mean [s] Min [s] Max [s] Relative
base keccak_integration_benchmark 7.898 ± 0.083 7.822 8.093 1.00
head keccak_integration_benchmark 8.012 ± 0.102 7.888 8.200 1.01 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base linear_search 2.104 ± 0.016 2.086 2.140 1.00
head linear_search 2.106 ± 0.015 2.070 2.125 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base math_cmp_and_pow_integration_benchmark 1.451 ± 0.013 1.430 1.476 1.00 ± 0.01
head math_cmp_and_pow_integration_benchmark 1.450 ± 0.012 1.425 1.475 1.00
Command Mean [s] Min [s] Max [s] Relative
base math_integration_benchmark 1.405 ± 0.008 1.391 1.416 1.01 ± 0.01
head math_integration_benchmark 1.392 ± 0.013 1.374 1.413 1.00
Command Mean [s] Min [s] Max [s] Relative
base memory_integration_benchmark 1.166 ± 0.011 1.146 1.183 1.01 ± 0.01
head memory_integration_benchmark 1.158 ± 0.010 1.142 1.174 1.00
Command Mean [s] Min [s] Max [s] Relative
base operations_with_data_structures_benchmarks 1.511 ± 0.011 1.495 1.529 1.00 ± 0.01
head operations_with_data_structures_benchmarks 1.508 ± 0.019 1.472 1.547 1.00
Command Mean [ms] Min [ms] Max [ms] Relative
base pedersen 514.1 ± 7.4 501.5 524.6 1.00
head pedersen 514.2 ± 6.2 504.8 520.6 1.00 ± 0.02
Command Mean [ms] Min [ms] Max [ms] Relative
base poseidon_integration_benchmark 600.2 ± 3.9 592.7 604.1 1.00
head poseidon_integration_benchmark 603.3 ± 4.3 596.4 611.1 1.01 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base secp_integration_benchmark 1.796 ± 0.010 1.780 1.811 1.01 ± 0.01
head secp_integration_benchmark 1.780 ± 0.018 1.757 1.803 1.00
Command Mean [ms] Min [ms] Max [ms] Relative
base set_integration_benchmark 612.0 ± 4.9 604.8 620.5 1.00 ± 0.01
head set_integration_benchmark 611.1 ± 5.4 601.1 621.8 1.00
Command Mean [s] Min [s] Max [s] Relative
base uint256_integration_benchmark 4.140 ± 0.018 4.120 4.181 1.00 ± 0.01
head uint256_integration_benchmark 4.132 ± 0.021 4.091 4.174 1.00

Copy link

codecov bot commented May 30, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.67%. Comparing base (2204910) to head (404c8c9).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2110      +/-   ##
==========================================
+ Coverage   96.65%   96.67%   +0.01%     
==========================================
  Files         103      103              
  Lines       43544    43597      +53     
==========================================
+ Hits        42089    42147      +58     
+ Misses       1455     1450       -5     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@DiegoCivi DiegoCivi added the tests Implementation of tests label May 30, 2025
@DiegoCivi DiegoCivi marked this pull request as ready for review May 30, 2025 19:30
Copy link
Contributor

@JulianGCalderon JulianGCalderon left a comment

Choose a reason for hiding this comment

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

LGTM!

@gabrielbosio gabrielbosio added this pull request to the merge queue Jun 2, 2025
Merged via the queue into main with commit 4f02f5a Jun 2, 2025
93 checks passed
@gabrielbosio gabrielbosio deleted the tests/memory-segments-coverage branch June 2, 2025 18:45
gabrielbosio added a commit that referenced this pull request Jun 4, 2025
* Remove duplicated `get_val` (#2065)

* avoid installing gmp if it is already installed

* revert part of the last commit

* changelog

* remove unwanted file

* CI: Make cache keys depend on Cairo version (#2056)

* Add Makefile and requirements.txt to cache key

* Don't fetch cairo stwo exclusive programs

* Remove empty file

* Restrict caching Cairo programs

Revert how the Rust workflow uses the Cairo program paths to
calculate the cache keys.
This change would imply the branch only adds Makefile and
requirements.txt to the cache key computation.

---------

Co-authored-by: gabrielbosio <[email protected]>
Co-authored-by: Gabriel Bosio <[email protected]>

* dev: make Memory::get `pub` (#2039)

* dev: make Memory::get `pub`

* edit changelog

* dev: expose get_maybe_relocatable instead

* add comment on borrowed variant

* add tests

* feat(breaking): add support for hint accessible scopes (#2042)

* feat: add support for hint accessible scopes

update changelog

* Update vm/src/hint_processor/hint_processor_definition.rs

Co-authored-by: Julian Gonzalez Calderon <[email protected]>

---------

Co-authored-by: Julian Gonzalez Calderon <[email protected]>

* feat: add support for alias identifiers destination in program serde (#2071)

* feat: add support for aliases destination in program serde

* add changelog

---------

Co-authored-by: Julián González Calderón <[email protected]>

* fix: Add boundary tests for SecpSplitOutOfRange in secp_utils (#2062)

* fix: Add boundary tests for SecpSplitOutOfRange in secp_utils

* Update secp_utils.rs

* Update CHANGELOG.md

* Update secp_utils.rs

* remove optimizations

* Update CHANGELOG.md

* Update CHANGELOG.md

* Update CHANGELOG.md

* empty commit to fix CI

---------

Co-authored-by: Julian Gonzalez Calderon <[email protected]>

* docs: add --run_from_cairo_pie documentation for Cairo 0 and Cairo 1 (#2077)

* docs: add --run_from_cairo_pie flag usage documentation for Cairo 0

* docs: add --run_from_cairo_pie flag usage documentation for Cairo 1

* Update README.md

Co-authored-by: Julian Gonzalez Calderon <[email protected]>

* Update README.md

* Update README.md

* Update README.md

Co-authored-by: Julian Gonzalez Calderon <[email protected]>

* Update README.md

Co-authored-by: Gabriel Bosio <[email protected]>

* Update README.md

Co-authored-by: Julian Gonzalez Calderon <[email protected]>

---------

Co-authored-by: Julian Gonzalez Calderon <[email protected]>
Co-authored-by: Gabriel Bosio <[email protected]>

* Fix WRITE_DIVMOD_SEGMENT hint (#2078)

* Minor fixes - use CAIRO_PRIME

* Add error handling

* Update CHANGELOG.md

* Bump cairo-lang to 0.13.5 (#1959)

* Update cairo-lang versin

* Update changelog

* Add new hints

* Specify prime in new hints

* Only apply mod floor if prime is not CAIRO_PRIME

* Properly implement pack for a different prime

* Fix pack in compute_doubling_slope

* Add negative_points.cairo test

* Add try_get_point_from_x for negative points

* Add double_x test for negative points

* Allow to many arguments

* Add codecov to cairo-0-secp-hints feature

* Prepare for Release v3.0.0-rc.1 (#2092)

* Update version

* Update lock

* Update toolchain

* Update changelog

* Fix clippy

* Update toolchain in CI

* fix: correct cache keys for no-std test coverage in CI (#2093)

* Update rust.yml

* Update rust.yml

* Update rust toolchain to 1.87.0 (#2100)

* update rust toolchain to 1.87.0

* remove uneeded file

* update rust in workflows

* update changelog

* clippy

* clippy

* remove unneeded clippy allow

* fix Changelog link (#2104)

* Improve memory_segments coverage (#2110)

* Add tests for .gen_arg() and .write_arg()

* Add test for .is_valid_memory_value()

* Assert contents of memory segments

---------

Co-authored-by: Franco Giachetta <[email protected]>
Co-authored-by: Julian Gonzalez Calderon <[email protected]>
Co-authored-by: Mathieu <[email protected]>
Co-authored-by: VolodymyrBg <[email protected]>
Co-authored-by: GarmashAlex <[email protected]>
Co-authored-by: crStiv <[email protected]>
Co-authored-by: DiegoC <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Implementation of tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add memory_segments coverage
3 participants