Repository navigation
perf: compare a pair again after a stopped try with no unfold - #355
Merged
Merged
Conversation
When the compare of the arguments in v_try_struct stops on its bound, engine V takes the false as a guess that an unfold finds the equality. If no side can unfold after the stop, nothing compared the arguments in full, so engine V gave a false that is not a result and declined the check. Now v_eq_core compares this pair again with the bound of the check.
The retry after a stopped try can use at most 1<<22 work and 128 MiB of arena growth. A retry that stops on these bounds stops the check, and engine R checks the declaration.
The retry can use at most 1<<23 work and 256 MiB of arena growth. Inside the retry, v_spent also checks the arena size, because a long Nat computation can grow the arena with few unfolds.
Spec perf/19.31 compares engine V with the rivals test by test, gives the gap in v_eq_core, the measures of the fix and of its bound, and the decision. The code comments name v_retry_struct.
The two changelog lines of the retry name #355.
This was referenced Dec 2, 2026
Merged
tamnd
added a commit
that referenced
this pull request
Dec 2, 2026
This PR makes the release v0.11.1. The release is a step of the milestone M14 (#354). The PR sets the version to 0.11.1 in `Cargo.toml`, `Cargo.lock` and `fuzz/Cargo.lock`, and adds the changelog entry. The code change of this release is #355: engine V compares a pair again when its compare stopped on the bound of `v_try_struct` and no side of the pair can unfold. On a build without PGO, the sum of the 44 perf tests goes from 127.72 G to 96.63 G instructions. `--confirm all` gives 0 disagreements on `init`, `std` and the Arena tests, and each Arena test gives the expected exit code. Part of #354.
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.
Problem
v_try_structcompares the arguments of two applications with a work bound ofTRY_WORK. If this bound stops the compare, it gives false, because a later unfold usually finds the equality. But if no side can unfold, asEq Bool (decide p) trueagainstEq Bool true truein adecideproof, the lazy delta loop ends at once and nothing compares the arguments again. So engine V gives false for two equal values, and engine R checks the declaration again from the start. nano-lean and the official kernel always finish this compare.Change
v_eq_corekeeps the pair of the last compare that stopped on the bound ofv_try_struct. If the loop ends with the same pair and no step after the loop changes it,v_retry_structcompares the pair again.magma-list-pair-n21andgf3-matrix-productslower.v_spentalso checks the arena size, because aNatcomputation can grow the arena with few unfolds.Measures
Build without PGO,
perf stat -e instructions:u, one thread, on server4.magma-list-deep-n36grind-field-kernel-cancelmagma-list-pair-n21gf3-matrix-productshort-circuit-and-badinitstdThe loss on
initcomes from declarations where engine V is slower than engine R. A larger depth bound makes it worse (spec perf/19.31.4).Checks
cargo clippy --workspace --all-targets -D warningsis clean, andcargo xtask allpasses.