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

perf!: avoid extra copies of immediate args #942

Merged
merged 1 commit into from
May 3, 2023

Conversation

Oppen
Copy link
Contributor

@Oppen Oppen commented Apr 3, 2023

The Instruction structure no longer keeps a copy of whatever value follows the tentative instruction. If it's an immediate, other fields are enough to deduce that. If the argument is missing, memory access will make that evident.
There's no need for that copy.

Because a public field of a public structure is gone, it's a breaking change.

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.

@codecov
Copy link

codecov bot commented Apr 3, 2023

Codecov Report

Merging #942 (242ba16) into main (21b6427) will increase coverage by 0.01%.
The diff coverage is 97.41%.

❗ Current head 242ba16 differs from pull request most recent head 2413d53. Consider uploading reports for the commit 2413d53 to get more accurate results

@@            Coverage Diff             @@
##             main     #942      +/-   ##
==========================================
+ Coverage   98.14%   98.15%   +0.01%     
==========================================
  Files          85       85              
  Lines       34576    34536      -40     
==========================================
- Hits        33934    33899      -35     
+ Misses        642      637       -5     
Impacted Files Coverage Δ
src/vm/context/run_context.rs 99.71% <ø> (-0.01%) ⬇️
src/vm/vm_core.rs 97.87% <90.90%> (+0.01%) ⬆️
src/types/instruction.rs 95.91% <95.83%> (ø)
src/utils.rs 99.44% <100.00%> (+<0.01%) ⬆️
src/vm/decoding/decoder.rs 100.00% <100.00%> (+0.41%) ⬆️
src/vm/runners/cairo_runner.rs 98.13% <100.00%> (+0.02%) ⬆️
src/vm/trace/mod.rs 97.10% <100.00%> (+2.29%) ⬆️

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

@Oppen Oppen force-pushed the simplify_decode_current_instruction branch 2 times, most recently from 322e974 to ebd792e Compare April 4, 2023 18:52
@Oppen Oppen force-pushed the simplify_decode_current_instruction branch from ebd792e to 6935dae Compare April 26, 2023 23:53
@github-actions
Copy link

github-actions bot commented Apr 27, 2023

Benchmark Results for unmodified programs 🚀

