Repository navigation
Conversation
When at least half of the limbs of the long operand are zero, the product adds one row for each limb that is not zero. The masked rows of a packed matrix in gf3-matrix-product have about 3% of their limbs not zero.
Engine V records the source term of a binary Nat operation when the term has no loose bound variable. When engine V must compute the operation, it asks engine G for the value first. Engine G makes no values in the arena, so a large closed computation does not stop engine V on the arena bound and then run again in engine G.
Engine V reads back a closed value as a term when the other side of a compare is a Bool or Nat value, and engine G computes the term, as ground_defeq of engine R does. The origin step of the Nat operations moves to the new module vground.rs.
The compare hook gave each closed compare with a scalar to engine G at once. On grind-field-kernel-cancel engine G used about 13 G instructions on 20 certificates that engine V computes with less than 2^19 work each. Now engine V computes the value first with at most 2^20 work and 64 MiB of arena growth. Only a value that engine V does not compute in these bounds goes to engine G, and a stop on these bounds is not a stop of the check.
A compare in v_try_struct is a guess, and the probe of engine V there did work that the check did not need, which cost 0.83 G on std. Now v_eq_ground does not run in v_try_struct. A pair that the try does not decide comes back in the retry, where the hook runs.
The section gives the cost of gf3-matrix-product, the sparse product, why engine V stopped on the closed computations, the two sites that give them to engine G, why engine G is not always the faster engine, and the measures. The changelog has the entry.
tamnd
enabled auto-merge (squash)
December 2, 2026 16:57
auto-merge was automatically disabled
December 2, 2026 17:00
Pull request was closed
tamnd
enabled auto-merge (squash)
December 2, 2026 17:00
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Part of #354.
This PR removes most of the cost of the closed computations that engine V met on the perf tests. It has three changes.
Natproduct (rulean-nat/src/limbs.rs) skips the zero limbs of the long operand when at most half of its limbs are not zero. Ingf3-matrix-product, each step multiplies a masked row of a packed matrix where about 3% of the limbs are not zero.Natoperation to engine G before it computes the arguments (v_ground_origininv_nat_step). Engine G keeps no value of a step after the step, so the large results ofgf3-matrix-productdo not fill the arena of engine V.BoolorNatvalue to engine G (v_eq_groundinv_eq_core), asground_defeqof engine R. The hook does not run inv_try_struct, where the compare is a guess. Engine V first computes the value with at most 2^20 work and 64 MiB of arena growth (v_probe), and only a value that engine V does not compute in these bounds goes to engine G.The probe is necessary. The first form of change 3 gave each compare to engine G at once, and
grind-field-kernel-cancelwent from 5.94 G to 18.14 G instructions. A measure build showed 20 certificates of about 4.5 million steps each in engine G, which engine V computes with less than 2^19 work each. Spec perf/19.33.5 gives the measures.Engine G gives a result only when it computes a constructor or a literal, so each result of the hooks is the result of the same steps in engine V. Rule 2 of spec 05.1 does not change.
Measures (instructions, build without PGO, server4):
gf3-matrix-productmagma-list-pair-n21magma-list-pair-n7grind-field-kernel-cancelinitstdThe 238 Arena verdicts are correct, and
--confirm allgives 0 disagreements oninit,stdand the Arena tests.cargo test --workspace,cargo clippy -D warningsandcargo xtask allpass. The sum of the perf tests is now 1.52 times less than kefir, 19.65 times less than nanoda and 23.55 times less than official.gf3-matrix-product,magma-list-pair-n21andgrind-field-kernel-cancelare now faster than each rival.Changes:
mul_schoolandsparse_rowsincrates/rulean-nat/src/limbs.rs, and the testsparse_rows_agree_with_num_bigintincrates/rulean-nat/tests/oracle.rs.crates/rulean-core/src/vground.rs, the memooriginand the countertriesofVState, and the two hooks invreduce.rsandvdefeq.rs.