Subst improvements#3970
Open
mtzguido wants to merge 6 commits into
Open
Conversation
mtzguido
added a commit
to mtzguido/FStar
that referenced
this pull request
Mar 21, 2026
Port key ideas from PR FStarLang#3970 (subst improvements): 1. delay: Don't coalesce nested Tm_delayed nodes. Previously, delay would compose substitutions when encountering an existing Tm_delayed, which breaks structural sharing and causes quadratic memory blowup on deeply nested let-expressions (issue FStarLang#3800). 2. push_subst: Handle Tm_delayed by recursing through compress_subst instead of failing. This allows nested delayed substitutions to be resolved incrementally. 3. Tm_uvar: Use simple compose_subst instead of compose_uvar_subst in push_subst. 4. compress: Simplified to a single recursive function that resolves uvars and pushes substitutions in one pass. Benchmarks (1116 matched tests, heavy tests > 100 MiB): Memory: median +0.0%, mean -0.1%, range [-20.4%, +4.3%] (Main impact is on pathological cases like issue FStarLang#3800.) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
github-actions Bot
pushed a commit
to mtzguido/FStar
that referenced
this pull request
Mar 21, 2026
Port key ideas from PR FStarLang#3970 (subst improvements): 1. delay: Don't coalesce nested Tm_delayed nodes. Previously, delay would compose substitutions when encountering an existing Tm_delayed, which breaks structural sharing and causes quadratic memory blowup on deeply nested let-expressions (issue FStarLang#3800). 2. push_subst: Handle Tm_delayed by recursing through compress_subst instead of failing. This allows nested delayed substitutions to be resolved incrementally. 3. Tm_uvar: Use simple compose_subst instead of compose_uvar_subst in push_subst. 4. compress: Simplified to a single recursive function that resolves uvars and pushes substitutions in one pass. Benchmarks (1116 matched tests, heavy tests > 100 MiB): Memory: median +0.0%, mean -0.1%, range [-20.4%, +4.3%] (Main impact is on pathological cases like issue FStarLang#3800.) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This is counterproductive.
This has a minor impact in ranges, but it seems like an improvement.
Member
Author
|
!bench |
Contributor
🔬 F* Performance ComparisonBaseline: Summary
Totals: Memory: 843.0 MiB | Time: +160.0s Change Distribution
Heavy Tests (baseline > 100 MiB, n=906)
📉 Top 20 Memory Improvements
📈 Top 20 Memory Regressions
⬇️ Top 20 Time Improvements
⬆️ Top 20 Time Regressions
📋 Full Comparison (2058 tests)
|
Member
Author
|
The benchmarks don't look so good, and this one is concerning:
|
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.
I want to measure this across more files, but here's the improvement on the repro from #3800.
Before:
After:
So reducing RAM usage by 1/3.
https://github.com/mtzguido/FStar/actions/runs/16949854112