Improve naming for prof system thread name option

This commit is contained in:
Yinan Zhang
2020-06-19 15:16:53 -07:00
parent 25e43c6022
commit d460333efb
9 changed files with 38 additions and 40 deletions

View File

@@ -127,7 +127,7 @@ CTL_PROTO(opt_prof_final)
CTL_PROTO(opt_prof_leak)
CTL_PROTO(opt_prof_accum)
CTL_PROTO(opt_prof_recent_alloc_max)
CTL_PROTO(opt_prof_experimental_use_sys_thread_name)
CTL_PROTO(opt_prof_sys_thread_name)
CTL_PROTO(opt_prof_time_res)
CTL_PROTO(opt_zero_realloc)
CTL_PROTO(tcache_create)
@@ -382,11 +382,10 @@ static const ctl_named_node_t opt_node[] = {
{NAME("prof_final"), CTL(opt_prof_final)},
{NAME("prof_leak"), CTL(opt_prof_leak)},
{NAME("prof_accum"), CTL(opt_prof_accum)},
{NAME("prof_recent_alloc_max"), CTL(opt_prof_recent_alloc_max)},
{NAME("prof_experimental_use_sys_thread_name"),
CTL(opt_prof_experimental_use_sys_thread_name)},
{NAME("zero_realloc"), CTL(opt_zero_realloc)},
{NAME("prof_time_resolution"), CTL(opt_prof_time_res)}
{NAME("prof_recent_alloc_max"), CTL(opt_prof_recent_alloc_max)},
{NAME("prof_sys_thread_name"), CTL(opt_prof_sys_thread_name)},
{NAME("prof_time_resolution"), CTL(opt_prof_time_res)},
{NAME("zero_realloc"), CTL(opt_zero_realloc)}
};
static const ctl_named_node_t tcache_node[] = {
@@ -1852,8 +1851,8 @@ CTL_RO_NL_CGEN(config_prof, opt_prof_final, opt_prof_final, bool)
CTL_RO_NL_CGEN(config_prof, opt_prof_leak, opt_prof_leak, bool)
CTL_RO_NL_CGEN(config_prof, opt_prof_recent_alloc_max,
opt_prof_recent_alloc_max, ssize_t)
CTL_RO_NL_CGEN(config_prof, opt_prof_experimental_use_sys_thread_name,
opt_prof_experimental_use_sys_thread_name, bool)
CTL_RO_NL_CGEN(config_prof, opt_prof_sys_thread_name, opt_prof_sys_thread_name,
bool)
CTL_RO_NL_CGEN(config_prof, opt_prof_time_res,
prof_time_res_mode_names[opt_prof_time_res], const char *)
CTL_RO_NL_GEN(opt_zero_realloc,

View File

@@ -1495,9 +1495,8 @@ malloc_conf_init_helper(sc_data_t *sc_data, unsigned bin_shard_sizes[SC_NBINS],
CONF_HANDLE_BOOL(opt_prof_log, "prof_log")
CONF_HANDLE_SSIZE_T(opt_prof_recent_alloc_max,
"prof_recent_alloc_max", -1, SSIZE_MAX)
CONF_HANDLE_BOOL(
opt_prof_experimental_use_sys_thread_name,
"prof_experimental_use_sys_thread_name")
CONF_HANDLE_BOOL(opt_prof_sys_thread_name,
"prof_sys_thread_name")
if (CONF_MATCH("prof_time_resolution")) {
if (CONF_MATCH_VALUE("default")) {
opt_prof_time_res =

View File

@@ -47,7 +47,7 @@ bool opt_prof_final = false;
bool opt_prof_leak = false;
bool opt_prof_accum = false;
char opt_prof_prefix[PROF_DUMP_FILENAME_LEN];
bool opt_prof_experimental_use_sys_thread_name = false;
bool opt_prof_sys_thread_name = false;
/* Accessed via prof_sample_event_handler(). */
static counter_accum_t prof_idump_accumulated;
@@ -197,21 +197,21 @@ prof_thread_name_set_impl(tsd_t *tsd, const char *thread_name) {
}
static int
prof_read_sys_thread_name_impl(char *buf, size_t limit) {
prof_sys_thread_name_read_impl(char *buf, size_t limit) {
#ifdef JEMALLOC_HAVE_PTHREAD_SETNAME_NP
return pthread_getname_np(pthread_self(), buf, limit);
#else
return ENOSYS;
#endif
}
prof_read_sys_thread_name_t *JET_MUTABLE prof_read_sys_thread_name =
prof_read_sys_thread_name_impl;
prof_sys_thread_name_read_t *JET_MUTABLE prof_sys_thread_name_read =
prof_sys_thread_name_read_impl;
static void
prof_fetch_sys_thread_name(tsd_t *tsd) {
prof_sys_thread_name_fetch(tsd_t *tsd) {
#define THREAD_NAME_MAX_LEN 16
char buf[THREAD_NAME_MAX_LEN];
if (!prof_read_sys_thread_name(buf, THREAD_NAME_MAX_LEN)) {
if (!prof_sys_thread_name_read(buf, THREAD_NAME_MAX_LEN)) {
prof_thread_name_set_impl(tsd, buf);
}
#undef THREAD_NAME_MAX_LEN
@@ -220,8 +220,8 @@ prof_fetch_sys_thread_name(tsd_t *tsd) {
void
prof_malloc_sample_object(tsd_t *tsd, const void *ptr, size_t size,
size_t usize, prof_tctx_t *tctx) {
if (opt_prof_experimental_use_sys_thread_name) {
prof_fetch_sys_thread_name(tsd);
if (opt_prof_sys_thread_name) {
prof_sys_thread_name_fetch(tsd);
}
edata_t *edata = emap_edata_lookup(tsd_tsdn(tsd), &arena_emap_global,
@@ -870,7 +870,7 @@ prof_thread_name_get(tsd_t *tsd) {
int
prof_thread_name_set(tsd_t *tsd, const char *thread_name) {
if (opt_prof_experimental_use_sys_thread_name) {
if (opt_prof_sys_thread_name) {
return ENOENT;
} else {
return prof_thread_name_set_impl(tsd, thread_name);