Repository navigation
Keep expansions and nested results across one outermost Simplify - #2015
Merged
Merged
Conversation
Simplify expanded, factored and re-simplified the same trees over and over. The polynomial pass in Simplificator.Alternate ran res.Expand() once per variable; Patterns.SumOfFractions simplified the product of the denominators afresh and the Expand and Factorize candidates were simplified again; and PolynomialFactoring.TryGetRationalCoefficients expanded once more. For t^4/((b t^2 + a + a t^2)^2 (1 + t^2)), the integrand Rubi's 4.1.7:136 hands the homogeneous substitution, 11.0 of 12.09 GB was one 342-term product expanded 72 times; 7.4.2:891 ran 2,145 factoring calls on 200 distinct polynomials and 1,232 nested Simplify calls on 214 distinct trees. The polynomial pass now expands each candidate once. Expansions and nested Simplify(expr, level) results are kept in a thread-static table that lives for the outermost Simplify only, keyed by the tree's value, each entry with its own SettingsState snapshot and used only while it still holds; only elementary trees are kept, and nothing while a RewriteRecording is open. Answers are identical. Chain against master 08a3c49: pocket of 3,836 rows (every 15th of each family, every 2nd of 4.1.7 and 7.4.2), allocation over the 3,813 solved on both 648.4 -> 375.8 GB and time 1,012 -> 815 s; samples of every family unchanged in verdicts, allocation down 19-70% per family (family 4 133.5 -> 64.7 GB); no row's allocation grew past 1.3x. Alone, 1.3.2:599 and 3.3:246 timeout -> answered, 6.6.3:213 timeout -> declined. Part of #233. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
…line The gate reported IMPROVED: SimplifyHard allocates 157,895,384 B/op, 10.0% below the 175,442,312 recorded at 7c0dce12 on 2026-09-28, where the baseline was last taken. The file is the one this pull request's own Benchmark job wrote, measured-CommonFunctionsInterVersion.json from its artifact, copied over the baseline as version_performance_control.md describes. Every other gated row is within its band: SimplifyEasy +0.8%, Derivate +0.8%, SolveHard -1.5%. The run was on .NET 10.0.13 on a 4-core Ubuntu 24.04 runner, where the previous baseline records .NET 10.0.10 on an 8-core Ubuntu 26.04 machine, so the recorded times are the runner's; the gate fails on time only past 3x. The ungated map and its reasons are carried over. Part of #233. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
Rafael-SOWNet
force-pushed
the
keep-expansions-across-one-simplify
branch
2 times, most recently
from
October 21, 2026 13:57
7a13440 to
d3d1e2d
Compare
This was referenced Oct 21, 2026
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 #233.
Simplifyexpanded, factored and re-simplified the same trees over and over:Simplificator.Alternateranres.Expand()once per variable;Patterns.SumOfFractionssimplified the product of the denominators afresh, and the Expand and Factorize candidates were simplified again;PolynomialFactoring.TryGetRationalCoefficientsexpanded once more.The cost was located by attributing bytes to
AddHistorycall sites. Two examples:t^4/((b t^2 + a + a t^2)^2 (1 + t^2)), the integrand that row hands the homogeneous substitution, 11.0 of 12.09 GB was one 342-term product expanded 72 times.Simplifycalls on 214 distinct trees.The fix:
Simplify(expr, level)results are kept in a thread-static table that lives for the outermostSimplifyonly, keyed by the tree's value.SettingsStatesnapshot and is used only while that still holds. A single stamp for the whole call missed 2,219 of 2,325 lookups, because settings register lazily and the snapshot grows partway through.absandsgn. Nothing is kept while aRewriteRecordingis open.Answers are identical.
Chain against master 08a3c49, with the harness at its current revision on both arms:
The samples of every family are unchanged in verdicts, and allocate less:
Tests: a new class pins four integrals with allocation bounds on the test's own thread, plus one
Simplifyform. With the change disabled, all five fail on their bounds (7.4–19.7 GB against 3–8 GB). Locally, 4,302 tests across the patterns, simplification, factoring, recording, polynomial, expansion, transformation, corpus and multithreading classes pass.The kernel benchmark gate will report IMPROVED. Measured locally on the test thread:
SimplifyHardallocates 176.66 → 158.15 MB/op (−10.5%), andSimplifyEasy+0.9%, within the band. All eight benchmark answers are byte-identical. I will copy this run'smeasured-CommonFunctionsInterVersion.jsonfrom the CI artifact overperformance-baseline.json, asversion_performance_control.mdsays a decrease is to be recorded.🤖 Generated with Claude Code
https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura