-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
perf_hooks: simplify perf_hooks #19563
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.
Code changes LGTM
We need to add |
@hiroppy .... let's do that in a separate PR :-) |
00932a3
to
229fed3
Compare
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.
LGTM
It's probably important to know that after the performance timeline has filled up, it's no longer possible to create events - which means the memory leak is quite contained. I'm +1 on this change though. Continuously clearing timings without having a way to clear single timings is annoying to say the least. And from the looks of it this will simply make using this API faster. Real neat! Refs |
This looks great, @jasnell! It makes a lot more sense to get people to just work with the observer API instead. As in, you might start of with |
Just to be sure, everything one can do with |
Yep, there's just no persistence of the performance entries so you'll need to have a PerformanceObserver registered in advance to catch the entries and work with them. |
Remove the `performance.getEntries()` and `performance.clear*()` variants and eliminate the accumulation of the global timeline entries. The design of this particular bit of the API is a memory leak and performance footgun. The `PerformanceObserver` API is a better approach to consuming the data in a more transient way.
229fed3
to
9f9ff4c
Compare
Tweaked a few things and fixed a bug... new CI: https://ci.nodejs.org/job/node-test-pull-request/13998/ |
a lot of the stuff removed here appears to be specified by w3c, have we properly considered this/reached out to the web performance wg? |
@devsnek ... that's actually part of the point. The bits removed here are from a part of the defined standard API that is not super usable, not super useful, and has a non-zero risk of introducing memory leaks. It is something that can easily be re-implemented by userland code if necessary. |
@jasnell I have nothing specific against removing them I just thought it would be nice to let them know beforehand |
Yeah, I've already put out a heads up on my twitter feed. Both @yoshuawuyts and @lrlna are consumers of the API, and this would go into the notable changes for whatever release it lands in. The feature is still marked as experimental as well. |
New CI is looking good. There's one build bot that's lagging currently but there are no indications that this will fail there. |
Remove the `performance.getEntries()` and `performance.clear*()` variants and eliminate the accumulation of the global timeline entries. The design of this particular bit of the API is a memory leak and performance footgun. The `PerformanceObserver` API is a better approach to consuming the data in a more transient way. PR-URL: #19563 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
Landed in 2ec6995 |
Should this be backported to |
Replacement for
|
Is anyone able to summarize why |
@jmm ... Yes, the challenge here is that the Performance API as specified actually includes a bit of a built in memory leak (e.g. things like measures accumulate forever until the user explicitly clears them). We have to retain marks simply because of their nature but we handle measures as being fully transient (that is, measures are not persisted after they are emitted to a |
@jasnell Thanks! That's the gist I understood from reading the previous posts, but I was confused because in AWS Lambda it seemed I was getting accumulating measures each time the container was re-used. After your reply I realized that it wasn't accumulating measures, it was my mistake accumulating So, sorry to make you repeat yourself :), but I definitely appreciate the reply. |
While
perf_hooks
are still experimental, remove theperformance.getEntries()
andperformance.clear*()
variants and eliminate the accumulation of the global timeline entries. The design of this particular bit of the API is a memory leak and performance footgun. ThePerformanceObserver
API is a better approach to consuming the data in a more transient way.Note that this does mean having a slight variance with the browser based API but it's an important one. Even the browser API suffers from the possibility of a memory leak the way the performance timeline API is defined. Any other attempt to mitigate this would also mean deviating from the standard API definition so let's just do it right and remove the problematic bits while we can.
/cc @mcollina
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes