Skip to content

Feedback on the proposal #36

@jasnell

Description

@jasnell

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.

  1. 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).

  2. 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...

const profiler = await performance.profile({ sampleInterval: 10 });
for (let i = 0; i < 1000000; i++) {
     doWork();
}
profiler.stop();

sendTrace(await profiler.trace());  // returns the parsed `ProfilerTrace`

// alternatively

const profiler = await performance.profile({ sampleInterval: 10 });
profiler.reader().pipeTo(writable);  // Consumes the profile as a raw stream of events

for (let i = 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions