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

introduce opcode_extension to the structure of Instruction. #1933

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ohad-nir-starkware
Copy link
Collaborator

@ohad-nir-starkware ohad-nir-starkware commented Feb 4, 2025

#Introduce opcode_extension to the structure of Instruction

Description

In preparation for adding new opcodes to Stwo, we introduce another field named opcode_extension to the structure Instruction.
That field is an enum that in the future will denote which of the new opcodes is being used in the instruction.

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.

This change is Reviewable

Copy link

github-actions bot commented Feb 4, 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 ± σ):     32.343 s ±  0.837 s    [User: 31.583 s, System: 0.758 s]
  Range (min … max):   31.751 s … 32.935 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 1
  Time (mean ± σ):     32.909 s ±  0.926 s    [User: 32.153 s, System: 0.754 s]
  Range (min … max):   32.255 s … 33.564 s    2 runs
 
Summary
  hyper_threading_main threads: 1 ran
    1.02 ± 0.04 times faster than hyper_threading_pr 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 ± σ):     17.738 s ±  0.062 s    [User: 30.972 s, System: 0.782 s]
  Range (min … max):   17.694 s … 17.782 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 2
  Time (mean ± σ):     17.858 s ±  0.053 s    [User: 31.324 s, System: 0.784 s]
  Range (min … max):   17.820 s … 17.896 s    2 runs
 
Summary
  hyper_threading_main threads: 2 ran
    1.01 ± 0.00 times faster than hyper_threading_pr 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 ± σ):     11.969 s ±  0.232 s    [User: 44.129 s, System: 0.930 s]
  Range (min … max):   11.805 s … 12.132 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 4
  Time (mean ± σ):     12.362 s ±  0.437 s    [User: 43.573 s, System: 0.934 s]
  Range (min … max):   12.053 s … 12.671 s    2 runs
 
Summary
  hyper_threading_main threads: 4 ran
    1.03 ± 0.04 times faster than hyper_threading_pr 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 ± σ):     12.087 s ±  0.279 s    [User: 43.835 s, System: 0.919 s]
  Range (min … max):   11.890 s … 12.285 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 6
  Time (mean ± σ):     11.983 s ±  0.049 s    [User: 44.045 s, System: 0.913 s]
  Range (min … max):   11.949 s … 12.017 s    2 runs
 
Summary
  hyper_threading_pr threads: 6 ran
    1.01 ± 0.02 times faster than hyper_threading_main 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 ± σ):     12.052 s ±  0.012 s    [User: 44.335 s, System: 0.978 s]
  Range (min … max):   12.044 s … 12.061 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 8
  Time (mean ± σ):     11.980 s ±  0.168 s    [User: 44.210 s, System: 0.947 s]
  Range (min … max):   11.861 s … 12.099 s    2 runs
 
Summary
  hyper_threading_pr threads: 8 ran
    1.01 ± 0.01 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 ± σ):     12.233 s ±  0.060 s    [User: 44.741 s, System: 1.056 s]
  Range (min … max):   12.191 s … 12.276 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 16
  Time (mean ± σ):     11.794 s ±  0.049 s    [User: 44.441 s, System: 1.068 s]
  Range (min … max):   11.759 s … 11.829 s    2 runs
 
Summary
  hyper_threading_pr threads: 16 ran
    1.04 ± 0.01 times faster than hyper_threading_main threads: 16


Copy link

github-actions bot commented Feb 4, 2025

Benchmark Results for unmodified programs 🚀

