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: wrap big variants of errors in Box #1193

Merged
merged 24 commits into from
Jun 1, 2023
Merged

feat: wrap big variants of errors in Box #1193

merged 24 commits into from
Jun 1, 2023

Conversation

MegaRedHand
Copy link
Contributor

TITLE

Description

Some HintError variants can be pretty big (e.g. ArcTooBig). This PR Boxes their contents. That way we can still match those variants, but they occupy less space. This also helps #1184, as with the change from heap to stack-living types the felts and relocatables grow even bigger.

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.

@github-actions
Copy link

github-actions bot commented May 31, 2023

Benchmark Results for unmodified programs 🚀

Command Mean [s] Min [s] Max [s] Relative
base blake2s_integration_benchmark 12.449 ± 0.045 12.371 12.532 1.00
head blake2s_integration_benchmark 12.975 ± 0.191 12.825 13.454 1.04 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base compare_arrays_200000 4.176 ± 0.040 4.140 4.261 1.00
head compare_arrays_200000 4.204 ± 0.052 4.165 4.305 1.01 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base dict_integration_benchmark 2.766 ± 0.032 2.746 2.853 1.01 ± 0.01
head dict_integration_benchmark 2.741 ± 0.008 2.731 2.755 1.00
Command Mean [s] Min [s] Max [s] Relative
base factorial_multirun 4.373 ± 0.022 4.355 4.431 1.00
head factorial_multirun 4.453 ± 0.044 4.415 4.529 1.02 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base fibonacci_1000_multirun 3.776 ± 0.028 3.750 3.847 1.00
head fibonacci_1000_multirun 3.798 ± 0.015 3.786 3.833 1.01 ± 0.01
Command Mean [ms] Min [ms] Max [ms] Relative
base field_arithmetic_get_square_benchmark 182.1 ± 1.8 180.3 186.2 1.01 ± 0.01
head field_arithmetic_get_square_benchmark 180.8 ± 0.9 179.1 182.1 1.00
Command Mean [s] Min [s] Max [s] Relative
base integration_builtins 11.368 ± 0.203 11.220 11.900 1.00
head integration_builtins 11.951 ± 0.115 11.802 12.161 1.05 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base keccak_integration_benchmark 12.922 ± 0.462 12.594 14.189 1.00
head keccak_integration_benchmark 13.025 ± 0.067 12.925 13.133 1.01 ± 0.04
Command Mean [s] Min [s] Max [s] Relative
base linear_search 4.144 ± 0.024 4.119 4.199 1.00
head linear_search 4.187 ± 0.056 4.149 4.340 1.01 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base math_cmp_and_pow_integration_benchmark 3.021 ± 0.005 3.015 3.032 1.01 ± 0.00
head math_cmp_and_pow_integration_benchmark 3.001 ± 0.011 2.991 3.023 1.00
Command Mean [s] Min [s] Max [s] Relative
base math_integration_benchmark 2.794 ± 0.011 2.780 2.815 1.01 ± 0.01
head math_integration_benchmark 2.771 ± 0.016 2.752 2.800 1.00
Command Mean [s] Min [s] Max [s] Relative
base memory_integration_benchmark 2.380 ± 0.008 2.371 2.398 1.00 ± 0.00
head memory_integration_benchmark 2.380 ± 0.007 2.370 2.389 1.00
Command Mean [s] Min [s] Max [s] Relative
base operations_with_data_structures_benchmarks 2.761 ± 0.021 2.748 2.819 1.01 ± 0.01
head operations_with_data_structures_benchmarks 2.737 ± 0.008 2.728 2.750 1.00
Command Mean [ms] Min [ms] Max [ms] Relative
base pedersen 901.7 ± 14.6 894.2 942.4 1.00
head pedersen 905.6 ± 4.1 901.3 913.1 1.00 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base poseidon_integration_benchmark 1.592 ± 0.009 1.583 1.612 1.00 ± 0.01
head poseidon_integration_benchmark 1.591 ± 0.010 1.581 1.616 1.00
Command Mean [s] Min [s] Max [s] Relative
base secp_integration_benchmark 3.424 ± 0.018 3.411 3.474 1.00
head secp_integration_benchmark 3.450 ± 0.013 3.436 3.483 1.01 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base set_integration_benchmark 1.897 ± 0.005 1.887 1.904 1.28 ± 0.02
head set_integration_benchmark 1.479 ± 0.027 1.465 1.554 1.00
Command Mean [s] Min [s] Max [s] Relative
base uint256_integration_benchmark 8.149 ± 0.210 8.056 8.744 1.00
head uint256_integration_benchmark 8.240 ± 0.025 8.223 8.289 1.01 ± 0.03

