perf(ixvm): share argument-independent substitution work - #573
Closed
arthurpaulino wants to merge 1 commit into
Closed
perf(ixvm): share argument-independent substitution work#573arthurpaulino wants to merge 1 commit into
arthurpaulino wants to merge 1 commit into
Conversation
arthurpaulino
force-pushed
the
ap/ixvm-subst
branch
from
August 19, 2026 21:04
db79445 to
0770e6d
Compare
Large beta-reduction traces repeatedly instantiate the same expression with different arguments even when most subtrees do not reference the substituted binders. Those calls have distinct memo keys, so the kernel previously rebuilt the same argument-independent subtrees for every application. Add an exact loose-BVar occurrence query for single substitution. When the target binder is absent, lower only the higher variables through the existing memoized lowering path. Apply the analogous range test to simultaneous substitution: if no binder in the substitution window occurs, lower the expression once without keying the result on the substitution list. The ordinary substitution walks remain unchanged whenever an argument is actually used. Keep the resulting hot lowering circuit narrow by extracting its BVar, binder, and let arms into cold helpers. This is a circuit-layout change only; it reduces expr_lower_walk from width 53 to 34. Regenerate the native IxVM kernel. Validation: - A native sweep passed all 600 Init, InitStd, Batteries, Lean, FLT, and Mathlib shards without errors or timeouts. - Total FFT cost fell from 258.065T to 248.348T (-3.77%); Mathlib fell 5.12% and FLT fell 3.82%. - The former worst Mathlib shard fell from 1.740T to 1.206T (-30.66%), with elapsed time dropping from 260.67s to 187.68s and peak RSS from 38.76M KiB to 29.48M KiB. - On the next dominant isolated constant, CoalgCat.MonoidalCategoryAux.comul_tensorObj_tensorObj_right, the lowering circuit split further reduced FFT from 123.664B to 118.932B (-3.83%). Its left/composite siblings and the established Init, Batteries, and Nat.add_comm guards all pass under bytecode interpretation.
arthurpaulino
force-pushed
the
ap/ixvm-subst
branch
from
August 19, 2026 22:06
0770e6d to
d530731
Compare
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.
Large beta-reduction traces repeatedly instantiate the same expression with different arguments even when most subtrees do not reference the substituted binders. Those calls have distinct memo keys, so the kernel previously rebuilt the same argument-independent subtrees for every application.
Add an exact loose-BVar occurrence query for single substitution. When the target binder is absent, lower only the higher variables through the existing memoized lowering path. Apply the analogous range test to simultaneous substitution: if no binder in the substitution window occurs, lower the expression once without keying the result on the substitution list. The ordinary substitution walks remain unchanged whenever an argument is actually used.
Keep the resulting hot lowering circuit narrow by extracting its BVar, binder, and let arms into cold helpers. This is a circuit-layout change only; it reduces expr_lower_walk from width 53 to 34. Regenerate the native IxVM kernel.
Validation:
A native sweep passed all 600 Init, InitStd, Batteries, Lean, FLT, and Mathlib shards without errors or timeouts.
Total FFT cost fell from 258.065T to 248.348T (-3.77%); Mathlib fell 5.12% and FLT fell 3.82%.
The former worst Mathlib shard fell from 1.740T to 1.206T (-30.66%), with elapsed time dropping from 260.67s to 187.68s and peak RSS from 38.76M KiB to 29.48M KiB.
On the next dominant isolated constant, CoalgCat.MonoidalCategoryAux.comul_tensorObj_tensorObj_right, the lowering circuit split further reduced FFT from 123.664B to 118.932B (-3.83%). Its left/composite siblings and the established Init, Batteries, and Nat.add_comm guards all pass under bytecode interpretation.