8000 perf: avoid needless clones in permutation trace commit by jonathanpwang · Pull Request #69 · openvm-org/stark-backend · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

perf: avoid needless clones in permutation trace commit #69

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 relate 8000 d emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 22, 2025

Conversation

jonathanpwang
Copy link
Contributor
@jonathanpwang jonathanpwang commented Apr 13, 2025

PR targeting #68

I noticed that permutation trace commitment is doing TWO needless clones: first RowMajorMatrix::flatten_to_base creates a whole new vector by collecting individual flatten to base when the extension field matrix can just be transmuted. Secondly, the permutation trace is never used after it is committed, so we should not use TraceCommitter (which clones) but instead use pcs.commit directly.

I have add a transmute_to_base function to replace flatten_to_base. There doesn't seem a good way to have the compiler check the required safety assumptions, so I just document it. (The BinomialExtensionField implementation of ExtensionField satisfies the assumptions.)

The quotient polynomial matrices also saves clones by using transmute_to_base.

Note that since the backend is the one who constructs both perm and quotient matrices, we should be able to reserve extra capacity to avoid a vector re-alloc using the same idea as in #68. I didn't do this yet because there's a lot of traits that make it kind of messy.

before: https://github.com/axiom-crypto/openvm-reth-benchmark/blob/gh-pages/benchmarks-dispatch/refs/heads/main/reth-1c30506ef50e081fa0dceae8244b6dc6311f9584-0d99ea9777b49a7f2c889dc36dd5470ef77a099408c22e824b413132e03e9b83.md
after: https://github.com/axiom-crypto/openvm-reth-benchmark/blob/gh-pages/benchmarks-dispatch/refs/heads/main/reth-8fba5a1c8d9a53527b463292f1569f6087404deb-b9ae348d0275e83a4b3237713f3850bb3c858b14294348e4fe7dbe0d07096e71.md

@jonathanpwang jonathanpwang requested a review from gaxiom April 13, 2025 04:28
Base automatically changed from perf/avoid-realloc to main April 22, 2025 21:46
@jonathanpwang jonathanpwang force-pushed the perf/perm-trace-needless-clones branch from 16204ec to 00b88ed Compare April 22, 2025 21:47
@jonathanpwang jonathanpwang merged commit 62352af into main Apr 22, 2025
3 checks passed
@jonathanpwang jonathanpwang deleted the perf/perm-trace-needless-clones branch April 22, 2025 22:14
leonardoalt pushed a commit to powdr-labs/stark-backend that referenced this pull request Jun 3, 2025
* perf: cpu `TraceCommitter` should reserve capacity for LDE (openvm-org#68)

* perf: avoid needless clones in permutation trace commit (openvm-org#69)

* perf: `transmute_to_base` to avoid needless clones

* chore: add note about p3 PR

* chore: add debug asserts for safety

* feat!: drop main trace earlier for lower peak memory (openvm-org#71)

* feat: drop main trace earlier for lower peak memory

* fix: trace_metrics

* chore: log quotient poly cells (openvm-org#72)

* feat: reserve capacity for perm & quotient LDE; avoid copy for quotient split (openvm-org#73)

* chore: log quotient poly cells

* feat: perm trace reserve extra capacity

* feat: quotient no-resize and no-copy

* fix: small trace heights

* fix: misunderstanding of vertical striding

* chore: clarify comment

* chore: bump workspace version to `1.0.1` (openvm-org#74)

* release: v1.1.0 (openvm-org#76)

* feat: update security parameters (openvm-org#20)

* chore: update status in readme (openvm-org#21)

closes INT-4015

* fix: account for poles in log up security calculation (openvm-org#22)

* chore: update readme

* fix(plonky3): update plonky3 commit for security fix

---------

Co-authored-by: Zach Langley <zblangley@gmail.com>

* perf: optimize `compute_quotient_values` (openvm-org#75)

* chore: rename keccak example to keccakf

* feat: add example to bench compute_quotient and readme

* chore: add bench script

* chore: update profile script to use perf on linux

* feat: `parallelize_chunks`

* feat: allocate once per thread

* feat: share alpha_powers and avoid `Vec::push`

* chore: bump workspace version

* feat: Export metrics to Prometheus server (openvm-org#70)

* Add metrics exporter

* Add tracing context

* Fix tokio

* Revert "Fix tokio"

This reverts commit fdd16a8.

* Install crypto provider

* Increase interval length

* Feature gate

* Small fixes

* chore: remove unused modules (openvm-org#77)

---------

Co-authored-by: Jonathan Wang <31040440+jonathanpwang@users.noreply.github.com>
Co-authored-by: Zach Langley <zblangley@gmail.com>
Co-authored-by: Manh Dinh <manh9203@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.

1 participant
0