You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First off, a thank you @littledan for pointing me at this proposal. Overall I think it's a great start and a great addition to the API surface here. It should be fairly straightforward to implement support for this in Node.js and definitely think it's something we would do.
A couple of comments on the API... May have more later but these are what jumps out immediately.
An alternative to specifying a sample interval would be to specify a sample rate ... for instance, something like await performance.profile({ hz: 20 }) (sample at approximately 20 samples per second).
The ProfilerTrace object can potentially be a bit heavy in terms of memory load. It would be very interesting to support a streaming mode as an alternative that just outputs a raw stream of profile data rather than building up the index. Imagine an API like...
constprofiler=awaitperformance.profile({sampleInterval: 10});for(leti=0;i<1000000;i++){doWork();}profiler.stop();sendTrace(awaitprofiler.trace());// returns the parsed `ProfilerTrace`// alternativelyconstprofiler=awaitperformance.profile({sampleInterval: 10});profiler.reader().pipeTo(writable);// Consumes the profile as a raw stream of eventsfor(leti=0;i<1000000;i++){doWork();}profiler.stop();
The stream approach would generate more raw unprocessed data but would allow it to be piped out and processed later much more efficiently.
The text was updated successfully, but these errors were encountered:
For (2), a stream is interesting because it could provide a workaround for cases where the Profiler is active and the page is unloading. In that case, the website may wish to stop-and-send the profile, but the Promise from Profiler.stop() may prevent that from happening (since the page will move-on with unloading before the Promise resolves).
If there was a stream available, the website code could maintain the profile stream on its own, and be able to beacon the profile at unload without waiting for a Promise.
I think the challenge is that there are multiple parts to "stream" though, looking at the current output of a Profiler.stop(), where you get frames, resources, samples and stacks top-level objects. Each of those would need to be "streamed" in a way, or the stream would need to be notified if there were any new entries in any of the above.
First off, a thank you @littledan for pointing me at this proposal. Overall I think it's a great start and a great addition to the API surface here. It should be fairly straightforward to implement support for this in Node.js and definitely think it's something we would do.
A couple of comments on the API... May have more later but these are what jumps out immediately.
An alternative to specifying a sample interval would be to specify a sample rate ... for instance, something like
await performance.profile({ hz: 20 })
(sample at approximately 20 samples per second).The
ProfilerTrace
object can potentially be a bit heavy in terms of memory load. It would be very interesting to support a streaming mode as an alternative that just outputs a raw stream of profile data rather than building up the index. Imagine an API like...The stream approach would generate more raw unprocessed data but would allow it to be piped out and processed later much more efficiently.
The text was updated successfully, but these errors were encountered: