Conversation
ZeWaka
force-pushed
the
proc-body-heap
branch
4 times, most recently
from
October 5, 2026 00:36
e2c6104 to
a84bf5f
Compare
Parse proc bodies into their own mimalloc heap, then drop them and collect that heap once both background jobs finish, so their pages actually return to the OS.
ZeWaka
marked this pull request as ready for review
October 5, 2026 01:05
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.
Supersedes #486, per:
This time, the parser gets a hook that runs around each proc body. The langserver uses it to switch mimalloc's default heap to a separate proc heap while a body is being parsed, so everything a proc body allocates ends up there.
Once the Find References table and dreamchecker are done with the tree, the proc bodies get dropped and the proc heap is collected. Errors registered while parsing a proc body are copied back out of the proc heap so they don't pin its pages.
The background jobs wake up the main loop when they finish, so the memory is released right away. VSCode doesn't send anything while idle, so otherwise it'd sit there until the next hover or keystroke.
Diagram
A thick border means it's kept in memory while idle
flowchart TD S[Load or reparse] --> P[Parse] P -->|everything else| M[Object tree<br/>for hover, completion, goto] P -->|proc bodies| H[Proc heap] H --> R[Build Find References table] H --> D[Run dreamchecker] R --> T[Find References table] R --> F[Proc bodies dropped,<br/>proc heap collected] D --> F classDef kept stroke-width:3px class M,T keptMedian of 3 runs each on my local Windows machine:
Similar percentages on Debian WSL using glibc.
Thoughts
Unlike #486 there's no speedups, since that came from the main thread skipping proc bodies. There's no extra memory overhead from double-parsing, though.
I don't think waiting for custom allocators in 1.100 would help here since
String/Cow/IndexMapstill won't take an allocator, so a lot of proc body memory would still land in the main heap.Related: #113