diff --git a/paddle/fluid/framework/new_executor/workqueue/nonblocking_threadpool.h b/paddle/fluid/framework/new_executor/workqueue/nonblocking_threadpool.h index 7b3916bafc93eda8cb1afbf54b706e032c5233dd..bc65231abe7371a931f709c9190b55fde24f0543 100644 --- a/paddle/fluid/framework/new_executor/workqueue/nonblocking_threadpool.h +++ b/paddle/fluid/framework/new_executor/workqueue/nonblocking_threadpool.h @@ -409,7 +409,7 @@ class ThreadPoolTempl { return false; } platform::RecordEvent("SleepWaitForWork", - platform::TracerEventType::UserDefined, 2); + platform::TracerEventType::UserDefined, 10); ec_.CommitWait(waiter); blocked_--; return true; diff --git a/paddle/fluid/platform/init.cc b/paddle/fluid/platform/init.cc index 71fd0d20143a08b065eb596d6f5f9ac6531057f4..372bfbce2aca232ca5704fa20f17b0c75359ceba 100644 --- a/paddle/fluid/platform/init.cc +++ b/paddle/fluid/platform/init.cc @@ -28,6 +28,7 @@ limitations under the License. */ #include "paddle/fluid/platform/device/device_wrapper.h" #include "paddle/fluid/platform/device_context.h" #include "paddle/fluid/platform/init.h" +#include "paddle/fluid/platform/os_info.h" #include "paddle/fluid/platform/place.h" #ifdef PADDLE_WITH_XPU @@ -161,6 +162,8 @@ void LoadCustomDevice(const std::string &library_dir) { #endif void InitDevices() { + // set name at the entry point of Paddle + platform::SetCurrentThreadName("MainThread"); // CUPTI attribute should be set before any CUDA context is created (see CUPTI // documentation about CUpti_ActivityAttribute). #ifdef PADDLE_WITH_CUDA diff --git a/paddle/fluid/platform/os_info_test.cc b/paddle/fluid/platform/os_info_test.cc index b309bb985122d8bbe28a8014bca51b4a5a6b9b10..b3311f1d19e6304a0b232cd936397559224e9b96 100644 --- a/paddle/fluid/platform/os_info_test.cc +++ b/paddle/fluid/platform/os_info_test.cc @@ -30,8 +30,7 @@ TEST(ThreadInfo, TestThreadNameUtils) { using paddle::platform::GetCurrentThreadName; using paddle::platform::SetCurrentThreadName; using paddle::platform::GetAllThreadNames; - EXPECT_EQ("unset", GetCurrentThreadName()); - EXPECT_TRUE(SetCurrentThreadName("MainThread")); + SetCurrentThreadName("MainThread"); EXPECT_FALSE(SetCurrentThreadName("MainThread")); auto names = GetAllThreadNames(); EXPECT_TRUE(names.find(GetCurrentThreadStdId()) != names.end()); diff --git a/paddle/fluid/platform/profiler/host_event_recorder.h b/paddle/fluid/platform/profiler/host_event_recorder.h index 49f9362527591744dd0685375e0244673a7b3081..afd4135246556624cb022243e0e98b5ad9f9f6da 100644 --- a/paddle/fluid/platform/profiler/host_event_recorder.h +++ b/paddle/fluid/platform/profiler/host_event_recorder.h @@ -189,7 +189,10 @@ struct ThreadEventSection { class ThreadEventRecorder { public: - ThreadEventRecorder() { thread_id_ = GetCurrentThreadSysId(); } + ThreadEventRecorder() { + thread_id_ = GetCurrentThreadSysId(); + thread_name_ = GetCurrentThreadName(); + } DISABLE_COPY_AND_ASSIGN(ThreadEventRecorder); @@ -202,7 +205,7 @@ class ThreadEventRecorder { ThreadEventSection GatherEvents() { ThreadEventSection thr_sec; - thr_sec.thread_name = GetCurrentThreadName(); + thr_sec.thread_name = thread_name_; thr_sec.thread_id = thread_id_; thr_sec.events = std::move(base_evt_cntr_.Reduce()); return thr_sec; @@ -210,6 +213,7 @@ class ThreadEventRecorder { private: uint64_t thread_id_; + std::string thread_name_; EventContainer base_evt_cntr_; };