-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
assert: lazy load fs #20767
assert: lazy load fs #20767
Conversation
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.
Lazy loading fs
probably does not make a lot of difference given how the bootstrapping works, but if for the sake of consistency, LGTM
Hmm, by the way, maybe we want to have another more global way of knowing if a module is already loaded. In the case of a commonly used module like |
@joyeecheung - can you please elaborate on that, for my learning? Does the bootstrap load every core modules that is available in the |
Isn't it best leave it to the |
@gireeshpunathil No, we do not read code of internal modules from disk since they are compiled into the binary, but a) if the binary is started to execute a script provided by users, or do The only case where fs is unnecessary that I can think of is |
It's not about avoiding the load, it's about being more deliberate about the ordering of loading and only doing the require lookup when absolutely necessary, even if the module is already in the cache. |
Also we do have benchmarks for start up times: https://benchmarking.nodejs.org/ the source should be in the benchmarking repo. EDIT: see https://github.com/nodejs/benchmarking/tree/master/benchmarks/start_stop_time |
For a super-quick and rough startup benchmark, try For something more detailed, #20728 will emit trace events that are quite helpful for profiling when used alongside the |
Yes, I understand, just trying to look at it from a more distant perspective.
@gireeshpunathil The require used in the internal modules is a different function from the one exposed to the users (see the comments at the top of |
By the way, I used perf to see the start up times when I first looked into the bootstrapping performance. On my Ubuntu server with perf version
|
I doubt it is possible to lazy load |
This is more about deferring the load. I'd like to have it so that assert loads early and quickly without side effects. |
@jasnell but there is (almost) no extra load if |
Closing this for now. Will revisit it later. |
Originally part of #20734 ...
Lazy load
fs
inassert
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes