Repository navigation
Conversation
Under the hot runtime a worker re-stat'd and re-read installed files it had already checked in the same test file: the resolution memo's hit stat, the transform's key stat, and the ESM loader's source comparison. These answers are now kept per test file for paths under node_modules and forgotten when the hot generation advances at the next file's start.
Installed files are checked once per hot test file, as Jest keeps one file cache per test file. The within-file edit and removal cases become cross-file pairs under the hot runtime and freshRuntime, and the changeset records the behaviour change.
The per-file memo of installed files is not cleared at jest.resetModules(), because a reset renews project modules only and never loads an installed file again. A hot jest-compat test pins that, so a change to the reset's scope must revisit the memo. The memo's comment states the comparison with Jest.
They prove that a load outside the hot runtime still goes to the disk, so they run there and are skipped only under the hot runtime, where the boundary pairs cover removal. Rewrap a comment and state which Node versions the import test's read count applies to.
danfry1
marked this pull request as ready for review
December 2, 2026 23:09
This branch has not been deployed
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.
Summary
Under the hot runtime, each installed package's file is checked on disk once per test file instead of on every load. On Rocket.Chat, the engine's repeated checks within a test file drop from 316,738 to 22,936 (−93%), with identical test results.
Why
A hot worker re-stat'd and re-read installed files it had already checked earlier in the same test file. It did this for the resolution memo's hit check, the compiled output's key, and the ESM loader's source comparison. Within one test file these answers can't change in a way the engine must notice. Jest keeps the same per-file view: its Runtime holds one file-content cache per test file (
_cacheFS, created in jest-runner'srunTest.js).Changes
src/native/file-facts.mjsholds the stat and the bytes of files undernode_modulesuntil the hot generation advances at the next test file. The three call sites read through it.freshRuntime): a change made in one file is seen by the next. Without the hot runtime the removal cases still run within one file.jest.resetModules()keeps installed packages loaded, which is why the memo isn't cleared there.Notes
jest.resetModules()too. That makes no difference here, because a reset never loads an installed file again (documented in the jest-compat guide). Jest's resolver caches last the whole run (jest-resolvefileWalkers.js), so resolutions here are fresher than Jest's.Fixes #935.