@MegaRedHand MegaRedHand changed the title feat: wrap HintError's variants' contents in Box * feat: wrap big variants of HintError in Box May 31, 2023
@MegaRedHand MegaRedHand marked this pull request as ready for review May 31, 2023 15:02
@MegaRedHand MegaRedHand changed the title * feat: wrap big variants of HintError in Box feat: wrap big variants of HintError in Box May 31, 2023
@codecov
Copy link

codecov bot commented May 31, 2023

Codecov Report

Merging #1193 (8f91da3) into main (d9784bf) will decrease coverage by 0.08%.
The diff coverage is 87.70%.

@@            Coverage Diff             @@
##             main    #1193      +/-   ##
==========================================
- Coverage   97.69%   97.62%   -0.08%     
==========================================
  Files          89       89              
  Lines       35975    36038      +63     
==========================================
+ Hits        35147    35182      +35     
- Misses        828      856      +28     
Impacted Files Coverage Δ
..._processor/builtin_hint_processor/uint512_utils.rs 93.33% <0.00%> (ø)
...sor/cairo_1_hint_processor/hint_processor_utils.rs 56.47% <0.00%> (-2.79%) ⬇️
src/utils.rs 99.49% <ø> (ø)
...uiltin_hint_processor/cairo_keccak/keccak_hints.rs 94.09% <43.75%> (ø)
...t_processor/builtin_hint_processor/dict_manager.rs 95.74% <55.55%> (-1.00%) ⬇️
src/vm/runners/builtin_runner/bitwise.rs 96.11% <57.14%> (+<0.01%) ⬆️
...t_processor/cairo_1_hint_processor/dict_manager.rs 90.00% <57.89%> (-2.41%) ⬇️
...int_processor/builtin_hint_processor/hint_utils.rs 92.89% <62.50%> (-1.98%) ⬇️
.../hint_processor/builtin_hint_processor/ec_utils.rs 98.53% <66.66%> (-0.49%) ⬇️
src/vm/runners/builtin_runner/poseidon.rs 97.48% <75.00%> (+<0.01%) ⬆️
... and 41 more

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

CHANGELOG.md Outdated Show resolved Hide resolved
@MegaRedHand MegaRedHand marked this pull request as draft May 31, 2023 18:06
@MegaRedHand MegaRedHand marked this pull request as ready for review June 1, 2023 03:38
@MegaRedHand MegaRedHand changed the title feat: wrap big variants of HintError in Box feat: wrap big variants of errors in Box Jun 1, 2023
@Oppen
Copy link
Member

Oppen commented Jun 1, 2023

Some benches seem much slower. Make sure the allocations only happen on error paths.

@MegaRedHand MegaRedHand added this pull request to the merge queue Jun 1, 2023
Merged via the queue into main with commit cf5768c Jun 1, 2023
30 of 31 checks passed
@MegaRedHand MegaRedHand deleted the hinterror-boxing branch June 1, 2023 15:59
kariy pushed a commit to dojoengine/cairo-rs that referenced this pull request Jun 23, 2023
* Wrap HintError's variants' contents in Box

* Fix half of the errors

* Fix compile warnings

* Use `crate::stdlib`'s `Box`

* Appease clippy

* Add simple smoke tests of message formatting

* Update changelog

* Mention change is breaking

* Box `MathError` variants

* Box `MemoryError` variants

* Box HintError variants (now also strings)

* Add tentative test to avoid size regressions

* Box `VirtualMachineError`

* Box RunnerError

* Appease clippy

* Use `crate::stdlib`'s `Box`

* Update changelog with recent changes

* fix: replace several ok_ok by ok_or_else for perf regression

* Replace more ok_or for ok_or_else

* Add missing regression test

* Use `Box<str>` instead of `Box<String>`

---------

Co-authored-by: Mario Rugiero <mrugiero@gmail.com>
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