mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-07-23 21:23:06 +00:00
Inline the storage for thread name in prof_tdata_t.
The previous approach managed the thread name in a separate buffer, which causes races because the thread name update (triggered by new samples) can happen at the same time as prof dumping (which reads the thread names) -- these two operations are under separate locks to avoid blocking each other. Implemented the thread name storage as part of the tdata struct, which resolves the lifetime issue and also avoids internal alloc / dalloc during prof_sample.
This commit is contained in:
@@ -462,12 +462,17 @@ prof_sys_thread_name_read_t *JET_MUTABLE prof_sys_thread_name_read =
|
||||
|
||||
void
|
||||
prof_sys_thread_name_fetch(tsd_t *tsd) {
|
||||
#define THREAD_NAME_MAX_LEN 16
|
||||
char buf[THREAD_NAME_MAX_LEN];
|
||||
if (!prof_sys_thread_name_read(buf, THREAD_NAME_MAX_LEN)) {
|
||||
prof_thread_name_set_impl(tsd, buf);
|
||||
prof_tdata_t *tdata = prof_tdata_get(tsd, true);
|
||||
if (tdata == NULL) {
|
||||
return;
|
||||
}
|
||||
#undef THREAD_NAME_MAX_LEN
|
||||
|
||||
if (prof_sys_thread_name_read(tdata->thread_name,
|
||||
PROF_THREAD_NAME_MAX_LEN) != 0) {
|
||||
prof_thread_name_clear(tdata);
|
||||
}
|
||||
|
||||
tdata->thread_name[PROF_THREAD_NAME_MAX_LEN - 1] = '\0';
|
||||
}
|
||||
|
||||
int
|
||||
|
||||
Reference in New Issue
Block a user