Skip to content

Commit 529d24e

Browse files
jasnelltargos
authored andcommitted
Revert "workers,trace_events: set thread name for workers"
This reverts commit a24b691. PR-URL: #21363 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent e00e5e6 commit 529d24e

File tree

5 files changed

+9
-51
lines changed

5 files changed

+9
-51
lines changed

src/env-inl.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -598,11 +598,11 @@ inline bool Environment::is_main_thread() const {
598598
return thread_id_ == 0;
599599
}
600600

601-
inline uint64_t Environment::thread_id() const {
601+
inline double Environment::thread_id() const {
602602
return thread_id_;
603603
}
604604

605-
inline void Environment::set_thread_id(uint64_t id) {
605+
inline void Environment::set_thread_id(double id) {
606606
thread_id_ = id;
607607
}
608608

src/env.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -726,8 +726,8 @@ class Environment {
726726
bool is_stopping_worker() const;
727727

728728
inline bool is_main_thread() const;
729-
inline uint64_t thread_id() const;
730-
inline void set_thread_id(uint64_t id);
729+
inline double thread_id() const;
730+
inline void set_thread_id(double id);
731731
inline worker::Worker* worker_context() const;
732732
inline void set_worker_context(worker::Worker* context);
733733
inline void add_sub_worker_context(worker::Worker* context);
@@ -881,7 +881,7 @@ class Environment {
881881
std::unordered_map<std::string, uint64_t> performance_marks_;
882882

883883
bool can_call_into_js_ = true;
884-
uint64_t thread_id_ = 0;
884+
double thread_id_ = 0;
885885
std::unordered_set<worker::Worker*> sub_worker_contexts_;
886886

887887

src/node_worker.cc

+3-12
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
#include "async_wrap.h"
1010
#include "async_wrap-inl.h"
1111

12-
#include <string>
13-
1412
using v8::ArrayBuffer;
1513
using v8::Context;
1614
using v8::Function;
@@ -32,7 +30,7 @@ namespace worker {
3230

3331
namespace {
3432

35-
uint64_t next_thread_id = 1;
33+
double next_thread_id = 1;
3634
Mutex next_thread_id_mutex;
3735

3836
} // anonymous namespace
@@ -46,8 +44,7 @@ Worker::Worker(Environment* env, Local<Object> wrap)
4644
}
4745
wrap->Set(env->context(),
4846
env->thread_id_string(),
49-
Number::New(env->isolate(),
50-
static_cast<double>(thread_id_))).FromJust();
47+
Number::New(env->isolate(), thread_id_)).FromJust();
5148

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

117114
void Worker::Run() {
118-
std::string name = "WorkerThread ";
119-
name += std::to_string(thread_id_);
120-
TRACE_EVENT_METADATA1(
121-
"__metadata", "thread_name", "name",
122-
TRACE_STR_COPY(name.c_str()));
123115
MultiIsolatePlatform* platform = isolate_data_->platform();
124116
CHECK_NE(platform, nullptr);
125117

@@ -426,8 +418,7 @@ void InitWorker(Local<Object> target,
426418
auto thread_id_string = FIXED_ONE_BYTE_STRING(env->isolate(), "threadId");
427419
target->Set(env->context(),
428420
thread_id_string,
429-
Number::New(env->isolate(),
430-
static_cast<double>(env->thread_id()))).FromJust();
421+
Number::New(env->isolate(), env->thread_id())).FromJust();
431422
}
432423

433424
} // anonymous namespace

src/node_worker.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class Worker : public AsyncWrap {
6262

6363
bool thread_joined_ = true;
6464
int exit_code_ = 0;
65-
uint64_t thread_id_ = -1;
65+
double thread_id_ = -1;
6666

6767
std::unique_ptr<MessagePortData> child_port_data_;
6868

test/parallel/test-trace-events-worker-metadata.js

-33
This file was deleted.

0 commit comments

Comments
 (0)