Command Mean [s] Min [s] Max [s] Relative
base blake2s_integration_benchmark 21.983 ± 0.168 21.759 22.363 1.06 ± 0.01
head blake2s_integration_benchmark 20.690 ± 0.194 20.378 21.016 1.00
Command Mean [s] Min [s] Max [s] Relative
base compare_arrays_200000 6.750 ± 0.130 6.593 7.020 1.09 ± 0.02
head compare_arrays_200000 6.186 ± 0.071 6.057 6.309 1.00
Command Mean [s] Min [s] Max [s] Relative
base dict_integration_benchmark 4.205 ± 0.054 4.116 4.262 1.08 ± 0.02
head dict_integration_benchmark 3.901 ± 0.051 3.838 3.999 1.00
Command Mean [s] Min [s] Max [s] Relative
base factorial_multirun 7.286 ± 0.077 7.170 7.393 1.10 ± 0.02
head factorial_multirun 6.624 ± 0.064 6.542 6.768 1.00
Command Mean [s] Min [s] Max [s] Relative
base fibonacci_1000_multirun 6.369 ± 0.145 6.237 6.768 1.10 ± 0.03
head fibonacci_1000_multirun 5.794 ± 0.047 5.704 5.860 1.00
Command Mean [ms] Min [ms] Max [ms] Relative
base field_arithmetic_get_square_benchmark 248.4 ± 5.1 242.4 258.0 1.05 ± 0.03
head field_arithmetic_get_square_benchmark 237.1 ± 4.7 229.2 244.4 1.00
Command Mean [s] Min [s] Max [s] Relative
base integration_builtins 20.624 ± 0.250 20.259 20.965 1.07 ± 0.02
head integration_builtins 19.329 ± 0.277 19.009 19.831 1.00
Command Mean [s] Min [s] Max [s] Relative
base keccak_integration_benchmark 22.518 ± 0.409 22.179 23.454 1.07 ± 0.02
head keccak_integration_benchmark 21.140 ± 0.250 20.880 21.693 1.00
Command Mean [s] Min [s] Max [s] Relative
base linear_search 6.740 ± 0.073 6.673 6.915 1.08 ± 0.02
head linear_search 6.252 ± 0.060 6.165 6.359 1.00
Command Mean [s] Min [s] Max [s] Relative
base math_cmp_and_pow_integration_benchmark 4.459 ± 0.048 4.383 4.562 1.08 ± 0.02
head math_cmp_and_pow_integration_benchmark 4.141 ± 0.038 4.050 4.193 1.00
Command Mean [s] Min [s] Max [s] Relative
base math_integration_benchmark 4.209 ± 0.048 4.145 4.328 1.08 ± 0.01
head math_integration_benchmark 3.909 ± 0.021 3.872 3.938 1.00
Command Mean [s] Min [s] Max [s] Relative
base memory_integration_benchmark 3.790 ± 0.050 3.703 3.868 1.10 ± 0.02
head memory_integration_benchmark 3.449 ± 0.034 3.392 3.484 1.00
Command Mean [s] Min [s] Max [s] Relative
base operations_with_data_structures_benchmarks 4.092 ± 0.034 4.042 4.148 1.07 ± 0.01
head operations_with_data_structures_benchmarks 3.819 ± 0.032 3.766 3.870 1.00
Command Mean [s] Min [s] Max [s] Relative
base pedersen 1.312 ± 0.012 1.295 1.328 1.03 ± 0.02
head pedersen 1.267 ± 0.018 1.247 1.297 1.00
Command Mean [s] Min [s] Max [s] Relative
base poseidon_integration_benchmark 2.164 ± 0.022 2.136 2.201 1.04 ± 0.02
head poseidon_integration_benchmark 2.085 ± 0.036 2.026 2.165 1.00
Command Mean [s] Min [s] Max [s] Relative
base secp_integration_benchmark 5.073 ± 0.032 5.034 5.144 1.04 ± 0.01
head secp_integration_benchmark 4.862 ± 0.053 4.772 4.953 1.00
Command Mean [s] Min [s] Max [s] Relative
base set_integration_benchmark 2.855 ± 0.028 2.806 2.895 1.03 ± 0.02
head set_integration_benchmark 2.759 ± 0.031 2.720 2.799 1.00
Command Mean [s] Min [s] Max [s] Relative
base uint256_integration_benchmark 12.731 ± 0.182 12.503 13.014 1.06 ± 0.02
head uint256_integration_benchmark 11.969 ± 0.222 11.735 12.413 1.00

@Oppen Oppen force-pushed the simplify_decode_current_instruction branch from 00f8d1c to 2f2dfef Compare April 27, 2023 01:23
@Oppen Oppen marked this pull request as ready for review April 27, 2023 01:24
@Oppen Oppen changed the title Remove immediate argument copies, computed from op1_addr already perf: avoid extra copies of immediate args Apr 27, 2023
@Oppen Oppen force-pushed the simplify_decode_current_instruction branch from 2f2dfef to f00fbe8 Compare April 27, 2023 01:26
@Oppen Oppen changed the title perf: avoid extra copies of immediate args perf!: avoid extra copies of immediate args Apr 27, 2023
@Oppen Oppen force-pushed the simplify_decode_current_instruction branch 3 times, most recently from 242ba16 to 8d0c41f Compare April 30, 2023 22:42
Copy link
Contributor

@fmoletta fmoletta left a comment

Choose a reason for hiding this comment

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

LGTM!

@Oppen Oppen force-pushed the simplify_decode_current_instruction branch from 8d0c41f to 2413d53 Compare May 3, 2023 03:25
@pefontana
Copy link
Collaborator

nice one!

@pefontana pefontana added this pull request to the merge queue May 3, 2023
Merged via the queue into main with commit c17aa23 May 3, 2023
@pefontana pefontana deleted the simplify_decode_current_instruction branch May 3, 2023 18:18
kariy pushed a commit to dojoengine/cairo-rs that referenced this pull request Jun 23, 2023
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.

3 participants