forked from google/pprof-nodejs
-
Notifications
You must be signed in to change notification settings - Fork 6
Store sampling context in the AsyncContextFrame directly #255
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
Draft
szegedi
wants to merge
12
commits into
main
Choose a base branch
from
szegedi/acf-simple
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Overall package sizeSelf size: 1.77 MB Dependency sizes| name | version | self size | total size | |------|---------|-----------|------------| | source-map | 0.7.6 | 185.63 kB | 185.63 kB | | pprof-format | 2.2.1 | 163.06 kB | 163.06 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 |
time-profiler.ts uses it to pass an AsyncLocalStorage (ALS) as the key. This allows retrieval of context through the ALS, and can open a way for additional context features, like custom labels.
bb7b1ea to
11f315e
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?:
AsyncContextFrame(ACF) object in the CPED with a proxy that has an internal field for our sample context.AsyncLocalStorageas the key will allow the sampling context object to be retrieved from JavaScript usingstorage.getStore()on that object. This opens the possibility of implementing custom contexts in dd-trace-js.Motivation:
Simplification and performance. Storing the sampling context directly in the ACF reduces the complexity of having a proxy object. We also no longer need to ensure that the proxy object is updated every time a new async context is created, thus dd-trace-js no longer needs to instrument
AsyncLocalStorage.enterWith, eliminating the need to do any work on context creation or switches.Additional Notes:
While storing the sampling context is now simpler, retrieving it from the signal handler actually got more complex, but that's a tradeoff we should make. Namely, in the signal handler now we need to chase pointers from current isolate to the hash table backing the ACF storage, and then also implement the hash table lookup-by-key. None of these data structures are published by V8, so we're doing raw memory interpretation. They would also need to be updated if V8 internally changes them. (I will probably rewrite the current code to instead declare structs that mirror the memory layout and use that.)
How to test the change?:
TBD