Skip to content
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

src: trace_events: support for metadata events #20757

Closed
wants to merge 1 commit into from

Conversation

ofrobots
Copy link
Contributor

@ofrobots ofrobots commented May 15, 2018

Add support for metadata events. At this point they are added to the
main buffer. Emit a metadata event for the main thread.

Metadata events are implicitly enabled when tracing is enabled. They contain information pertaining not to the individual events as they occur but rather about the process and the environment. Trace viewers use this information, e.g. to render thread names.

Example:

Before
image

After:
image

/cc @nodejs/trace-events @nodejs/diagnostics

CI: https://ci.nodejs.org/job/node-test-pull-request/14896/

@nodejs-github-bot nodejs-github-bot added the c++ Issues and PRs that require attention from people who are familiar with C++. label May 15, 2018
@jasnell
Copy link
Member

jasnell commented May 16, 2018

Oh, awesome! You just crossed one of my to-do items off!

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

LGTM.

Do we need to document those somewhere?

@jasnell
Copy link
Member

jasnell commented May 16, 2018

@mcollina ... I'll be doing a complete rework of the tracing.md documentation very soon.

@@ -4545,6 +4545,9 @@ inline int Start(Isolate* isolate, IsolateData* isolate_data,
Environment env(isolate_data, context, v8_platform.GetTracingAgent());
env.Start(argc, argv, exec_argc, exec_argv, v8_is_profiling);

TRACE_EVENT_METADATA1("__metadata", "thread_name", "name",
"JavaScriptMainThread");
Copy link
Member

Choose a reason for hiding this comment

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

Given that trace events can be enabled after this point, perhaps we should move this to ensure that it's always emitted when tracing is first turned on?

Copy link
Member

Choose a reason for hiding this comment

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

fwiw... I plan on doing to same to emit some information about which node.js version is being traced

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Given that trace events can be enabled after this point, perhaps we should move this to ensure that it's always emitted when tracing is first turned on?

I think the right way to go here would be to address the TODO I already added to the code regarding metadata events being kept in a separate buffer of their own and being emitted on each flush of the trace buffer. That would address the case you mention (tracing turned on later) and more (streaming). I think the emit of the event should should stay where it logically make sense. For example, when we create a thread, we should emit the event at that location rather than artificially moving the emit to a point to better align with the lifecycle of tracing.

I plan to implement this secondary buffer for metadata events in a follow-on. I think it will address the issue.

fwiw... I plan on doing to same to emit some information about which node.js version is being traced

👍

@ofrobots
Copy link
Contributor Author

New CI after rebase: https://ci.nodejs.org/job/node-test-pull-request/14937/

@BridgeAR BridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label May 18, 2018
@BridgeAR
Copy link
Member

BridgeAR commented May 18, 2018

Running Windows again: https://ci.nodejs.org/job/node-test-commit-windows-fanned/18094/

(All other failures are related due to a bug in our http2 code).

Add support for metadata events. At this point they are added to the
main buffer. Emit a metadata event for the main thread.
@ofrobots
Copy link
Contributor Author

Thanks. Landed in 3ff723f.

@ofrobots ofrobots closed this May 18, 2018
@ofrobots ofrobots deleted the metadata-events branch May 18, 2018 17:43
ofrobots added a commit that referenced this pull request May 18, 2018
Add support for metadata events. At this point they are added to the
main buffer. Emit a metadata event for the main thread.

PR-URL: #20757
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
MylesBorins pushed a commit that referenced this pull request May 22, 2018
Add support for metadata events. At this point they are added to the
main buffer. Emit a metadata event for the main thread.

PR-URL: #20757
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
@addaleax addaleax mentioned this pull request May 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants