⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Conversation

@szegedi
Copy link

@szegedi szegedi commented Jan 15, 2026

What does this PR do?:

  • Discards the CPED approach where we replace the AsyncContextFrame (ACF) object in the CPED with a proxy that has an internal field for our sample context.
  • Instead, adopts an approach where the sample context is stored directly in the ACF map under an arbitrary key.
  • It is possible to pass in a key externally. Passing in an AsyncLocalStorage as the key will allow the sampling context object to be retrieved from JavaScript using storage.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

@github-actions
Copy link

github-actions bot commented Jan 15, 2026

Overall package size

Self size: 1.77 MB
Deduped: 2.15 MB
No deduping: 2.15 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.
@szegedi szegedi force-pushed the szegedi/acf-simple branch from bb7b1ea to 11f315e Compare January 19, 2026 15:01
@pr-commenter
Copy link

pr-commenter bot commented Jan 19, 2026

Benchmarks

Benchmark execution time: 2026-01-19 15:09:38

Comparing candidate commit 11f315e in PR branch szegedi/acf-simple with baseline commit 947f5cf in branch main.

Found 0 performance improvements and 0 performance regressions! Performance is the same for 90 metrics, 30 unstable metrics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants