Skip to content

ContinuationPreservedEmbedderData-based Node custom labels#153

Merged
umanwizard merged 2 commits into
mainfrom
btv/test-cped
Sep 29, 2025
Merged

ContinuationPreservedEmbedderData-based Node custom labels#153
umanwizard merged 2 commits into
mainfrom
btv/test-cped

Conversation

@umanwizard
Copy link
Copy Markdown
Collaborator

@umanwizard umanwizard commented Sep 24, 2025

This totally removes the previous hashmap-based labels experiment, which was found to be too slow in practice, and replaces it with storing labels in Node's AsyncLocalStorage. We require that Node use its async_context_frame strategy for storing and propagating this data (which is the default beginning in Node v24, and requires the --experimental-async-context-frame flag in v22 and v23). This strategy works by storing the stored value in v8's ContinuationPreservedEmbedderData, which causes the runtime itself to handle propagation. We refuse to use the previous default AsyncLocalStorage propagation strategy, which is basically similar to our own (failed) approach.

The internal v8 data structures we walk are explained in the comment on maybe_add_node_custom_labels; everything else is basically similar.

@umanwizard umanwizard marked this pull request as ready for review September 24, 2025 13:39
@umanwizard umanwizard force-pushed the btv/test-cped branch 2 times, most recently from 1cc30b5 to b4a8986 Compare September 25, 2025 14:23
@umanwizard umanwizard changed the title don't merge ContinuationPreservedEmbedderData-based Node custom labels Sep 25, 2025
@umanwizard
Copy link
Copy Markdown
Collaborator Author

@gnurizen This is ready for review; please take a look when you're not too busy sailing in the Ionian Sea.

Comment thread support/ebpf/interpreter_dispatcher.ebpf.c Outdated
@gnurizen
Copy link
Copy Markdown
Collaborator

gnurizen commented Sep 26, 2025

Can we separate this into two PRs/commits one to remove hashmap and one to add the new approach? That will make reviewing and more importantly upstreaming this a lot easier. Claude should be able to make short work of it if the git-fu gets tedious.

"license": "Apache-2.0",
"dependencies": {
"@polarsignals/custom-labels": "^0.2.0",
"@polarsignals/custom-labels": "^0.3.1",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do I review what changes went into this bump again?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread tools/complete_offsets.csv Outdated
We are replacing the manually propagated hashmap-based approach with
an approach based on stuffing the labels in v8's
ContinuationPreservedEmbedderData (see upcoming commit).
@umanwizard
Copy link
Copy Markdown
Collaborator Author

@gnurizen I broke it into two commits: one which removes the old approach (except tests, which haven't changed) and one which re-adds the new approach.

Comment thread interpreter/customlabels/integrationtests/node_test.go
Comment thread interpreter/nodev8/v8.go
Comment thread support/ebpf/interpreter_dispatcher.ebpf.c Outdated
Comment thread support/ebpf/interpreter_dispatcher.ebpf.c Outdated
Copy link
Copy Markdown
Collaborator

@gnurizen gnurizen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, just a couple nits, nice work!

Introduce custom labels stored in Node's AsyncLocalStorage. We require
that Node use its async_context_frame strategy for storing and
propagating this data (which is the default beginning in Node v24, and
requires the --experimental-async-context-frame flag in v22 and
v23). This strategy works by storing the stored value in v8's
ContinuationPreservedEmbedderData, which causes the runtime itself to
handle propagation. We refuse to use the previous default
AsyncLocalStorage propagation strategy, which is basically similar to
our prior approach, which was rejected due to being too slow.

The internal v8 data structures we walk are explained in the comment
on maybe_add_node_custom_labels.
@umanwizard umanwizard merged commit bff0d78 into main Sep 29, 2025
28 checks passed
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