-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lib: reduce startup time #20567
Closed
Closed
lib: reduce startup time #20567
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
35cc355
string_decoder: lazy loaded
BridgeAR d480b63
querystring: lazy loaded
BridgeAR 5c144fa
readline: lazy loaded
BridgeAR a18174b
os: lazy loaded
BridgeAR 02c3b4b
dns: lazy loaded
BridgeAR 9168e15
bootstrap: only load inspector stuff if necessary
BridgeAR 1dfa4ec
esm: lazy load necessary loaders
BridgeAR 246ab38
cluster: remove obsolete array allocation
BridgeAR e8ae9a4
trace_events: lazy loaded
BridgeAR ce21afd
lib: use capital letters in comments
BridgeAR a093ed3
bootstrap: remove unnecessary require
BridgeAR 4733c2a
tools: stricter eslint rule for globals
BridgeAR e0080ce
assert,util: lazy load comparison functions
BridgeAR bd96a9d
async_hook: lazy loading for startup performance
BridgeAR d31581f
bootstrap: do not call performance hooks
BridgeAR 0093e0d
stream: lazy load ReadableAsyncIterator
BridgeAR 0b31adc
console: lazy load cli
BridgeAR 5c3a245
stream: lazy load end-of-stream
BridgeAR b0bbbba
net: lazy load dns
BridgeAR 3ca0b58
test: add loaded modules test
BridgeAR File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of this, you could assign
isDeepEqual
a function that loads and then overwrites itself. That way you can be sure you caught all the use sites.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hashseed Can we just use something like
And use
lazyComparison()
everywhere for simplicy? I guess V8 should be able to inline that?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You would have to use
lazyComparison()(args)
the way you defined it. Inlining shouldn't be an issue here.I'd even go a bit further and define a wrapper that can be reused:
You can then use this to load
comparison
:I wonder though whether inlining that would be an issue. @bmeurer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just ran benchmarks on all three of the variations and looking at the numbers it seems like everything gets inlined (both ways). Depending on how I write the benchmark, the outcome is favorable for some other different versions.
Without the if block,
a
is the winner with ~450ms vs ~500ms. With the if block,b
is the winner with ~450ms vs ~500ms.I personally normally use it the way as is right now but I see the point for it being error prone. Even though it also some times allows to only lazy load once outside of a loop instead of running a function in a hot loop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we should agree on one specific way how to do this. I do not have a strong opinion (anymore) and would like to let others decide which one to pick.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like Yang's way if it is fast.