-
-
Notifications
You must be signed in to change notification settings - Fork 33.5k
v8: add cpu profile APIs #59429
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
v8: add cpu profile APIs #59429
Conversation
f7114fb
to
d49b31f
Compare
src/node_v8.cc
Outdated
V8::SetFlagsFromString(*flags, static_cast<size_t>(flags.length())); | ||
} | ||
|
||
class JSONOutputStream : public v8::OutputStream { |
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.
class JSONOutputStream : public v8::OutputStream { | |
class JSONOutputStream final : public v8::OutputStream { |
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.
Btw – we may want to use HeapSnapshotStream
here? I know it requires a bit more setup, but it integrates nicely with existing stream primitives in Node.js
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.
I think these are two issues in HeapSnapshotStream
:
- We should not delete the snapshot(which is created in worker) in main thread.
- It will crash when the worker exits.
const worker = require('worker_threads');
const w = new worker.Worker("setInterval(() => {}, 100)", { eval: true})
w.on('online', async () => {
const stream = await w.getHeapSnapshot()
stream.on('data', () => {});
// Crash
w.terminate();
});
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.
Advocating for using CpuProfiler::Start
and thus eliminating the need for users to invent names for the profiler sessions in order to use the API.
f4618c5
to
e78d71a
Compare
5037a4a
to
b3c64d0
Compare
b3c64d0
to
1b66417
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #59429 +/- ##
==========================================
+ Coverage 89.93% 89.95% +0.01%
==========================================
Files 667 667
Lines 196775 196841 +66
Branches 38409 38422 +13
==========================================
+ Hits 176977 177069 +92
+ Misses 12247 12200 -47
- Partials 7551 7572 +21
🚀 New features to boost your workflow:
|
Add CPU profile APIs.
make -j4 test
(UNIX), orvcbuild test
(Windows) passes