Uh oh!
There was an error while loading. Please reload this page.
assert: lazy load fs - #20767
Conversation
jasnell
commented
May 16, 2018
joyeecheung
left a comment
There was a problem hiding this comment.
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 |
gireeshpunathil
commented
May 16, 2018
@joyeecheung - can you please elaborate on that, for my learning? Does the bootstrap load every core modules that is available in the |
gireeshpunathil
commented
May 16, 2018
Isn't it best leave it to the |
joyeecheung
commented
May 16, 2018
@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 |
jasnell
commented
May 16, 2018
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 |
jasnell
commented
May 16, 2018
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
|
BridgeAR
commented
May 18, 2018
I doubt it is possible to lazy load |
jasnell
commented
May 18, 2018
This is more about deferring the load. I'd like to have it so that assert loads early and quickly without side effects. |
BridgeAR
commented
May 18, 2018
@jasnell but there is (almost) no extra load if |
jasnell
commented
May 23, 2018
Closing this for now. Will revisit it later. |
Originally part of #20734 ...
Lazy load
fsinassertChecklist
make -j4 test(UNIX), orvcbuild test(Windows) passes