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

tracing: refactor tracing state ownership #23781

Closed
wants to merge 3 commits into from

Conversation

addaleax
Copy link
Member

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • documentation is changed or added
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. labels Oct 20, 2018
@richardlau
Copy link
Member

Does the second commit need tests?

@@ -13,7 +13,8 @@ const {
ERR_INVALID_ARG_TYPE
} = require('internal/errors').codes;

if (!hasTracing)
const { isMainThread } = require('internal/worker');
if (!hasTracing || !isMainThread)
Copy link
Member

Choose a reason for hiding this comment

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

A note about this limitation should be added in tracing.md also

Copy link
Member Author

Choose a reason for hiding this comment

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

Done!

Copy link
Contributor

@refack refack left a comment

Choose a reason for hiding this comment

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

Left some comments and questions.

src/env.cc Outdated
if (!env_->is_main_thread()) {
// Ideally, we’d have a consistent story that treats all threads/Environment
// instances equally here. However, tracing is essentially global, and this
// callback is callback from whichever thread calls `StartTracing()` or
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// callback is callback from whichever thread calls `StartTracing()` or
// callback is called from whichever thread calls `StartTracing()` or

or invoked or called back

Copy link
Member Author

Choose a reason for hiding this comment

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

Done!

src/env.cc Outdated
@@ -182,10 +191,9 @@ Environment::Environment(IsolateData* isolate_data,

AssignToContext(context, ContextInfo(""));

if (tracing_agent_writer_ != nullptr) {
if (tracing::AgentWriterHandle* writer = GetTracingAgentWriter()) {
trace_state_observer_.reset(new TrackingTraceStateObserver(this));
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
trace_state_observer_.reset(new TrackingTraceStateObserver(this));
trace_state_observer_ = std::make_unique<TrackingTraceStateObserver>(this);

Copy link
Member Author

Choose a reason for hiding this comment

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

Done!

src/env.cc Show resolved Hide resolved
src/env.cc Show resolved Hide resolved
src/inspector/tracing_agent.cc Show resolved Hide resolved
src/node_worker.cc Show resolved Hide resolved
src/node.cc Show resolved Hide resolved
src/node_internals.h Show resolved Hide resolved
As per the conversation in nodejs#22513,
this is essentially global, and adding this on the Environment
is generally just confusing.

Refs: nodejs#22513
Fixes: nodejs#22767
Forbid modifying tracing state from worker threads, either
through the built-in module or inspector sessions, since
the main thread owns all global state, and at least
the `async_hooks` integration is definitely not thread
safe in its current state.
@addaleax
Copy link
Member Author

@mmarchini mmarchini added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Oct 23, 2018
@addaleax
Copy link
Member Author

@mmarchini
Copy link
Contributor

Landed in d568b53...5d80ae3

@mmarchini mmarchini closed this Oct 24, 2018
mmarchini pushed a commit that referenced this pull request Oct 24, 2018
As per the conversation in #22513,
this is essentially global, and adding this on the Environment
is generally just confusing.

Refs: #22513
Fixes: #22767

PR-URL: #23781
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Matheus Marchini <mat@mmarchini.me>
mmarchini pushed a commit that referenced this pull request Oct 24, 2018
Forbid modifying tracing state from worker threads, either
through the built-in module or inspector sessions, since
the main thread owns all global state, and at least
the `async_hooks` integration is definitely not thread
safe in its current state.

PR-URL: #23781
Fixes: #22767
Refs: #22513
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Matheus Marchini <mat@mmarchini.me>
@addaleax addaleax deleted the env-tracing-writer branch October 24, 2018 17:56
targos pushed a commit that referenced this pull request Oct 27, 2018
As per the conversation in #22513,
this is essentially global, and adding this on the Environment
is generally just confusing.

Refs: #22513
Fixes: #22767

PR-URL: #23781
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Matheus Marchini <mat@mmarchini.me>
targos pushed a commit that referenced this pull request Oct 27, 2018
Forbid modifying tracing state from worker threads, either
through the built-in module or inspector sessions, since
the main thread owns all global state, and at least
the `async_hooks` integration is definitely not thread
safe in its current state.

PR-URL: #23781
Fixes: #22767
Refs: #22513
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Matheus Marchini <mat@mmarchini.me>
@targos
Copy link
Member

targos commented Nov 1, 2018

Marking dont-land-on-v11.x until nodejs/build#1542 is fixed

@targos targos mentioned this pull request Nov 1, 2018
2 tasks
targos pushed a commit that referenced this pull request Nov 18, 2018
As per the conversation in #22513,
this is essentially global, and adding this on the Environment
is generally just confusing.

Refs: #22513
Fixes: #22767

PR-URL: #23781
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Matheus Marchini <mat@mmarchini.me>
targos pushed a commit that referenced this pull request Nov 18, 2018
Forbid modifying tracing state from worker threads, either
through the built-in module or inspector sessions, since
the main thread owns all global state, and at least
the `async_hooks` integration is definitely not thread
safe in its current state.

PR-URL: #23781
Fixes: #22767
Refs: #22513
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Matheus Marchini <mat@mmarchini.me>
rvagg pushed a commit that referenced this pull request Nov 28, 2018
As per the conversation in #22513,
this is essentially global, and adding this on the Environment
is generally just confusing.

Refs: #22513
Fixes: #22767

PR-URL: #23781
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Matheus Marchini <mat@mmarchini.me>
rvagg pushed a commit that referenced this pull request Nov 28, 2018
Forbid modifying tracing state from worker threads, either
through the built-in module or inspector sessions, since
the main thread owns all global state, and at least
the `async_hooks` integration is definitely not thread
safe in its current state.

PR-URL: #23781
Fixes: #22767
Refs: #22513
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Matheus Marchini <mat@mmarchini.me>
@BridgeAR BridgeAR mentioned this pull request Dec 5, 2018
4 tasks
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++. lib / src Issues and PRs related to general changes in the lib or src directory.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants