| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
@legendecas @RaisinTen Hi, can we just trace the total time of work. the code is as follows. void ThreadPoolWork::ScheduleWork() {
env_->IncreaseWaitingRequestCounter();
TRACE_EVENT_NESTABLE_ASYNC_BEGIN0(...);
int status = uv_queue_work(
env_->event_loop(),
&work_req_,
[](uv_work_t* req) {
ThreadPoolWork* self = ContainerOf(&ThreadPoolWork::work_req_, req);
self->DoThreadPoolWork();
},
[](uv_work_t* req, int status) {
ThreadPoolWork* self = ContainerOf(&ThreadPoolWork::work_req_, req);
self->env_->DecreaseWaitingRequestCounter();
TRACE_EVENT_NESTABLE_ASYNC_END1(...);
self->AfterThreadPoolWork(status);
});
CHECK_EQ(status, 0);
}
Or trace all the time by two different event type. void ThreadPoolWork::ScheduleWork() {
env_->IncreaseWaitingRequestCounter();
TRACE_EVENT_NESTABLE_ASYNC_BEGIN0(...);
int status = uv_queue_work(
env_->event_loop(),
&work_req_,
[](uv_work_t* req) {
ThreadPoolWork* self = ContainerOf(&ThreadPoolWork::work_req_, req);
TRACE_EVENT_BEGIN(...);
self->DoThreadPoolWork();
TRACE_EVENT_END(...);
},
[](uv_work_t* req, int status) {
ThreadPoolWork* self = ContainerOf(&ThreadPoolWork::work_req_, req);
self->env_->DecreaseWaitingRequestCounter();
TRACE_EVENT_NESTABLE_ASYNC_END1(...);
self->AfterThreadPoolWork(status);
});
CHECK_EQ(status, 0);
}
|
Sorry, something went wrong.
|
I'd still find that tracing the synchronous event is important. So the latter alternative is LGTM. |
Sorry, something went wrong.
|
It seems we can not use TRACE_EVENT_BEGIN0 and TRACE_EVENT_END0 in another thread, i will take a look later. |
Sorry, something went wrong.
|
@legendecas Hi, it seems the TRACE_EVENT_xx is not thread-safe, so i record the time of synchronous API call in args field of async event. what do you think ? |
Sorry, something went wrong.
|
@theanarkh The macros are declared to be thread-safe. If there is any problem related to thread safety, it should be fixed. I'd find the problem here is related to the incomplete shutdown -- e.g. the global state of the tracing controller is not reset after the platform is shut down https://github.com/nodejs/node/blob/main/src/tracing/trace_event.cc#L8. This global state is used in the macro expansion: https://github.com/nodejs/node/blob/main/src/tracing/trace_event.h#L474. We should properly shut down the platform with the tracing global state. |
Sorry, something went wrong.
|
Do you mean this test case https://github.com/nodejs/node/actions/runs/3054446637/jobs/4926355622 ? I remember when i change common.platformTimeout(10) to common.platformTimeout(100), the test exits normally🤔. |
Sorry, something went wrong.
|
@theanarkh yeah, IIUC that test case is exactly testing a premature exit while the async work is still in progress. |
Sorry, something went wrong.
Sorry, something went wrong.
When the process exits, there may be tasks in the thread pool that need to access data in the platform, such as trace agent. So make sure the thread pool exits first. see #44458 PR-URL: #45226 Refs: #44458 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
PR-URL: #44458 Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
When the process exits, there may be tasks in the thread pool that need to access data in the platform, such as trace agent. So make sure the thread pool exits first. see #44458 PR-URL: #45226 Refs: #44458 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
PR-URL: #44458 Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
When the process exits, there may be tasks in the thread pool that need to access data in the platform, such as trace agent. So make sure the thread pool exits first. see #44458 PR-URL: #45226 Refs: #44458 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
PR-URL: #44458 Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
When the process exits, there may be tasks in the thread pool that need to access data in the platform, such as trace agent. So make sure the thread pool exits first. see #44458 PR-URL: #45226 Refs: #44458 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
PR-URL: #44458 Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
| Back | FazBrowse Home | New Git URL |
trace threadpool events, such as APIs of Blob, zlib, crypto and node_api.