-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
module: print amount of load time of a module #52213
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
Conversation
|
Review requested:
|
|
Could this perhaps get its own label in |
82249f3 to
838237a
Compare
|
@GeoffreyBooth I changed to I didn't found any good alternative for this name, so I'm open to change this to another one if needed. |
|
Conceptually this feels more like something for trace_events than NODE_DEBUG? |
b80bab3 to
ac6e394
Compare
|
@richardlau Maybe I'm not familiar with trace_events but from what I see in the source code, I think it won't be as useful as having it as The benefits of emitting these events through |
|
|
|
Actually |
|
@joyeecheung I changed the implementation to match what we discussed, I liked this new way, it will print in the I still have some tests to fix but in general the implementation is good enough to get some reviews. |
|
I fixed the tests and I also changed a little bit the visualization for |
RafaelGSS
left a comment
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.
Can you update the PR to include only the changes this PR is about? I can see some linting and type changes.
|
@H4ad Is it possible to backport this to node 20? |
|
I don't know, usually we need someone from the release team to select this PR first to see if there is any conflict, only if we have conflicts we need a manual backport. |
|
Tentatively backported in #56927 - backporting this reduces the conflicts, though it seems associated with some other later commits, some included regressions, so only tentatively backporting it together with the associated commits that I found, which seemed safe enough. |
|
Backing it out from #56927 to avoid introducing surface for regressions. |

I was investigating why
npmis slow and I started to figure out that was caused by it loading a lot of modules/js files, but I didn't know what are those modules or even how much time it took to load them.So, this implementation came to my mind, and I used with the following commands:
The log looks like this:
If we try to clean a little bit:
The output was:
In this way, is very clear what is taking a lot of time to load
npm, and I actually already opened a PR to fix one of the issues that appeared in this log (npm/cli#7314)@joyeecheung suggest to include also the support for
trace_events, so I created thedebugWithTimerto introduce support for both ways extract information, via log or via trace:This will generate a
trace-events.logfile that can be imported onchrome://tracingor Perfetto UI to generate the following graph:To be easier to read, I introduce two labels on the
debugWithTimer, the first one will be for logging viaNODE_DEBUGand the second one will be used at thetrace./cc @nodejs/performance