Skip to content

Bound peak memory in pyrefly coverage with streaming collection#4012

Open
jorenham wants to merge 1 commit into
facebook:mainfrom
jorenham:gh-3989-alt
Open

Bound peak memory in pyrefly coverage with streaming collection#4012
jorenham wants to merge 1 commit into
facebook:mainfrom
jorenham:gh-3989-alt

Conversation

@jorenham

@jorenham jorenham commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

pyrefly coverage {check, report} kept every module's bindings/answers/ASTs in memory all at once (Require::Everything). It now collects each module the moment it is solved, right before the run evicts it, so peak
memory holds only the solver's working set. Unlike the chunked collection approach from #4009, which increased runtime, this approach improves runtime, because by keeping everything in memory, it also recorded traces that were never read.

awesome project modules RSS before (GiB) RSS after (GiB) time before (s) time after (s)
numpy 560 5.06 1.44 195 168
scipy-stubs 589 2.29 0.57 16 4

(debug build)

The measurements in #4009 differ in the "before" because those used an outdated numpy version and ran scipy-stubs without scipy having installed.

Fixes #3989 and supplants #4009

Test Plan

Regression test added, and verified that this did not change any of the results for scipy-stubs and numpy.

@github-actions

This comment has been minimized.

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@jorenham

jorenham commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

windows CI failure seems unrelated (and flaky)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pyrefly coverage check uses significantly more memory than pyrefly check

2 participants