mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-07-31 07:28:02 +03: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:
parent
6cab460a45
commit
ce0b7ab6c8
11 changed files with 120 additions and 103 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue