Rename prof.dump_prefix to prof.prefix

This better aligns with our naming convention.  The option has not been included
in any upstream release yet.
This commit is contained in:
Qi Wang 2021-08-12 15:48:02 -07:00 committed by Qi Wang
parent 6a01600712
commit 5884a076fb
5 changed files with 37 additions and 44 deletions

View File

@ -1410,8 +1410,7 @@ malloc_conf = "xmalloc:true";]]></programlisting>
primarily useful for disabling the automatic final heap dump (which primarily useful for disabling the automatic final heap dump (which
also disables leak reporting, if enabled). The default prefix is also disables leak reporting, if enabled). The default prefix is
<filename>jeprof</filename>. This prefix value can be overriden by <filename>jeprof</filename>. This prefix value can be overriden by
<link <link linkend="prof.prefix"><mallctl>prof.prefix</mallctl></link>.
linkend="prof.dump_prefix"><mallctl>prof.dump_prefix</mallctl></link>.
</para></listitem> </para></listitem>
</varlistentry> </varlistentry>
@ -1492,8 +1491,7 @@ malloc_conf = "xmalloc:true";]]></programlisting>
where <literal>&lt;prefix&gt;</literal> is controlled by the where <literal>&lt;prefix&gt;</literal> is controlled by the
<link <link
linkend="opt.prof_prefix"><mallctl>opt.prof_prefix</mallctl></link> and linkend="opt.prof_prefix"><mallctl>opt.prof_prefix</mallctl></link> and
<link <link linkend="prof.prefix"><mallctl>prof.prefix</mallctl></link>
linkend="prof.dump_prefix"><mallctl>prof.dump_prefix</mallctl></link>
options. By default, interval-triggered profile dumping is disabled options. By default, interval-triggered profile dumping is disabled
(encoded as -1). (encoded as -1).
</para></listitem> </para></listitem>
@ -1527,8 +1525,7 @@ malloc_conf = "xmalloc:true";]]></programlisting>
<filename>&lt;prefix&gt;.&lt;pid&gt;.&lt;seq&gt;.f.heap</filename>, <filename>&lt;prefix&gt;.&lt;pid&gt;.&lt;seq&gt;.f.heap</filename>,
where <literal>&lt;prefix&gt;</literal> is controlled by the <link where <literal>&lt;prefix&gt;</literal> is controlled by the <link
linkend="opt.prof_prefix"><mallctl>opt.prof_prefix</mallctl></link> and linkend="opt.prof_prefix"><mallctl>opt.prof_prefix</mallctl></link> and
<link <link linkend="prof.prefix"><mallctl>prof.prefix</mallctl></link>
linkend="prof.dump_prefix"><mallctl>prof.dump_prefix</mallctl></link>
options. Note that <function>atexit()</function> may allocate options. Note that <function>atexit()</function> may allocate
memory during application initialization and then deadlock internally memory during application initialization and then deadlock internally
when jemalloc in turn calls <function>atexit()</function>, so when jemalloc in turn calls <function>atexit()</function>, so
@ -2398,16 +2395,14 @@ struct extent_hooks_s {
is specified, to a file according to the pattern is specified, to a file according to the pattern
<filename>&lt;prefix&gt;.&lt;pid&gt;.&lt;seq&gt;.m&lt;mseq&gt;.heap</filename>, <filename>&lt;prefix&gt;.&lt;pid&gt;.&lt;seq&gt;.m&lt;mseq&gt;.heap</filename>,
where <literal>&lt;prefix&gt;</literal> is controlled by the where <literal>&lt;prefix&gt;</literal> is controlled by the
<link <link linkend="opt.prof_prefix"><mallctl>opt.prof_prefix</mallctl></link>
linkend="opt.prof_prefix"><mallctl>opt.prof_prefix</mallctl></link> and and <link linkend="prof.prefix"><mallctl>prof.prefix</mallctl></link>
<link
linkend="prof.dump_prefix"><mallctl>prof.dump_prefix</mallctl></link>
options.</para></listitem> options.</para></listitem>
</varlistentry> </varlistentry>
<varlistentry id="prof.dump_prefix"> <varlistentry id="prof.prefix">
<term> <term>
<mallctl>prof.dump_prefix</mallctl> <mallctl>prof.prefix</mallctl>
(<type>const char *</type>) (<type>const char *</type>)
<literal>-w</literal> <literal>-w</literal>
[<option>--enable-prof</option>] [<option>--enable-prof</option>]
@ -2433,8 +2428,7 @@ struct extent_hooks_s {
<filename>&lt;prefix&gt;.&lt;pid&gt;.&lt;seq&gt;.u&lt;useq&gt;.heap</filename>, <filename>&lt;prefix&gt;.&lt;pid&gt;.&lt;seq&gt;.u&lt;useq&gt;.heap</filename>,
where <literal>&lt;prefix&gt;</literal> is controlled by the <link where <literal>&lt;prefix&gt;</literal> is controlled by the <link
linkend="opt.prof_prefix"><mallctl>opt.prof_prefix</mallctl></link> and linkend="opt.prof_prefix"><mallctl>opt.prof_prefix</mallctl></link> and
<link <link linkend="prof.prefix"><mallctl>prof.prefix</mallctl></link>
linkend="prof.dump_prefix"><mallctl>prof.dump_prefix</mallctl></link>
options.</para></listitem> options.</para></listitem>
</varlistentry> </varlistentry>

View File

@ -10,7 +10,7 @@ void prof_unwind_init();
void prof_sys_thread_name_fetch(tsd_t *tsd); void prof_sys_thread_name_fetch(tsd_t *tsd);
int prof_getpid(void); int prof_getpid(void);
void prof_get_default_filename(tsdn_t *tsdn, char *filename, uint64_t ind); void prof_get_default_filename(tsdn_t *tsdn, char *filename, uint64_t ind);
bool prof_dump_prefix_set(tsdn_t *tsdn, const char *prefix); bool prof_prefix_set(tsdn_t *tsdn, const char *prefix);
void prof_fdump_impl(tsd_t *tsd); void prof_fdump_impl(tsd_t *tsd);
void prof_idump_impl(tsd_t *tsd); void prof_idump_impl(tsd_t *tsd);
bool prof_mdump_impl(tsd_t *tsd, const char *filename); bool prof_mdump_impl(tsd_t *tsd, const char *filename);

View File

@ -187,7 +187,7 @@ CTL_PROTO(prof_thread_active_init)
CTL_PROTO(prof_active) CTL_PROTO(prof_active)
CTL_PROTO(prof_dump) CTL_PROTO(prof_dump)
CTL_PROTO(prof_gdump) CTL_PROTO(prof_gdump)
CTL_PROTO(prof_dump_prefix) CTL_PROTO(prof_prefix)
CTL_PROTO(prof_reset) CTL_PROTO(prof_reset)
CTL_PROTO(prof_interval) CTL_PROTO(prof_interval)
CTL_PROTO(lg_prof_sample) CTL_PROTO(lg_prof_sample)
@ -578,7 +578,7 @@ static const ctl_named_node_t prof_node[] = {
{NAME("active"), CTL(prof_active)}, {NAME("active"), CTL(prof_active)},
{NAME("dump"), CTL(prof_dump)}, {NAME("dump"), CTL(prof_dump)},
{NAME("gdump"), CTL(prof_gdump)}, {NAME("gdump"), CTL(prof_gdump)},
{NAME("dump_prefix"), CTL(prof_dump_prefix)}, {NAME("prefix"), CTL(prof_prefix)},
{NAME("reset"), CTL(prof_reset)}, {NAME("reset"), CTL(prof_reset)},
{NAME("interval"), CTL(prof_interval)}, {NAME("interval"), CTL(prof_interval)},
{NAME("lg_sample"), CTL(lg_prof_sample)}, {NAME("lg_sample"), CTL(lg_prof_sample)},
@ -3227,7 +3227,7 @@ label_return:
} }
static int static int
prof_dump_prefix_ctl(tsd_t *tsd, const size_t *mib, size_t miblen, prof_prefix_ctl(tsd_t *tsd, const size_t *mib, size_t miblen,
void *oldp, size_t *oldlenp, void *newp, size_t newlen) { void *oldp, size_t *oldlenp, void *newp, size_t newlen) {
int ret; int ret;
const char *prefix = NULL; const char *prefix = NULL;
@ -3240,7 +3240,7 @@ prof_dump_prefix_ctl(tsd_t *tsd, const size_t *mib, size_t miblen,
WRITEONLY(); WRITEONLY();
WRITE(prefix, const char *); WRITE(prefix, const char *);
ret = prof_dump_prefix_set(tsd_tsdn(tsd), prefix) ? EFAULT : 0; ret = prof_prefix_set(tsd_tsdn(tsd), prefix) ? EFAULT : 0;
label_return: label_return:
malloc_mutex_unlock(tsd_tsdn(tsd), &ctl_mtx); malloc_mutex_unlock(tsd_tsdn(tsd), &ctl_mtx);
return ret; return ret;

View File

@ -34,7 +34,7 @@ static uint64_t prof_dump_iseq;
static uint64_t prof_dump_mseq; static uint64_t prof_dump_mseq;
static uint64_t prof_dump_useq; static uint64_t prof_dump_useq;
static char *prof_dump_prefix = NULL; static char *prof_prefix = NULL;
/* The fallback allocator profiling functionality will use. */ /* The fallback allocator profiling functionality will use. */
base_t *prof_base; base_t *prof_base;
@ -524,16 +524,16 @@ prof_strncpy(char *UNUSED dest, const char *UNUSED src, size_t UNUSED size) {
} }
static const char * static const char *
prof_dump_prefix_get(tsdn_t* tsdn) { prof_prefix_get(tsdn_t* tsdn) {
malloc_mutex_assert_owner(tsdn, &prof_dump_filename_mtx); malloc_mutex_assert_owner(tsdn, &prof_dump_filename_mtx);
return prof_dump_prefix == NULL ? opt_prof_prefix : prof_dump_prefix; return prof_prefix == NULL ? opt_prof_prefix : prof_prefix;
} }
static bool static bool
prof_dump_prefix_is_empty(tsdn_t *tsdn) { prof_prefix_is_empty(tsdn_t *tsdn) {
malloc_mutex_lock(tsdn, &prof_dump_filename_mtx); malloc_mutex_lock(tsdn, &prof_dump_filename_mtx);
bool ret = (prof_dump_prefix_get(tsdn)[0] == '\0'); bool ret = (prof_prefix_get(tsdn)[0] == '\0');
malloc_mutex_unlock(tsdn, &prof_dump_filename_mtx); malloc_mutex_unlock(tsdn, &prof_dump_filename_mtx);
return ret; return ret;
} }
@ -545,18 +545,18 @@ prof_dump_filename(tsd_t *tsd, char *filename, char v, uint64_t vseq) {
cassert(config_prof); cassert(config_prof);
assert(tsd_reentrancy_level_get(tsd) == 0); assert(tsd_reentrancy_level_get(tsd) == 0);
const char *prof_prefix = prof_dump_prefix_get(tsd_tsdn(tsd)); const char *prof_prefix = prof_prefix_get(tsd_tsdn(tsd));
if (vseq != VSEQ_INVALID) { if (vseq != VSEQ_INVALID) {
/* "<prefix>.<pid>.<seq>.v<vseq>.heap" */ /* "<prefix>.<pid>.<seq>.v<vseq>.heap" */
malloc_snprintf(filename, DUMP_FILENAME_BUFSIZE, malloc_snprintf(filename, DUMP_FILENAME_BUFSIZE,
"%s.%d.%"FMTu64".%c%"FMTu64".heap", "%s.%d.%"FMTu64".%c%"FMTu64".heap", prof_prefix,
prof_prefix, prof_getpid(), prof_dump_seq, v, vseq); prof_getpid(), prof_dump_seq, v, vseq);
} else { } else {
/* "<prefix>.<pid>.<seq>.<v>.heap" */ /* "<prefix>.<pid>.<seq>.<v>.heap" */
malloc_snprintf(filename, DUMP_FILENAME_BUFSIZE, malloc_snprintf(filename, DUMP_FILENAME_BUFSIZE,
"%s.%d.%"FMTu64".%c.heap", "%s.%d.%"FMTu64".%c.heap", prof_prefix,
prof_prefix, prof_getpid(), prof_dump_seq, v); prof_getpid(), prof_dump_seq, v);
} }
prof_dump_seq++; prof_dump_seq++;
} }
@ -565,8 +565,7 @@ void
prof_get_default_filename(tsdn_t *tsdn, char *filename, uint64_t ind) { prof_get_default_filename(tsdn_t *tsdn, char *filename, uint64_t ind) {
malloc_mutex_lock(tsdn, &prof_dump_filename_mtx); malloc_mutex_lock(tsdn, &prof_dump_filename_mtx);
malloc_snprintf(filename, PROF_DUMP_FILENAME_LEN, malloc_snprintf(filename, PROF_DUMP_FILENAME_LEN,
"%s.%d.%"FMTu64".json", prof_dump_prefix_get(tsdn), prof_getpid(), "%s.%d.%"FMTu64".json", prof_prefix_get(tsdn), prof_getpid(), ind);
ind);
malloc_mutex_unlock(tsdn, &prof_dump_filename_mtx); malloc_mutex_unlock(tsdn, &prof_dump_filename_mtx);
} }
@ -574,7 +573,7 @@ void
prof_fdump_impl(tsd_t *tsd) { prof_fdump_impl(tsd_t *tsd) {
char filename[DUMP_FILENAME_BUFSIZE]; char filename[DUMP_FILENAME_BUFSIZE];
assert(!prof_dump_prefix_is_empty(tsd_tsdn(tsd))); assert(!prof_prefix_is_empty(tsd_tsdn(tsd)));
malloc_mutex_lock(tsd_tsdn(tsd), &prof_dump_filename_mtx); malloc_mutex_lock(tsd_tsdn(tsd), &prof_dump_filename_mtx);
prof_dump_filename(tsd, filename, 'f', VSEQ_INVALID); prof_dump_filename(tsd, filename, 'f', VSEQ_INVALID);
malloc_mutex_unlock(tsd_tsdn(tsd), &prof_dump_filename_mtx); malloc_mutex_unlock(tsd_tsdn(tsd), &prof_dump_filename_mtx);
@ -582,11 +581,11 @@ prof_fdump_impl(tsd_t *tsd) {
} }
bool bool
prof_dump_prefix_set(tsdn_t *tsdn, const char *prefix) { prof_prefix_set(tsdn_t *tsdn, const char *prefix) {
cassert(config_prof); cassert(config_prof);
ctl_mtx_assert_held(tsdn); ctl_mtx_assert_held(tsdn);
malloc_mutex_lock(tsdn, &prof_dump_filename_mtx); malloc_mutex_lock(tsdn, &prof_dump_filename_mtx);
if (prof_dump_prefix == NULL) { if (prof_prefix == NULL) {
malloc_mutex_unlock(tsdn, &prof_dump_filename_mtx); malloc_mutex_unlock(tsdn, &prof_dump_filename_mtx);
/* Everything is still guarded by ctl_mtx. */ /* Everything is still guarded by ctl_mtx. */
char *buffer = base_alloc(tsdn, prof_base, char *buffer = base_alloc(tsdn, prof_base,
@ -595,12 +594,12 @@ prof_dump_prefix_set(tsdn_t *tsdn, const char *prefix) {
return true; return true;
} }
malloc_mutex_lock(tsdn, &prof_dump_filename_mtx); malloc_mutex_lock(tsdn, &prof_dump_filename_mtx);
prof_dump_prefix = buffer; prof_prefix = buffer;
} }
assert(prof_dump_prefix != NULL); assert(prof_prefix != NULL);
prof_strncpy(prof_dump_prefix, prefix, PROF_DUMP_FILENAME_LEN - 1); prof_strncpy(prof_prefix, prefix, PROF_DUMP_FILENAME_LEN - 1);
prof_dump_prefix[PROF_DUMP_FILENAME_LEN - 1] = '\0'; prof_prefix[PROF_DUMP_FILENAME_LEN - 1] = '\0';
malloc_mutex_unlock(tsdn, &prof_dump_filename_mtx); malloc_mutex_unlock(tsdn, &prof_dump_filename_mtx);
return false; return false;
@ -609,7 +608,7 @@ prof_dump_prefix_set(tsdn_t *tsdn, const char *prefix) {
void void
prof_idump_impl(tsd_t *tsd) { prof_idump_impl(tsd_t *tsd) {
malloc_mutex_lock(tsd_tsdn(tsd), &prof_dump_filename_mtx); malloc_mutex_lock(tsd_tsdn(tsd), &prof_dump_filename_mtx);
if (prof_dump_prefix_get(tsd_tsdn(tsd))[0] == '\0') { if (prof_prefix_get(tsd_tsdn(tsd))[0] == '\0') {
malloc_mutex_unlock(tsd_tsdn(tsd), &prof_dump_filename_mtx); malloc_mutex_unlock(tsd_tsdn(tsd), &prof_dump_filename_mtx);
return; return;
} }
@ -626,7 +625,7 @@ prof_mdump_impl(tsd_t *tsd, const char *filename) {
if (filename == NULL) { if (filename == NULL) {
/* No filename specified, so automatically generate one. */ /* No filename specified, so automatically generate one. */
malloc_mutex_lock(tsd_tsdn(tsd), &prof_dump_filename_mtx); malloc_mutex_lock(tsd_tsdn(tsd), &prof_dump_filename_mtx);
if (prof_dump_prefix_get(tsd_tsdn(tsd))[0] == '\0') { if (prof_prefix_get(tsd_tsdn(tsd))[0] == '\0') {
malloc_mutex_unlock(tsd_tsdn(tsd), &prof_dump_filename_mtx); malloc_mutex_unlock(tsd_tsdn(tsd), &prof_dump_filename_mtx);
return true; return true;
} }
@ -642,7 +641,7 @@ void
prof_gdump_impl(tsd_t *tsd) { prof_gdump_impl(tsd_t *tsd) {
tsdn_t *tsdn = tsd_tsdn(tsd); tsdn_t *tsdn = tsd_tsdn(tsd);
malloc_mutex_lock(tsdn, &prof_dump_filename_mtx); malloc_mutex_lock(tsdn, &prof_dump_filename_mtx);
if (prof_dump_prefix_get(tsdn)[0] == '\0') { if (prof_prefix_get(tsdn)[0] == '\0') {
malloc_mutex_unlock(tsdn, &prof_dump_filename_mtx); malloc_mutex_unlock(tsdn, &prof_dump_filename_mtx);
return; return;
} }

View File

@ -26,14 +26,14 @@ TEST_BEGIN(test_idump) {
bool active; bool active;
void *p; void *p;
const char *dump_prefix = TEST_PREFIX; const char *prefix = TEST_PREFIX;
test_skip_if(!config_prof); test_skip_if(!config_prof);
active = true; active = true;
expect_d_eq(mallctl("prof.dump_prefix", NULL, NULL, expect_d_eq(mallctl("prof.prefix", NULL, NULL, (void *)&prefix,
(void *)&dump_prefix, sizeof(dump_prefix)), 0, sizeof(prefix)), 0,
"Unexpected mallctl failure while overwriting dump prefix"); "Unexpected mallctl failure while overwriting dump prefix");
expect_d_eq(mallctl("prof.active", NULL, NULL, (void *)&active, expect_d_eq(mallctl("prof.active", NULL, NULL, (void *)&active,