Repository navigation
metro-source-map: Look up source content in indexed maps without querying every section - #2250
Merged
Merged
Conversation
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
React Native release builds compose Metro's bundle source map with the Hermes compiler's map using
composeSourceMaps. Since Metro 0.86.0, the bundle map is an indexed map with one section per module.composeSourceMapsgets each source's content withsourceContentFor, andSectionsConsumer.sourceContentForasks every section in turn, normalizing the requested path again in each one. The time grows with sources × sections: for an app with 17,110 modules, composing takes about 50 s, nearly all of it in these lookups.SectionsConsumernow builds a map from normalized source to content on its firstsourceContentForcall. When several sections have content for a source, the first one still wins, so the composed map is unchanged; for the app above, composing takes about 2.5 s. Maps with a section that has asourceRootkeep asking every section.Changelog: [Performance] Faster
composeSourceMapsfor bundles with many modulesTest plan
Consumertests for indexed maps: a section withoutsourcesContentand a missing source, a source repeated within a section, a requested path that needs normalizing, a map with asourceRootsection, and a nested section. Removing thesourceRootfallback, the recursion into nested sections, the first-entry rule or the skip for sections withoutsourcesContenteach fails the matching test.yarn jest packages/metro-source-map,flow check, ESLint and Prettier pass.composeSourceMapsfrom source,mainand this PR, 5 interleaved runs each. Output is byte-identical.main(median)hermesc -OmapScript for the synthetic maps