Stop the rescorer falling to its memmap while RAM is free - #88
Merged
Merged
Conversation
Reported as "rescoring is still very very slow". On a six-file Astral experiment the pooled rescore took 166 minutes for 3,133,636 PSMs x 387 features. Cause: that matrix decodes to 4.52 GiB and MUMDIA_NN_STREAM_GB was a fixed 4, so the worker chose its disk-backed memmap -- over the line by 13%, on a machine with 96 GiB of RAM and 42 free. The recorded in-memory reference for a comparable pool is about 20 minutes, so the fixed threshold cost roughly 9x. Unset, the threshold is now twice free physical memory, floored at the historical 4 GB so a machine too small to benefit is unaffected. Greater than 1x on purpose: the memmap is a last resort, not a safety margin. Between 1x and 2x the operating system pages, which for this largely sequential access is far cheaper than the memmap's indexed minibatch reads; past that the paging thrashes and the memmap becomes the better of two bad options. The consequence is deliberate and documented: in that band the rescore relies on the page file, so a machine without one should set MUMDIA_NN_STREAM_GB explicitly. Free memory is read without a new dependency -- psutil is not in the rescore environment and is not worth the resolver risk for one number -- via GlobalMemoryStatusEx on Windows and MemAvailable on Linux, returning None anywhere else so the caller keeps the fixed default rather than guessing. On the machine that reported this: 4.00 GB -> 82.1 GB, and the 4.52 GiB matrix stays in RAM. Also corrected in my own reading of it: the worker was never silent about this. It has always printed the backend and the sizes; that line was simply lost among the DeepLC blank lines that #84 removed. It now also reports where the threshold came from, and says plainly when the slow path was taken for want of memory. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This was referenced Sep 16, 2026
This was referenced Sep 16, 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.
Reported as "rescoring is still very very slow". On the six-file Astral experiment the pooled rescore took 166 minutes for 3,133,636 PSMs × 387 features.
Cause
That matrix decodes to 4.52 GiB, and
MUMDIA_NN_STREAM_GBwas a fixed 4. So the worker chose its disk-backed memmap — over the line by 13%, on a machine with 96 GiB of RAM and 42 free. The recorded in-memory reference for a comparable pool is about 20 minutes, so the fixed threshold cost roughly 9×.CLAUDE.md already documented this trap almost exactly: "a 4.31 GB matrix against the 4.00 GB default took the slow path". It had simply never been fixed.
Change
Unset, the threshold is now twice free physical memory, floored at the historical 4 GB so a machine too small to benefit is unaffected.
Greater than 1× on purpose: the memmap is a last resort, not a safety margin.
The consequence is deliberate and documented: in that band the rescore relies on the page file, so a machine without one (or with a small fixed one) should set
MUMDIA_NN_STREAM_GBexplicitly. That override works exactly as before.Free memory is read without a new dependency —
psutilis not in the rescore environment and is not worth the resolver risk for one number — viaGlobalMemoryStatusExon Windows andMemAvailableon Linux, returningNoneanywhere else so the caller keeps the fixed default rather than guessing.A correction to my own diagnosis
I told the reporter the worker was silent about this. It was not — it has always printed the backend and the sizes. That line was lost among the DeepLC blank lines that #84 has since removed. It now additionally reports where the threshold came from, and warns plainly when the slow path was taken for want of memory.
Validation
pytest tests/python— 85 passed, 8 skipped (two new tests: the multiplier is >1 so the memmap is never preferred over paging, the floor holds, the threshold explains itself, and reading free memory is optional and never fatal). Also passes on a bare interpreter with no ML dependencies. Config reference regenerated for the changed env-var documentation.🤖 Generated with Claude Code