perf: avoid needless clones in permutation trace commit #69
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 useTraceCommitter
(which clones) but instead usepcs.commit
directly.I have add a
transmute_to_base
function to replaceflatten_to_base
. There doesn't seem a good way to have the compiler check the required safety assumptions, so I just document it. (TheBinomialExtensionField
implementation ofExtensionField
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