Command Mean [s] Min [s] Max [s] Relative
base big_factorial 2.515 ± 0.041 2.466 2.606 1.00
head big_factorial 2.516 ± 0.024 2.471 2.543 1.00 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base big_fibonacci 2.442 ± 0.029 2.401 2.476 1.00
head big_fibonacci 2.487 ± 0.071 2.402 2.606 1.02 ± 0.03
Command Mean [s] Min [s] Max [s] Relative
base blake2s_integration_benchmark 9.271 ± 0.208 9.037 9.755 1.01 ± 0.03
head blake2s_integration_benchmark 9.201 ± 0.203 8.997 9.701 1.00
Command Mean [s] Min [s] Max [s] Relative
base compare_arrays_200000 2.648 ± 0.088 2.548 2.812 1.03 ± 0.04
head compare_arrays_200000 2.563 ± 0.031 2.531 2.611 1.00
Command Mean [s] Min [s] Max [s] Relative
base dict_integration_benchmark 1.687 ± 0.028 1.665 1.753 1.00 ± 0.03
head dict_integration_benchmark 1.686 ± 0.036 1.657 1.780 1.00
Command Mean [s] Min [s] Max [s] Relative
base field_arithmetic_get_square_benchmark 1.438 ± 0.022 1.406 1.481 1.00 ± 0.02
head field_arithmetic_get_square_benchmark 1.438 ± 0.027 1.406 1.498 1.00
Command Mean [s] Min [s] Max [s] Relative
base integration_builtins 9.241 ± 0.131 9.084 9.452 1.01 ± 0.02
head integration_builtins 9.188 ± 0.166 9.044 9.577 1.00
Command Mean [s] Min [s] Max [s] Relative
base keccak_integration_benchmark 9.551 ± 0.102 9.362 9.672 1.00
head keccak_integration_benchmark 9.582 ± 0.308 9.336 10.433 1.00 ± 0.03
Command Mean [s] Min [s] Max [s] Relative
base linear_search 2.607 ± 0.066 2.543 2.763 1.02 ± 0.03
head linear_search 2.566 ± 0.039 2.525 2.636 1.00
Command Mean [s] Min [s] Max [s] Relative
base math_cmp_and_pow_integration_benchmark 1.738 ± 0.014 1.724 1.761 1.00
head math_cmp_and_pow_integration_benchmark 1.742 ± 0.039 1.710 1.845 1.00 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base math_integration_benchmark 1.698 ± 0.019 1.679 1.734 1.00
head math_integration_benchmark 1.707 ± 0.027 1.677 1.770 1.01 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base memory_integration_benchmark 1.448 ± 0.022 1.417 1.487 1.01 ± 0.02
head memory_integration_benchmark 1.434 ± 0.018 1.410 1.461 1.00
Command Mean [s] Min [s] Max [s] Relative
base operations_with_data_structures_benchmarks 1.810 ± 0.027 1.793 1.881 1.01 ± 0.02
head operations_with_data_structures_benchmarks 1.795 ± 0.018 1.779 1.838 1.00
Command Mean [ms] Min [ms] Max [ms] Relative
base pedersen 589.2 ± 3.0 583.8 593.2 1.01 ± 0.01
head pedersen 582.9 ± 4.8 576.6 592.2 1.00
Command Mean [ms] Min [ms] Max [ms] Relative
base poseidon_integration_benchmark 691.5 ± 8.1 683.7 708.4 1.01 ± 0.02
head poseidon_integration_benchmark 686.5 ± 6.9 678.4 697.0 1.00
Command Mean [s] Min [s] Max [s] Relative
base secp_integration_benchmark 2.090 ± 0.029 2.066 2.166 1.01 ± 0.02
head secp_integration_benchmark 2.064 ± 0.012 2.043 2.089 1.00
Command Mean [ms] Min [ms] Max [ms] Relative
base set_integration_benchmark 721.1 ± 10.0 703.6 737.2 1.00
head set_integration_benchmark 721.8 ± 10.3 704.5 735.0 1.00 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base uint256_integration_benchmark 5.101 ± 0.119 4.986 5.417 1.00 ± 0.03
head uint256_integration_benchmark 5.080 ± 0.098 4.956 5.260 1.00

Copy link

codecov bot commented Feb 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.36%. Comparing base (df12864) to head (e15c6e6).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1933   +/-   ##
=======================================
  Coverage   96.35%   96.36%           
=======================================
  Files         102      102           
  Lines       41095    41157   +62     
=======================================
+ Hits        39599    39661   +62     
  Misses       1496     1496           

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

Copy link

@DavidLevitGurevich DavidLevitGurevich left a comment

Choose a reason for hiding this comment

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

Reviewed 4 of 6 files at r1, all commit messages.
Reviewable status: 4 of 6 files reviewed, 1 unresolved discussion (waiting on @fmoletta, @gabrielbosio, @igaray, @juanbono, @ohad-nir-starkware, @Oppen, @pefontana, and @YairVaknin-starkware)


vm/src/vm/decoding/decoder.rs line 9 at r1 (raw file):

// opcode_extension|  opcode|ap_update|pc_update|res_logic|op1_src|op0_reg|dst_reg
//               15|14 13 12|    11 10|  9  8  7|     6  5|4  3  2|      1|      0

I suggest ... 15 and then it is clear that it's all the evelent.

Copy link

@DavidLevitGurevich DavidLevitGurevich left a comment

Choose a reason for hiding this comment

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

Reviewable status: 4 of 6 files reviewed, 1 unresolved discussion (waiting on @fmoletta, @gabrielbosio, @igaray, @juanbono, @ohad-nir-starkware, @Oppen, @pefontana, and @YairVaknin-starkware)


vm/src/vm/decoding/decoder.rs line 9 at r1 (raw file):

Previously, DavidLevitGurevich wrote…

I suggest ... 15 and then it is clear that it's all the evelent.

  • all the elements to the left

Copy link
Collaborator Author

@ohad-nir-starkware ohad-nir-starkware left a comment

Choose a reason for hiding this comment

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

Reviewable status: 4 of 6 files reviewed, 1 unresolved discussion (waiting on @DavidLevitGurevich, @fmoletta, @gabrielbosio, @igaray, @juanbono, @Oppen, @pefontana, and @YairVaknin-starkware)


vm/src/vm/decoding/decoder.rs line 9 at r1 (raw file):

Previously, DavidLevitGurevich wrote…
  • all the elements to the left

Done.

Copy link

@DavidLevitGurevich DavidLevitGurevich left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 6 files at r1, 1 of 1 files at r2, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @fmoletta, @gabrielbosio, @igaray, @juanbono, @Oppen, @pefontana, and @YairVaknin-starkware)

Copy link

@DavidLevitGurevich DavidLevitGurevich left a comment

Choose a reason for hiding this comment

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

:lgtm:

but wait for @YairVaknin-starkware

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @fmoletta, @gabrielbosio, @igaray, @juanbono, @Oppen, @pefontana, and @YairVaknin-starkware)

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.

2 participants