ContinuationPreservedEmbedderData-based Node custom labels#153
Merged
Conversation
1cc30b5 to
b4a8986
Compare
Collaborator
Author
|
@gnurizen This is ready for review; please take a look when you're not too busy sailing in the Ionian Sea. |
umanwizard
commented
Sep 25, 2025
Collaborator
|
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. |
gnurizen
reviewed
Sep 26, 2025
| "license": "Apache-2.0", | ||
| "dependencies": { | ||
| "@polarsignals/custom-labels": "^0.2.0", | ||
| "@polarsignals/custom-labels": "^0.3.1", |
Collaborator
There was a problem hiding this comment.
How do I review what changes went into this bump again?
Collaborator
Author
There was a problem hiding this comment.
gnurizen
reviewed
Sep 27, 2025
We are replacing the manually propagated hashmap-based approach with an approach based on stuffing the labels in v8's ContinuationPreservedEmbedderData (see upcoming commit).
dcc57e7 to
457963b
Compare
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. |
gnurizen
reviewed
Sep 29, 2025
gnurizen
reviewed
Sep 29, 2025
gnurizen
reviewed
Sep 29, 2025
gnurizen
reviewed
Sep 29, 2025
gnurizen
approved these changes
Sep 29, 2025
Collaborator
gnurizen
left a comment
There was a problem hiding this comment.
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.
c029c68 to
6c22eed
Compare
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
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.
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_framestrategy for storing and propagating this data (which is the default beginning in Node v24, and requires the--experimental-async-context-frameflag in v22 and v23). This strategy works by storing the stored value in v8'sContinuationPreservedEmbedderData, which causes the runtime itself to handle propagation. We refuse to use the previous defaultAsyncLocalStoragepropagation 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.