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

Optimize polynomial batching computation #325

Merged
merged 1 commit into from
Jun 27, 2024

Conversation

moodlezoup
Copy link
Contributor

@moodlezoup moodlezoup commented Jun 26, 2024

Optimizes PolyEvalWitness::batch and PolyEvalWitness::batch_diff_size
Adapted from a similar optimization made in Jolt: a16z/jolt#379

SHA256 Benchmark, compared against main:

❯ cargo bench --bench sha256 -- --baseline main
   Compiling nova-snark v0.36.0 (/Users/mzhu/code/Nova)
    Finished `bench` profile [optimized] target(s) in 5.14s
     Running benches/sha256.rs (target/release/deps/sha256-2bc87e6fb709805f)
Gnuplot not found, using plotters backend
NovaProve-Sha256-message-len-64/Prove
                        time:   [38.233 ms 38.350 ms 38.470 ms]
                        change: [+0.2237% +0.8242% +1.5157%] (p = 0.03 < 0.05)
                        Change within noise threshold.

NovaProve-Sha256-message-len-128/Prove
                        time:   [47.714 ms 47.882 ms 48.248 ms]
                        change: [+0.3301% +0.9473% +1.5827%] (p = 0.01 < 0.05)
                        Change within noise threshold.

NovaProve-Sha256-message-len-256/Prove
                        time:   [57.914 ms 58.168 ms 58.357 ms]
                        change: [-1.0506% -0.3042% +0.4057%] (p = 0.45 > 0.05)
                        No change in performance detected.

NovaProve-Sha256-message-len-512/Prove
                        time:   [77.322 ms 77.728 ms 78.063 ms]
                        change: [-1.4300% -0.4703% +0.4200%] (p = 0.36 > 0.05)
                        No change in performance detected.

Benchmarking NovaProve-Sha256-message-len-1024/Prove: Warming up for 3.0000 s
Warning: Unable to complete 10 samples in 5.0s. You may wish to increase target time to 6.5s or enable flat sampling.
NovaProve-Sha256-message-len-1024/Prove
                        time:   [117.23 ms 117.56 ms 118.06 ms]
                        change: [-1.5108% -0.7987% -0.0734%] (p = 0.06 > 0.05)
                        No change in performance detected.
Found 3 outliers among 10 measurements (30.00%)
  1 (10.00%) low mild
  1 (10.00%) high mild
  1 (10.00%) high severe

NovaProve-Sha256-message-len-2048/Prove
                        time:   [196.09 ms 198.28 ms 200.92 ms]
                        change: [-2.7311% -0.9839% +0.8079%] (p = 0.32 > 0.05)
                        No change in performance detected.
Found 2 outliers among 10 measurements (20.00%)
  1 (10.00%) high mild
  1 (10.00%) high severe

NovaProve-Sha256-message-len-4096/Prove
                        time:   [360.62 ms 366.00 ms 372.74 ms]
                        change: [-2.5796% -0.9163% +1.3261%] (p = 0.38 > 0.05)
                        No change in performance detected.
Found 2 outliers among 10 measurements (20.00%)
  1 (10.00%) high mild
  1 (10.00%) high severe

Benchmarking NovaProve-Sha256-message-len-8192/Prove: Warming up for 3.0000 s
Warning: Unable to complete 10 samples in 5.0s. You may wish to increase target time to 6.9s.
NovaProve-Sha256-message-len-8192/Prove
                        time:   [682.35 ms 727.58 ms 790.57 ms]
                        change: [-5.1123% +2.0321% +13.448%] (p = 0.71 > 0.05)
                        No change in performance detected.
Found 1 outliers among 10 measurements (10.00%)
  1 (10.00%) high severe

Benchmarking NovaProve-Sha256-message-len-16384/Prove: Warming up for 3.0000 s
Warning: Unable to complete 10 samples in 5.0s. You may wish to increase target time to 13.2s.
NovaProve-Sha256-message-len-16384/Prove
                        time:   [1.3080 s 1.3599 s 1.4234 s]
                        change: [-15.529% -11.092% -5.9208%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 1 outliers among 10 measurements (10.00%)
  1 (10.00%) high mild

Benchmarking NovaProve-Sha256-message-len-32768/Prove: Warming up for 3.0000 s
Warning: Unable to complete 10 samples in 5.0s. You may wish to increase target time to 27.7s.
NovaProve-Sha256-message-len-32768/Prove
                        time:   [2.7410 s 2.8505 s 2.9849 s]
                        change: [-11.713% -6.4613% -1.0214%] (p = 0.05 > 0.05)
                        No change in performance detected.
Found 2 outliers among 10 measurements (20.00%)
  1 (10.00%) high mild
  1 (10.00%) high severe

Benchmarking NovaProve-Sha256-message-len-65536/Prove: Warming up for 3.0000 s
Warning: Unable to complete 10 samples in 5.0s. You may wish to increase target time to 60.4s.
NovaProve-Sha256-message-len-65536/Prove
                        time:   [5.4715 s 5.7959 s 6.1407 s]
                        change: [-19.865% -13.258% -5.9665%] (p = 0.01 < 0.05)
                        Performance has improved.

@moodlezoup
Copy link
Contributor Author

moodlezoup commented Jun 27, 2024

@moodlezoup please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement

@microsoft-github-policy-service agree company="Andreessen Horowitz"

@moodlezoup moodlezoup marked this pull request as ready for review June 27, 2024 21:04
@srinathsetty srinathsetty merged commit aa5eb7f into microsoft:main Jun 27, 2024
6 checks passed
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