-
Notifications
You must be signed in to change notification settings - Fork 637
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolver perf: Use directory existence to cut down candidate list (3/…
…n) (#1333) Summary: Pull Request resolved: #1333 Further optimise resolution with some work avoidance by using the fact that, when resolving `require('foo')`, we can eliminate any candidates of the form `<prefix>/node_modules/foo<suffix>` unless `<prefix>/node_modules` exists and is a directory. This saves a lot of lookups from deeply-nested origin modules. Further, when resolving `require('foo/bar')`, we can eliminate candidates of the form `<prefix>/node_modules/foo/<suffix>` unless `<prefix>/node_modules/foo` exists as a directory. This is a bit more subtle than it might seem, and can't be extended beyond these cases, due to redirection. For `require('foo/bar/baz')`, `foo/bar` need not exist anywhere, because some `foo/package.json` could redirect it. However, when looking up a `package.json` for possible redirections, we stop at `node_modules` (we do not check `node_modules/package.json`), so it's safe to treat anything up to and including `node_modules` (or `node_modules/foo` in the case `node_modules/foo.js` may not be a candidate) as a real file path that must be an extant directory. This fix reduces the existence checks we need to perform in RNTester such that total resolution speed is improved ~3x, or ~12x relative to the start of this stack / the previous Metro release. ``` - **[Performance]**: Use directory existence to cut down resolution candidates ``` Reviewed By: huntie Differential Revision: D58594993 fbshipit-source-id: 7be8c213a08fa651870ced588e2020ed8c3495d0
- Loading branch information
1 parent
60de111
commit 6f3af82
Showing
5 changed files
with
149 additions
and
50 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.