-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
process: delay and simplify the setup of async hooks trace events #26062
Conversation
I think I missed something. Why is this? They should be available. |
@jasnell Right – it’s just the JS module that’s not accessible… Is there a test for this code? I think that should have failed in CI if this PR breaks trace_events + Workers, but it looks like everything passed here |
@addaleax I don't think there is a test, it could be added but I don't think the dynamic switch can be tested in workers since dynamically enabling the category requires the trace_events module. I could add the preparation code to the worker bootstrap script though, at least that allows us to test the initial enabling of the events. |
Reasons: - Moves more environment-dependent setup out of bootstrap/node.js - No async operations should be done before the call to the setup functions in pre_execution.js so no async hooks should be triggered before that. Therefore it is safe to delay the setup until then.
- Remove `trace_category_state` from `Environment` - since this is only accessed in the bootstrap process and later in the trace category update handler, we could just pass the initial values into JS land via the trace_events binding, and pass the dynamic values directly to the handler later, instead of accessing them out-of-band via the AliasedBuffer. - Instead of creating the hooks directly in `trace_events_async_hooks.js`, export the hook factory and create the hooks in trace category state toggle.
8018819
to
38c772b
Compare
Added hasTracing guards in tests. Not sure why the CI complained about missing dynamically linked deps and libc, let's see what happens in a new CI: https://ci.nodejs.org/job/node-test-pull-request/20907/ |
73eaecb
to
400c370
Compare
@richardlau Thanks! I've updated the |
Landed in dec3dad...85df2c4 |
Reasons: - Moves more environment-dependent setup out of bootstrap/node.js - No async operations should be done before the call to the setup functions in pre_execution.js so no async hooks should be triggered before that. Therefore it is safe to delay the setup until then. PR-URL: #26062 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: James M Snell <[email protected]>
- Remove `trace_category_state` from `Environment` - since this is only accessed in the bootstrap process and later in the trace category update handler, we could just pass the initial values into JS land via the trace_events binding, and pass the dynamic values directly to the handler later, instead of accessing them out-of-band via the AliasedBuffer. - Instead of creating the hooks directly in `trace_events_async_hooks.js`, export the hook factory and create the hooks in trace category state toggle. PR-URL: #26062 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: James M Snell <[email protected]>
PR-URL: #26062 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: James M Snell <[email protected]>
PR-URL: #26062 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: James M Snell <[email protected]>
Reasons: - Moves more environment-dependent setup out of bootstrap/node.js - No async operations should be done before the call to the setup functions in pre_execution.js so no async hooks should be triggered before that. Therefore it is safe to delay the setup until then. PR-URL: #26062 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: James M Snell <[email protected]>
- Remove `trace_category_state` from `Environment` - since this is only accessed in the bootstrap process and later in the trace category update handler, we could just pass the initial values into JS land via the trace_events binding, and pass the dynamic values directly to the handler later, instead of accessing them out-of-band via the AliasedBuffer. - Instead of creating the hooks directly in `trace_events_async_hooks.js`, export the hook factory and create the hooks in trace category state toggle. PR-URL: #26062 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: James M Snell <[email protected]>
PR-URL: #26062 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: James M Snell <[email protected]>
PR-URL: #26062 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: James M Snell <[email protected]>
Reasons: - Moves more environment-dependent setup out of bootstrap/node.js - No async operations should be done before the call to the setup functions in pre_execution.js so no async hooks should be triggered before that. Therefore it is safe to delay the setup until then. PR-URL: #26062 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: James M Snell <[email protected]>
- Remove `trace_category_state` from `Environment` - since this is only accessed in the bootstrap process and later in the trace category update handler, we could just pass the initial values into JS land via the trace_events binding, and pass the dynamic values directly to the handler later, instead of accessing them out-of-band via the AliasedBuffer. - Instead of creating the hooks directly in `trace_events_async_hooks.js`, export the hook factory and create the hooks in trace category state toggle. PR-URL: #26062 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: James M Snell <[email protected]>
PR-URL: #26062 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: James M Snell <[email protected]>
PR-URL: #26062 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: James M Snell <[email protected]>
src: move async hooks trace events setup to pre_execution.js
Reasons:
the setup functions in pre_execution.js so no async hooks should be
triggered before that. Therefore it is safe to delay the setup
until then.
process: simplify the setup of async hooks trace events
trace_category_state
fromEnvironment
- since this isonly accessed in the bootstrap process and later in the
trace category update handler, we could just pass the initial
values into JS land via the trace_events binding, and pass
the dynamic values directly to the handler later, instead of
accessing them out-of-band via the AliasedBuffer.
trace_events_async_hooks.js
, export the hook factory andcreate the hooks in trace category state toggle.
test: add test for node.async_hooks tracing in workers
test: add test for dynamically enabling node.async_hooks tracing
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes