-
Notifications
You must be signed in to change notification settings - Fork 3
Store sampling context in ContinuationPreservedEmbeddedData #186
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
base: main
Are you sure you want to change the base?
Conversation
5b796ea
to
1b15c3a
Compare
1b15c3a
to
3decb46
Compare
bfa23b5
to
32b2170
Compare
32b2170
to
9f398f2
Compare
9f398f2
to
965a627
Compare
965a627
to
0c1791e
Compare
a2384e5
to
bb0bc2d
Compare
0c1791e
to
8f88f3d
Compare
@@ -66,6 +66,7 @@ export interface TimeProfilerOptions { | |||
withContexts?: boolean; | |||
workaroundV8Bug?: boolean; | |||
collectCpuTime?: boolean; | |||
useCPED?: boolean; |
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.
8f88f3d
to
717f17b
Compare
3c86526
to
79992a0
Compare
717f17b
to
2b9041d
Compare
Overall package sizeSelf size: 9.57 MB Dependency sizes| name | version | self size | total size | |------|---------|-----------|------------| | source-map | 0.7.4 | 226 kB | 226 kB | | pprof-format | 2.1.0 | 111.69 kB | 111.69 kB | | p-limit | 3.1.0 | 7.75 kB | 13.78 kB | | delay | 5.0.0 | 11.17 kB | 11.17 kB | | node-gyp-build | 3.9.0 | 8.81 kB | 8.81 kB |🤖 This report was automatically generated by heaviest-objects-in-the-universe |
BenchmarksBenchmark execution time: 2025-05-16 14:25:07 Comparing candidate commit cc4fbd7 in PR branch Found 1 performance improvements and 0 performance regressions! Performance is the same for 90 metrics, 29 unstable metrics. scenario:profiler-light-load-no-wall-profiler-24
|
2b9041d
to
c475e2f
Compare
9ba3bf1
to
9c4090e
Compare
9c4090e
to
5363295
Compare
5363295
to
665e365
Compare
…GetCurrentContext
… AsyncContextFrame object
665e365
to
cc4fbd7
Compare
What does this PR do?:
Moves profiler's sampling context into the V8 isolate's
ContinuationPreservedEmbeddedData
(CPED.) In fact, moves it into a private symbol-keyed property within the object as Node.js from version 23 will storeAsyncContextFrame
objects in the CPED.Motivation:
Before this change, we rely on async_hooks in dd-trace-js to update the sampling context on every context switch. It is both somewhat costly to do this on every async context switch and we should also migrate away from async hooks, as profiling is their last user, they'll be deprecated in Node, and they bring their own set of performance overhead by using them.
Additional Notes:
In an R&D week experiment, we concluded that this works. It was not clear whether:
HandleScope
Global::Get
to get a local for a symbol,Isolate::GetContinuationPreservedEmbeddedData
, andObject::Get
on it with the symbolwill work from a signal handler, but they do, provided we guard them with an explicit GC guard.
The code using this in
dd-trace-js
'wall.js
sets the context onAsyncLocalStorage.{enterWith|run}
, and thebefore
callback ofAsyncHooks.createHook
. With CPED storage enabled, we can eliminate thebefore
callback and "only" keep theAsyncLocalStorage.{enterWith|run}
callbacks – they are the minimum amount of instrumentation needed for the feature to work correctly then.This branch can be tested with the same-named branch in dd-trace-js.
Jira: PROF-11771