lib: lazy-load builtins not used during startup#63926
Open
watilde wants to merge 1 commit into
Open
Conversation
Defer the url_pattern and blob bindings and the typescript builtin until they are first used, instead of requiring them unconditionally during bootstrap. Loading internal/blob lazily also drops the internal/encoding tree it pulled in. This removes 7 builtins from the startup module list (113 -> 106) and reduces bootstrapComplete by ~2% (median 11.70ms -> 11.45ms), measured with performance.nodeTiming over 100 interleaved runs. - fs.openAsBlob() and URL.createObjectURL() load internal/blob and the blob binding on demand - URLPattern is exposed via exposeLazyInterfaces and no longer forces the url_pattern binding at bootstrap - TypeScript type stripping loads internal/modules/typescript only when a .ts source is actually processed Signed-off-by: Daijiro Wachi <daijiro.wachi@gmail.com>
Collaborator
|
Review requested:
|
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.
Defer builtins that aren't needed on a bare startup to first use:
fs.openAsBlob()andURL.createObjectURL()now loadinternal/blob/ theblobbinding lazily (also drops theinternal/encodingtree it pulled in).URLPatternis now a lazy export, exposed viaexposeLazyInterfacesinstead of forcing the binding at bootstrap.internal/modules/typescriptloads only when a.tssource is actually stripped.
Impact
node -e "", 100 interleaved before/after runs viaperformance.nodeTiming:bootstrapComplete(median)Modest, since the compiled code already lives in the snapshot.
Test
test-bootstrap-modules.jsupdated to drop the 7 no-longer-loaded entries.url / urlpattern / module / blob / typescript / es-module suites and
make lint-jspass locally.