Repository navigation
Closed
Conversation
…ble_incrementalResolution The first consumer of the `Observations` API from #1944. With `resolver.unstable_incrementalResolution` on, each resolution records everything it looks up in the file map, and the record is returned on the `BundlerResolution` as `unstable_observations`. Invalidating from it is the next step, so resolution results are unaffected, and with the flag off nothing is allocated. `ModuleResolver` already builds a resolution context per call, so with the flag on it binds the file system capabilities in that context to the resolution's record: https://github.com/react/metro/blob/8f49d3681cfd567c821aaadc958b99fa1d58b4ca/packages/metro/src/node-haste/DependencyGraph/ModuleResolution.js#L144-L166 A custom `resolveRequest` therefore records whatever it looks up through the context without knowing about any of this, and `DependencyGraph`'s whole-resolution cache carries the record along with the cached resolution. Still to follow: `package.json` contents, which are still read outside the file map, Haste lookups (#1952), and failed resolutions. With the flag on this costs ~13% of resolution time (~2µs per resolution) and 2.1x the retained heap (5.3MB -> 11.1MB on our benchmark app). Nearly all of that is extension and platform candidates that missed (`a.ios.js`, `a.native.js`, ...), which is what to go after before this is worth turning on, eg by recording the directory once. With the flag off, everything is within noise. ## Benchmark AI-driven. Every `resolveDependency` call of one iOS dev build replayed through the whole-resolution cache, 7 interleaved rounds. Heap is measured in a fresh process per configuration. Resolutions are identical with the flag on and off. | scenario | `main` | this PR, flag off | this PR, flag on | |---|---|---|---| | first build (ms) | 129.0 | 131.0 (+1.6%) | 137.4 (+6.6%) | | rebuild, nothing changed (ms) | 7.98 | 7.96 (-0.3%) | 8.04 (+0.8%) | | after a source edit, re-resolving the edited module's dependencies (µs) | 229 | 219 (-4.3%) | 256 (+11.8%) | | after a `package.json` change, re-resolving everything (ms) | 102.5 | 101.9 (-0.6%) | 116.2 (+13.3%) | | heap retained after resolving (MB) | 5.3 | 5.3 | 11.1 (2.1x) | Changelog: Internal ## Test plan New tests assert the exact sets recorded for a relative import, a package walk, a symlink, asset variants and the empty module, and that nothing is present by default. Benchmark app: the synthetic RN 0.87 app described in #1945 (2.8k-module bundle, 34k-file file map).
Collaborator
Author
|
Opened by mistake, duplicate of #1949 |
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.
The first consumer of the
ObservationsAPI from #1944. Withresolver.unstable_incrementalResolutionon, each resolution records everything it looks up in the file map, and the record is returned on theBundlerResolutionasunstable_observations. Invalidating from it is the next step, so resolution results are unaffected, and with the flag off nothing is allocated.ModuleResolveralready builds a resolution context per call, so with the flag on it binds the file system capabilities in that context to the resolution's record:metro/packages/metro/src/node-haste/DependencyGraph/ModuleResolution.js
Lines 144 to 166 in 8f49d36
A custom
resolveRequesttherefore records whatever it looks up through the context without knowing about any of this, andDependencyGraph's whole-resolution cache carries the record along with the cached resolution.Still to follow:
package.jsoncontents, which are still read outside the file map, Haste lookups (#1952), and failed resolutions.With the flag on this costs ~13% of resolution time (~2µs per resolution) and 2.1x the retained heap (5.3MB -> 11.1MB on our benchmark app). Nearly all of that is extension and platform candidates that missed (
a.ios.js,a.native.js, ...), which is what to go after before this is worth turning on, eg by recording the directory once. With the flag off, everything is within noise.Benchmark
AI-driven. Every
resolveDependencycall of one iOS dev build replayed through the whole-resolution cache, 7 interleaved rounds. Heap is measured in a fresh process per configuration. Resolutions are identical with the flag on and off.mainpackage.jsonchange, re-resolving everything (ms)Changelog: Internal
Test plan
New tests assert the exact sets recorded for a relative import, a package walk, a symlink, asset variants and the empty module, and that nothing is present by default.
Benchmark app: the synthetic RN 0.87 app described in #1945 (2.8k-module bundle, 34k-file file map).