-
Notifications
You must be signed in to change notification settings - Fork 309
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
[profiling] Add experimental CPU profiler #3895
Conversation
Overall package sizeSelf size: 5.83 MB Dependency sizes
🤖 This report was automatically generated by heaviest-objects-in-the-universe |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #3895 +/- ##
=======================================
Coverage 84.69% 84.69%
=======================================
Files 238 238
Lines 10156 10176 +20
Branches 33 33
=======================================
+ Hits 8602 8619 +17
- Misses 1554 1557 +3 ☔ View full report in Codecov by Sentry. |
5e2735e
to
37ad59c
Compare
BenchmarksBenchmark execution time: 2024-01-08 14:12:30 Comparing candidate commit 4aa5fbf in PR branch Found 1 performance improvements and 0 performance regressions! Performance is the same for 258 metrics, 7 unstable metrics. scenario:plugin-graphql-with-depth-off-18
|
const end = new Date() | ||
const end = Date.now() |
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.
Is this okay? As far as I can tell, we use Date
objects for start and end throughout. We could consistently use millis everywhere, but that'd be a larger change.
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 messed up my commits, fixed.
@@ -171,10 +171,11 @@ class EventsProfiler { | |||
stop () { | |||
if (this._observer) { | |||
this._observer.disconnect() | |||
this._observer = undefined |
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.
With this, we could also move the .observe
call into the if
statement in the start ()
method.
} | ||
} | ||
|
||
profile (startDate, endDate) { | ||
profile ({ startDate, endDate, restart = true }) { |
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 wanted to ask what's the value in passing an object here, and what's the value in having a default for restart – if the only call site is in profiler.js and it always passes all three values then just keeping 3-args would suffice. Except if you want to avoid specifying all args in wall and space profilers, in which case this might make sense. I'm still unclear on what does the default buy us.
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.
Well, my initial thought was that since wall and space profilers did not use startDate/endDate, it would be nice to not specify these parameters for them and at the same time make the API flexible.
But since this can be considered as an internal API than we can change at will, I guess we can pass 3 arguments as well.
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.
But having 3 args, implies updating tests with things like profiler.profile(undefined, undefined, true)
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 could swap the args to avoid that:
profile (restart, startDate, endDate)
@@ -267,30 +290,16 @@ class NativeWallProfiler { | |||
return labels | |||
} | |||
|
|||
profile () { | |||
return this._stop(true) | |||
profile ({ restart = true } = {}) { |
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 like { restart = true} = {}
. This is fun :-) OTOH, we don't use = {}
in the events profiler, and I'm unclear on where would we call this method without arguments. Is it from tests?
7fda2e6
to
d250c7e
Compare
d611230
to
af2b748
Compare
af2b748
to
5012a60
Compare
@@ -2,6 +2,7 @@ | |||
|
|||
const fs = require('fs') | |||
const { promisify } = require('util') | |||
const { threadId } = require('node:worker_threads') |
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.
Won't node:
again cause trouble for Node < 14.18?
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.
Woops, fixed
Upon process exit, profiler collects profiles a last time and was restarting all profilers before stopping them. Avoid this useless restart by changing the profiler API and make `profile()` methode take a restart argument.
5012a60
to
4aa5fbf
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.
🚢 🚢
* Add CPU profiler * Avoid restarting profiling for last collect Upon process exit, profiler collects profiles a last time and was restarting all profilers before stopping them. Avoid this useless restart by changing the profiler API and make `profile()` methode take a restart argument. * Bump pprof-nodejs version
* Add CPU profiler * Avoid restarting profiling for last collect Upon process exit, profiler collects profiles a last time and was restarting all profilers before stopping them. Avoid this useless restart by changing the profiler API and make `profile()` methode take a restart argument. * Bump pprof-nodejs version
* Add CPU profiler * Avoid restarting profiling for last collect Upon process exit, profiler collects profiles a last time and was restarting all profilers before stopping them. Avoid this useless restart by changing the profiler API and make `profile()` methode take a restart argument. * Bump pprof-nodejs version
* Add CPU profiler * Avoid restarting profiling for last collect Upon process exit, profiler collects profiles a last time and was restarting all profilers before stopping them. Avoid this useless restart by changing the profiler API and make `profile()` methode take a restart argument. * Bump pprof-nodejs version
What does this PR do?
Motivation
Additional Notes
Security
Datadog employees:
@DataDog/security-design-and-guidance
.Unsure? Have a question? Request a review!