Skip to content

use bincode for faster writing prover input info #2074

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 1 commit into from
Apr 29, 2025

Conversation

Stavbe
Copy link
Collaborator

@Stavbe Stavbe commented Apr 24, 2025

Added another flag to allow fast serialization of 'prover_input_info' into binary file


This change is Reviewable

@Stavbe Stavbe marked this pull request as ready for review April 24, 2025 14:08
@Stavbe Stavbe force-pushed the stav/add_faster_serialize_deserialize branch from 26e1cd4 to 76555e7 Compare April 24, 2025 14:10
Copy link

github-actions bot commented Apr 24, 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 ± σ):     26.595 s ±  0.121 s    [User: 25.665 s, System: 0.925 s]
  Range (min … max):   26.509 s … 26.680 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 1
  Time (mean ± σ):     26.851 s ±  0.045 s    [User: 25.947 s, System: 0.901 s]
  Range (min … max):   26.819 s … 26.883 s    2 runs
 
Summary
  hyper_threading_main threads: 1 ran
    1.01 ± 0.00 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 ± σ):     14.749 s ±  0.002 s    [User: 25.803 s, System: 0.912 s]
  Range (min … max):   14.748 s … 14.751 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 2
  Time (mean ± σ):     14.991 s ±  0.007 s    [User: 25.950 s, System: 0.937 s]
  Range (min … max):   14.986 s … 14.996 s    2 runs
 
Summary
  hyper_threading_main threads: 2 ran
    1.02 ± 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 ± σ):     10.792 s ±  0.170 s    [User: 37.434 s, System: 1.041 s]
  Range (min … max):   10.673 s … 10.912 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 4
  Time (mean ± σ):     11.387 s ±  0.179 s    [User: 38.990 s, System: 1.114 s]
  Range (min … max):   11.260 s … 11.514 s    2 runs
 
Summary
  hyper_threading_main threads: 4 ran
    1.06 ± 0.02 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 ± σ):     10.578 s ±  0.439 s    [User: 37.811 s, System: 1.070 s]
  Range (min … max):   10.268 s … 10.889 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 6
  Time (mean ± σ):     11.026 s ±  0.066 s    [User: 39.490 s, System: 1.212 s]
  Range (min … max):   10.979 s … 11.072 s    2 runs
 
Summary
  hyper_threading_main threads: 6 ran
    1.04 ± 0.04 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.272 s ±  0.123 s    [User: 38.188 s, System: 1.144 s]
  Range (min … max):   10.185 s … 10.358 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 8
  Time (mean ± σ):     10.865 s ±  0.030 s    [User: 39.765 s, System: 1.139 s]
  Range (min … max):   10.843 s … 10.886 s    2 runs
 
Summary
  hyper_threading_main threads: 8 ran
    1.06 ± 0.01 times faster than hyper_threading_pr 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.365 s ±  0.108 s    [User: 38.435 s, System: 1.189 s]
  Range (min … max):   10.288 s … 10.441 s    2 runs
 
Benchmark 2: hyper_threading_pr threads: 16
  Time (mean ± σ):     10.655 s ±  0.073 s    [User: 39.999 s, System: 1.247 s]
  Range (min … max):   10.603 s … 10.706 s    2 runs
 
Summary
  hyper_threading_main threads: 16 ran
    1.03 ± 0.01 times faster than hyper_threading_pr threads: 16


Copy link

github-actions bot commented Apr 24, 2025

Benchmark Results for unmodified programs 🚀

Command Mean [s] Min [s] Max [s] Relative
base big_factorial 2.149 ± 0.013 2.134 2.181 1.00
head big_factorial 2.163 ± 0.027 2.147 2.227 1.01 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base big_fibonacci 2.078 ± 0.009 2.062 2.094 1.00
head big_fibonacci 2.090 ± 0.018 2.077 2.138 1.01 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base blake2s_integration_benchmark 7.837 ± 0.055 7.762 7.967 1.00
head blake2s_integration_benchmark 7.929 ± 0.074 7.837 8.098 1.01 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base compare_arrays_200000 2.219 ± 0.024 2.204 2.287 1.00
head compare_arrays_200000 2.237 ± 0.026 2.212 2.284 1.01 ± 0.02
Command Mean [s] Min [s] Max [s] Relative
base dict_integration_benchmark 1.439 ± 0.007 1.430 1.452 1.01 ± 0.01
head dict_integration_benchmark 1.431 ± 0.018 1.420 1.478 1.00
Command Mean [s] Min [s] Max [s] Relative
base field_arithmetic_get_square_benchmark 1.232 ± 0.009 1.219 1.249 1.00
head field_arithmetic_get_square_benchmark 1.238 ± 0.013 1.229 1.269 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base integration_builtins 7.989 ± 0.151 7.836 8.344 1.00
head integration_builtins 8.133 ± 0.354 7.884 9.080 1.02 ± 0.05
Command Mean [s] Min [s] Max [s] Relative
base keccak_integration_benchmark 8.160 ± 0.074 8.079 8.341 1.00
head keccak_integration_benchmark 8.282 ± 0.052 8.227 8.358 1.01 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base linear_search 2.210 ± 0.026 2.188 2.279 1.00 ± 0.01
head linear_search 2.206 ± 0.015 2.189 2.242 1.00
Command Mean [s] Min [s] Max [s] Relative
base math_cmp_and_pow_integration_benchmark 1.523 ± 0.007 1.514 1.535 1.00
head math_cmp_and_pow_integration_benchmark 1.528 ± 0.002 1.524 1.531 1.00 ± 0.00
Command Mean [s] Min [s] Max [s] Relative
base math_integration_benchmark 1.471 ± 0.009 1.463 1.488 1.00 ± 0.01
head math_integration_benchmark 1.464 ± 0.003 1.460 1.468 1.00
Command Mean [s] Min [s] Max [s] Relative
base memory_integration_benchmark 1.228 ± 0.006 1.220 1.238 1.00
head memory_integration_benchmark 1.228 ± 0.002 1.225 1.230 1.00 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base operations_with_data_structures_benchmarks 1.581 ± 0.009 1.572 1.605 1.00
head operations_with_data_structures_benchmarks 1.589 ± 0.007 1.583 1.607 1.01 ± 0.01
Command Mean [ms] Min [ms] Max [ms] Relative
base pedersen 535.8 ± 1.3 533.9 537.4 1.00 ± 0.00
head pedersen 535.4 ± 0.8 534.0 536.6 1.00
Command Mean [ms] Min [ms] Max [ms] Relative
base poseidon_integration_benchmark 649.2 ± 5.0 643.7 658.3 1.00
head poseidon_integration_benchmark 652.7 ± 3.0 648.1 657.0 1.01 ± 0.01
Command Mean [s] Min [s] Max [s] Relative
base secp_integration_benchmark 1.863 ± 0.006 1.855 1.875 1.00
head secp_integration_benchmark 1.877 ± 0.013 1.867 1.909 1.01 ± 0.01
Command Mean [ms] Min [ms] Max [ms] Relative
base set_integration_benchmark 633.8 ± 2.3 630.1 637.3 1.00 ± 0.01
head set_integration_benchmark 631.7 ± 4.0 627.4 641.9 1.00
Command Mean [s] Min [s] Max [s] Relative
base uint256_integration_benchmark 4.290 ± 0.018 4.264 4.320 1.00
head uint256_integration_benchmark 4.323 ± 0.035 4.289 4.413 1.01 ± 0.01

Copy link

codecov bot commented Apr 24, 2025

Codecov Report

Attention: Patch coverage is 83.33333% with 3 lines in your changes missing coverage. Please review.

Project coverage is 96.52%. Comparing base (9c44e1c) to head (58174f3).
Report is 2 commits behind head on starkware-development.

Files with missing lines Patch % Lines
cairo-vm-cli/src/main.rs 78.57% 3 Missing ⚠️
Additional details and impacted files
@@                    Coverage Diff                    @@
##           starkware-development    #2074      +/-   ##
=========================================================
- Coverage                  96.63%   96.52%   -0.12%     
=========================================================
  Files                        102      102              
  Lines                      44374    43198    -1176     
=========================================================
- Hits                       42881    41697    -1184     
- Misses                      1493     1501       +8     

☔ 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.

@Stavbe Stavbe self-assigned this Apr 24, 2025
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.

Hey @Stavbe, I left you some small comments.

@gabrielbosio
Copy link
Collaborator

Hi @Stavbe, I have some questions:

  • Why postcard is faster than serde? Is there any benchmark that support this?
  • By reading the README it seems that the idea is support no_std serialization. But serde also support this so why postcard is necessary?

I'm asking this because the idea is to keep the number of dependencies at a minimum.

@Stavbe Stavbe force-pushed the stav/add_faster_serialize_deserialize branch 2 times, most recently from 28da242 to ad1214c Compare April 27, 2025 13:06
Copy link
Collaborator Author

@Stavbe Stavbe left a comment

Choose a reason for hiding this comment

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

The idea was to create binary file for this sturct. Changed to use bincode::serde instead of postcard.

Reviewable status: 0 of 2 files reviewed, 2 unresolved discussions (waiting on @DavidLevitGurevich and @JulianGCalderon)

@Stavbe Stavbe changed the title use postcard for faster binary serialization use bincode for faster writing prover input info Apr 27, 2025
@Stavbe Stavbe force-pushed the stav/add_faster_serialize_deserialize branch 2 times, most recently from de8e050 to 2726e58 Compare April 27, 2025 14:41
Copy link
Collaborator

@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 3 of 3 files at r1, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @JulianGCalderon)


vm/src/vm/runners/cairo_runner.rs line 1581 at r1 (raw file):

    #[error("Failed to (de)serialize data")]
    SerdeBincode(#[from] bincode::error::EncodeError),
    #[error("Failed to (de)serialize data using postcard")]

postcard?

@Stavbe Stavbe force-pushed the stav/add_faster_serialize_deserialize branch from 2726e58 to 58174f3 Compare April 28, 2025 14:54
Copy link
Collaborator

@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:

Reviewed 1 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @JulianGCalderon)

@Stavbe Stavbe merged commit 33d75ca into starkware-development Apr 29, 2025
91 of 93 checks passed
@Stavbe Stavbe deleted the stav/add_faster_serialize_deserialize branch April 29, 2025 10:26
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.

4 participants