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
also disables leak reporting, if enabled). The default prefix is
<filename>jeprof</filename>. This prefix value can be overriden by
<link
linkend="prof.dump_prefix"><mallctl>prof.dump_prefix</mallctl></link>.
<link linkend="prof.prefix"><mallctl>prof.prefix</mallctl></link>.
</para></listitem>
</varlistentry>
@ -1492,8 +1491,7 @@ malloc_conf = "xmalloc:true";]]></programlisting>
where <literal>&lt;prefix&gt;</literal> is controlled by the
<link
linkend="opt.prof_prefix"><mallctl>opt.prof_prefix</mallctl></link> and
<link
linkend="prof.dump_prefix"><mallctl>prof.dump_prefix</mallctl></link>
<link linkend="prof.prefix"><mallctl>prof.prefix</mallctl></link>
options. By default, interval-triggered profile dumping is disabled
(encoded as -1).
</para></listitem>
@ -1527,8 +1525,7 @@ malloc_conf = "xmalloc:true";]]></programlisting>
<filename>&lt;prefix&gt;.&lt;pid&gt;.&lt;seq&gt;.f.heap</filename>,
where <literal>&lt;prefix&gt;</literal> is controlled by the <link
linkend="opt.prof_prefix"><mallctl>opt.prof_prefix</mallctl></link> and
<link
linkend="prof.dump_prefix"><mallctl>prof.dump_prefix</mallctl></link>
<link linkend="prof.prefix"><mallctl>prof.prefix</mallctl></link>
options. Note that <function>atexit()</function> may allocate
memory during application initialization and then deadlock internally
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
<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
<link
linkend="opt.prof_prefix"><mallctl>opt.prof_prefix</mallctl></link> and
<link
linkend="prof.dump_prefix"><mallctl>prof.dump_prefix</mallctl></link>
<link linkend="opt.prof_prefix"><mallctl>opt.prof_prefix</mallctl></link>
and <link linkend="prof.prefix"><mallctl>prof.prefix</mallctl></link>
options.</para></listitem>
</varlistentry>
<varlistentry id="prof.dump_prefix">
<varlistentry id="prof.prefix">
<term>
<mallctl>prof.dump_prefix</mallctl>
<mallctl>prof.prefix</mallctl>
(<type>const char *</type>)
<literal>-w</literal>
[<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>,
where <literal>&lt;prefix&gt;</literal> is controlled by the <link
linkend="opt.prof_prefix"><mallctl>opt.prof_prefix</mallctl></link> and
<link
linkend="prof.dump_prefix"><mallctl>prof.dump_prefix</mallctl></link>
<link linkend="prof.prefix"><mallctl>prof.prefix</mallctl></link>
options.</para></listitem>
</varlistentry>

View File

@ -10,7 +10,7 @@ void prof_unwind_init();
void prof_sys_thread_name_fetch(tsd_t *tsd);
int prof_getpid(void);
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_idump_impl(tsd_t *tsd);
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_dump)
CTL_PROTO(prof_gdump)
CTL_PROTO(prof_dump_prefix)
CTL_PROTO(prof_prefix)
CTL_PROTO(prof_reset)
CTL_PROTO(prof_interval)
CTL_PROTO(lg_prof_sample)
@ -578,7 +578,7 @@ static const ctl_named_node_t prof_node[] = {
{NAME("active"), CTL(prof_active)},
{NAME("dump"), CTL(prof_dump)},
{NAME("gdump"), CTL(prof_gdump)},
{NAME("dump_prefix"), CTL(prof_dump_prefix)},
{NAME("prefix"), CTL(prof_prefix)},
{NAME("reset"), CTL(prof_reset)},
{NAME("interval"), CTL(prof_interval)},
{NAME("lg_sample"), CTL(lg_prof_sample)},
@ -3227,7 +3227,7 @@ label_return:
}
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) {
int ret;
const char *prefix = NULL;
@ -3240,7 +3240,7 @@ prof_dump_prefix_ctl(tsd_t *tsd, const size_t *mib, size_t miblen,
WRITEONLY();
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:
malloc_mutex_unlock(tsd_tsdn(tsd), &ctl_mtx);
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_useq;
static char *prof_dump_prefix = NULL;
static char *prof_prefix = NULL;
/* The fallback allocator profiling functionality will use. */
base_t *prof_base;
@ -524,16 +524,16 @@ prof_strncpy(char *UNUSED dest, const char *UNUSED src, size_t UNUSED size) {
}
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);
return prof_dump_prefix == NULL ? opt_prof_prefix : prof_dump_prefix;
return prof_prefix == NULL ? opt_prof_prefix : prof_prefix;
}
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);
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);
return ret;
}
@ -545,18 +545,18 @@ prof_dump_filename(tsd_t *tsd, char *filename, char v, uint64_t vseq) {
cassert(config_prof);
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) {
/* "<prefix>.<pid>.<seq>.v<vseq>.heap" */
malloc_snprintf(filename, DUMP_FILENAME_BUFSIZE,
"%s.%d.%"FMTu64".%c%"FMTu64".heap",
prof_prefix, prof_getpid(), prof_dump_seq, v, vseq);
"%s.%d.%"FMTu64".%c%"FMTu64".heap", prof_prefix,
prof_getpid(), prof_dump_seq, v, vseq);
} else {
/* "<prefix>.<pid>.<seq>.<v>.heap" */
malloc_snprintf(filename, DUMP_FILENAME_BUFSIZE,
"%s.%d.%"FMTu64".%c.heap",
prof_prefix, prof_getpid(), prof_dump_seq, v);
"%s.%d.%"FMTu64".%c.heap", prof_prefix,
prof_getpid(), prof_dump_seq, v);
}
prof_dump_seq++;
}
@ -565,8 +565,7 @@ void
prof_get_default_filename(tsdn_t *tsdn, char *filename, uint64_t ind) {
malloc_mutex_lock(tsdn, &prof_dump_filename_mtx);
malloc_snprintf(filename, PROF_DUMP_FILENAME_LEN,
"%s.%d.%"FMTu64".json", prof_dump_prefix_get(tsdn), prof_getpid(),
ind);
"%s.%d.%"FMTu64".json", prof_prefix_get(tsdn), prof_getpid(), ind);
malloc_mutex_unlock(tsdn, &prof_dump_filename_mtx);
}
@ -574,7 +573,7 @@ void
prof_fdump_impl(tsd_t *tsd) {
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);
prof_dump_filename(tsd, filename, 'f', VSEQ_INVALID);
malloc_mutex_unlock(tsd_tsdn(tsd), &prof_dump_filename_mtx);
@ -582,11 +581,11 @@ prof_fdump_impl(tsd_t *tsd) {
}
bool
prof_dump_prefix_set(tsdn_t *tsdn, const char *prefix) {
prof_prefix_set(tsdn_t *tsdn, const char *prefix) {
cassert(config_prof);
ctl_mtx_assert_held(tsdn);
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);
/* Everything is still guarded by ctl_mtx. */
char *buffer = base_alloc(tsdn, prof_base,
@ -595,12 +594,12 @@ prof_dump_prefix_set(tsdn_t *tsdn, const char *prefix) {
return true;
}
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_dump_prefix[PROF_DUMP_FILENAME_LEN - 1] = '\0';
prof_strncpy(prof_prefix, prefix, PROF_DUMP_FILENAME_LEN - 1);
prof_prefix[PROF_DUMP_FILENAME_LEN - 1] = '\0';
malloc_mutex_unlock(tsdn, &prof_dump_filename_mtx);
return false;
@ -609,7 +608,7 @@ prof_dump_prefix_set(tsdn_t *tsdn, const char *prefix) {
void
prof_idump_impl(tsd_t *tsd) {
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);
return;
}
@ -626,7 +625,7 @@ prof_mdump_impl(tsd_t *tsd, const char *filename) {
if (filename == NULL) {
/* No filename specified, so automatically generate one. */
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);
return true;
}
@ -642,7 +641,7 @@ void
prof_gdump_impl(tsd_t *tsd) {
tsdn_t *tsdn = tsd_tsdn(tsd);
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);
return;
}

View File

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