Skip to content

Commit

Permalink
Revert "workers,trace_events: set thread name for workers"
Browse files Browse the repository at this point in the history
This reverts commit a24b691.

PR-URL: #21363
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
jasnell committed Jun 16, 2018
1 parent dcad7c9 commit b505d2a
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 51 deletions.
4 changes: 2 additions & 2 deletions src/env-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -598,11 +598,11 @@ inline bool Environment::is_main_thread() const {
return thread_id_ == 0;
}

inline uint64_t Environment::thread_id() const {
inline double Environment::thread_id() const {
return thread_id_;
}

inline void Environment::set_thread_id(uint64_t id) {
inline void Environment::set_thread_id(double id) {
thread_id_ = id;
}

Expand Down
6 changes: 3 additions & 3 deletions src/env.h
Original file line number Diff line number Diff line change
Expand Up @@ -726,8 +726,8 @@ class Environment {
bool is_stopping_worker() const;

inline bool is_main_thread() const;
inline uint64_t thread_id() const;
inline void set_thread_id(uint64_t id);
inline double thread_id() const;
inline void set_thread_id(double id);
inline worker::Worker* worker_context() const;
inline void set_worker_context(worker::Worker* context);
inline void add_sub_worker_context(worker::Worker* context);
Expand Down Expand Up @@ -881,7 +881,7 @@ class Environment {
std::unordered_map<std::string, uint64_t> performance_marks_;

bool can_call_into_js_ = true;
uint64_t thread_id_ = 0;
double thread_id_ = 0;
std::unordered_set<worker::Worker*> sub_worker_contexts_;


Expand Down
15 changes: 3 additions & 12 deletions src/node_worker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
#include "async_wrap.h"
#include "async_wrap-inl.h"

#include <string>

using v8::ArrayBuffer;
using v8::Context;
using v8::Function;
Expand All @@ -32,7 +30,7 @@ namespace worker {

namespace {

uint64_t next_thread_id = 1;
double next_thread_id = 1;
Mutex next_thread_id_mutex;

} // anonymous namespace
Expand All @@ -46,8 +44,7 @@ Worker::Worker(Environment* env, Local<Object> wrap)
}
wrap->Set(env->context(),
env->thread_id_string(),
Number::New(env->isolate(),
static_cast<double>(thread_id_))).FromJust();
Number::New(env->isolate(), thread_id_)).FromJust();

// Set up everything that needs to be set up in the parent environment.
parent_port_ = MessagePort::New(env, env->context());
Expand Down Expand Up @@ -115,11 +112,6 @@ bool Worker::is_stopped() const {
}

void Worker::Run() {
std::string name = "WorkerThread ";
name += std::to_string(thread_id_);
TRACE_EVENT_METADATA1(
"__metadata", "thread_name", "name",
TRACE_STR_COPY(name.c_str()));
MultiIsolatePlatform* platform = isolate_data_->platform();
CHECK_NE(platform, nullptr);

Expand Down Expand Up @@ -426,8 +418,7 @@ void InitWorker(Local<Object> target,
auto thread_id_string = FIXED_ONE_BYTE_STRING(env->isolate(), "threadId");
target->Set(env->context(),
thread_id_string,
Number::New(env->isolate(),
static_cast<double>(env->thread_id()))).FromJust();
Number::New(env->isolate(), env->thread_id())).FromJust();
}

} // anonymous namespace
Expand Down
2 changes: 1 addition & 1 deletion src/node_worker.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class Worker : public AsyncWrap {

bool thread_joined_ = true;
int exit_code_ = 0;
uint64_t thread_id_ = -1;
double thread_id_ = -1;

std::unique_ptr<MessagePortData> child_port_data_;

Expand Down
33 changes: 0 additions & 33 deletions test/parallel/test-trace-events-worker-metadata.js

This file was deleted.

0 comments on commit b505d2a

Please sign in to comment.