Update prof defaults to match common usage.

Change the "opt.lg_prof_sample" default from 0 to 19 (1 B to 512 KiB).

Change the "opt.prof_accum" default from true to false.

Add the "opt.prof_final" mallctl, so that "opt.prof_prefix" need not be
abused to disable final profile dumping.
This commit is contained in:
Jason Evans 2012-04-17 16:39:33 -07:00
parent 25a000e896
commit 0b25fe79aa
7 changed files with 41 additions and 20 deletions

View File

@ -34,6 +34,7 @@ found in the git revision history:
- Add the --with-mangling option. - Add the --with-mangling option.
- Add the --disable-experimental option. - Add the --disable-experimental option.
- Add the "thread.tcache.enabled" mallctl. - Add the "thread.tcache.enabled" mallctl.
- Add the "opt.prof_final" mallctl.
- Update pprof (from gperftools 2.0). - Update pprof (from gperftools 2.0).
Incompatible changes: Incompatible changes:
@ -42,6 +43,8 @@ found in the git revision history:
- Disable lazy locking by default. - Disable lazy locking by default.
- Rename the "tcache.flush" mallctl to "thread.tcache.flush". - Rename the "tcache.flush" mallctl to "thread.tcache.flush".
- Rename the "arenas.pagesize" mallctl to "arenas.page". - Rename the "arenas.pagesize" mallctl to "arenas.page".
- Change the "opt.lg_prof_sample" default from 0 to 19 (1 B to 512 KiB).
- Change the "opt.prof_accum" default from true to false.
Removed features: Removed features:
- Remove the swap feature, including the "config.swap", "swap.avail", - Remove the swap feature, including the "config.swap", "swap.avail",

View File

@ -986,14 +986,7 @@ malloc_conf = "xmalloc:true";]]></programlisting>
[<option>--enable-prof</option>] [<option>--enable-prof</option>]
</term> </term>
<listitem><para>Memory profiling enabled/disabled. If enabled, profile <listitem><para>Memory profiling enabled/disabled. If enabled, profile
memory allocation activity, and use an memory allocation activity. See the <link
<citerefentry><refentrytitle>atexit</refentrytitle>
<manvolnum>3</manvolnum></citerefentry> function to dump final memory
usage to a file named according to the pattern
<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>
option. See the <link
linkend="opt.prof_active"><mallctl>opt.prof_active</mallctl></link> linkend="opt.prof_active"><mallctl>opt.prof_active</mallctl></link>
option for on-the-fly activation/deactivation. See the <link option for on-the-fly activation/deactivation. See the <link
linkend="opt.lg_prof_sample"><mallctl>opt.lg_prof_sample</mallctl></link> linkend="opt.lg_prof_sample"><mallctl>opt.lg_prof_sample</mallctl></link>
@ -1001,12 +994,13 @@ malloc_conf = "xmalloc:true";]]></programlisting>
linkend="opt.prof_accum"><mallctl>opt.prof_accum</mallctl></link> linkend="opt.prof_accum"><mallctl>opt.prof_accum</mallctl></link>
option for control of cumulative sample reporting. See the <link option for control of cumulative sample reporting. See the <link
linkend="opt.lg_prof_interval"><mallctl>opt.lg_prof_interval</mallctl></link> linkend="opt.lg_prof_interval"><mallctl>opt.lg_prof_interval</mallctl></link>
option for information on interval-triggered profile dumping, and the option for information on interval-triggered profile dumping, the <link
<link linkend="opt.prof_gdump"><mallctl>opt.prof_gdump</mallctl></link> linkend="opt.prof_gdump"><mallctl>opt.prof_gdump</mallctl></link>
option for information on high-water-triggered profile dumping. option for information on high-water-triggered profile dumping, and the
Profile output is compatible with the included <command>pprof</command> <link linkend="opt.prof_final"><mallctl>opt.prof_final</mallctl></link>
Perl script, which originates from the <ulink option for final profile dumping. Profile output is compatible with
url="http://code.google.com/p/gperftools/">gperftools the included <command>pprof</command> Perl script, which originates
from the <ulink url="http://code.google.com/p/gperftools/">gperftools
package</ulink>.</para></listitem> package</ulink>.</para></listitem>
</varlistentry> </varlistentry>
@ -1051,8 +1045,8 @@ malloc_conf = "xmalloc:true";]]></programlisting>
<listitem><para>Average interval (log base 2) between allocation <listitem><para>Average interval (log base 2) between allocation
samples, as measured in bytes of allocation activity. Increasing the samples, as measured in bytes of allocation activity. Increasing the
sampling interval decreases profile fidelity, but also decreases the sampling interval decreases profile fidelity, but also decreases the
computational overhead. The default sample interval is 1 (2^0) (i.e. computational overhead. The default sample interval is 512 KiB (2^19
all allocations are sampled).</para></listitem> B).</para></listitem>
</varlistentry> </varlistentry>
<varlistentry id="opt.prof_accum"> <varlistentry id="opt.prof_accum">
@ -1066,7 +1060,7 @@ malloc_conf = "xmalloc:true";]]></programlisting>
dumps enabled/disabled. If this option is enabled, every unique dumps enabled/disabled. If this option is enabled, every unique
backtrace must be stored for the duration of execution. Depending on backtrace must be stored for the duration of execution. Depending on
the application, this can impose a large memory overhead, and the the application, this can impose a large memory overhead, and the
cumulative counts are not always of interest. This option is enabled cumulative counts are not always of interest. This option is disabled
by default.</para></listitem> by default.</para></listitem>
</varlistentry> </varlistentry>
@ -1107,6 +1101,23 @@ malloc_conf = "xmalloc:true";]]></programlisting>
option. This option is disabled by default.</para></listitem> option. This option is disabled by default.</para></listitem>
</varlistentry> </varlistentry>
<varlistentry id="opt.prof_final">
<term>
<mallctl>opt.prof_final</mallctl>
(<type>bool</type>)
<literal>r-</literal>
[<option>--enable-prof</option>]
</term>
<listitem><para>Use an
<citerefentry><refentrytitle>atexit</refentrytitle>
<manvolnum>3</manvolnum></citerefentry> function to dump final memory
usage to a file named according to the pattern
<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>
option. This option is enabled by default.</para></listitem>
</varlistentry>
<varlistentry id="opt.prof_leak"> <varlistentry id="opt.prof_leak">
<term> <term>
<mallctl>opt.prof_leak</mallctl> <mallctl>opt.prof_leak</mallctl>

View File

@ -9,7 +9,7 @@ typedef struct prof_tdata_s prof_tdata_t;
/* Option defaults. */ /* Option defaults. */
#define PROF_PREFIX_DEFAULT "jeprof" #define PROF_PREFIX_DEFAULT "jeprof"
#define LG_PROF_SAMPLE_DEFAULT 0 #define LG_PROF_SAMPLE_DEFAULT 19
#define LG_PROF_INTERVAL_DEFAULT -1 #define LG_PROF_INTERVAL_DEFAULT -1
/* /*
@ -169,6 +169,7 @@ extern bool opt_prof_active;
extern size_t opt_lg_prof_sample; /* Mean bytes between samples. */ extern size_t opt_lg_prof_sample; /* Mean bytes between samples. */
extern ssize_t opt_lg_prof_interval; /* lg(prof_interval). */ extern ssize_t opt_lg_prof_interval; /* lg(prof_interval). */
extern bool opt_prof_gdump; /* High-water memory dumping. */ extern bool opt_prof_gdump; /* High-water memory dumping. */
extern bool opt_prof_final; /* Final profile dumping. */
extern bool opt_prof_leak; /* Dump leak summary at exit. */ extern bool opt_prof_leak; /* Dump leak summary at exit. */
extern bool opt_prof_accum; /* Report cumulative bytes. */ extern bool opt_prof_accum; /* Report cumulative bytes. */
extern char opt_prof_prefix[PATH_MAX + 1]; extern char opt_prof_prefix[PATH_MAX + 1];

View File

@ -80,6 +80,7 @@ CTL_PROTO(opt_prof_active)
CTL_PROTO(opt_lg_prof_sample) CTL_PROTO(opt_lg_prof_sample)
CTL_PROTO(opt_lg_prof_interval) CTL_PROTO(opt_lg_prof_interval)
CTL_PROTO(opt_prof_gdump) CTL_PROTO(opt_prof_gdump)
CTL_PROTO(opt_prof_final)
CTL_PROTO(opt_prof_leak) CTL_PROTO(opt_prof_leak)
CTL_PROTO(opt_prof_accum) CTL_PROTO(opt_prof_accum)
CTL_PROTO(arenas_bin_i_size) CTL_PROTO(arenas_bin_i_size)
@ -210,6 +211,7 @@ static const ctl_node_t opt_node[] = {
{NAME("lg_prof_sample"), CTL(opt_lg_prof_sample)}, {NAME("lg_prof_sample"), CTL(opt_lg_prof_sample)},
{NAME("lg_prof_interval"), CTL(opt_lg_prof_interval)}, {NAME("lg_prof_interval"), CTL(opt_lg_prof_interval)},
{NAME("prof_gdump"), CTL(opt_prof_gdump)}, {NAME("prof_gdump"), CTL(opt_prof_gdump)},
{NAME("prof_final"), CTL(opt_prof_final)},
{NAME("prof_leak"), CTL(opt_prof_leak)}, {NAME("prof_leak"), CTL(opt_prof_leak)},
{NAME("prof_accum"), CTL(opt_prof_accum)} {NAME("prof_accum"), CTL(opt_prof_accum)}
}; };
@ -1122,6 +1124,7 @@ CTL_RO_CGEN(config_prof, opt_prof_active, opt_prof_active, bool) /* Mutable. */
CTL_RO_NL_CGEN(config_prof, opt_lg_prof_sample, opt_lg_prof_sample, size_t) CTL_RO_NL_CGEN(config_prof, opt_lg_prof_sample, opt_lg_prof_sample, size_t)
CTL_RO_NL_CGEN(config_prof, opt_lg_prof_interval, opt_lg_prof_interval, ssize_t) CTL_RO_NL_CGEN(config_prof, opt_lg_prof_interval, opt_lg_prof_interval, ssize_t)
CTL_RO_NL_CGEN(config_prof, opt_prof_gdump, opt_prof_gdump, bool) CTL_RO_NL_CGEN(config_prof, opt_prof_gdump, opt_prof_gdump, bool)
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_leak, opt_prof_leak, bool)
CTL_RO_NL_CGEN(config_prof, opt_prof_accum, opt_prof_accum, bool) CTL_RO_NL_CGEN(config_prof, opt_prof_accum, opt_prof_accum, bool)

View File

@ -561,6 +561,7 @@ malloc_conf_init(void)
lg_prof_interval, -1, lg_prof_interval, -1,
(sizeof(uint64_t) << 3) - 1) (sizeof(uint64_t) << 3) - 1)
CONF_HANDLE_BOOL(opt_prof_gdump, prof_gdump) CONF_HANDLE_BOOL(opt_prof_gdump, prof_gdump)
CONF_HANDLE_BOOL(opt_prof_final, prof_final)
CONF_HANDLE_BOOL(opt_prof_leak, prof_leak) CONF_HANDLE_BOOL(opt_prof_leak, prof_leak)
} }
malloc_conf_error("Invalid conf pair", k, klen, v, malloc_conf_error("Invalid conf pair", k, klen, v,

View File

@ -21,8 +21,9 @@ bool opt_prof_active = true;
size_t opt_lg_prof_sample = LG_PROF_SAMPLE_DEFAULT; size_t opt_lg_prof_sample = LG_PROF_SAMPLE_DEFAULT;
ssize_t opt_lg_prof_interval = LG_PROF_INTERVAL_DEFAULT; ssize_t opt_lg_prof_interval = LG_PROF_INTERVAL_DEFAULT;
bool opt_prof_gdump = false; bool opt_prof_gdump = false;
bool opt_prof_final = true;
bool opt_prof_leak = false; bool opt_prof_leak = false;
bool opt_prof_accum = true; bool opt_prof_accum = false;
char opt_prof_prefix[PATH_MAX + 1]; char opt_prof_prefix[PATH_MAX + 1];
uint64_t prof_interval; uint64_t prof_interval;
@ -944,7 +945,7 @@ prof_fdump(void)
if (prof_booted == false) if (prof_booted == false)
return; return;
if (opt_prof_prefix[0] != '\0') { if (opt_prof_final && opt_prof_prefix[0] != '\0') {
malloc_mutex_lock(&prof_dump_seq_mtx); malloc_mutex_lock(&prof_dump_seq_mtx);
prof_dump_filename(filename, 'f', UINT64_C(0xffffffffffffffff)); prof_dump_filename(filename, 'f', UINT64_C(0xffffffffffffffff));
malloc_mutex_unlock(&prof_dump_seq_mtx); malloc_mutex_unlock(&prof_dump_seq_mtx);

View File

@ -397,6 +397,7 @@ stats_print(void (*write_cb)(void *, const char *), void *cbopaque,
OPT_WRITE_BOOL(prof_accum) OPT_WRITE_BOOL(prof_accum)
OPT_WRITE_SSIZE_T(lg_prof_interval) OPT_WRITE_SSIZE_T(lg_prof_interval)
OPT_WRITE_BOOL(prof_gdump) OPT_WRITE_BOOL(prof_gdump)
OPT_WRITE_BOOL(prof_final)
OPT_WRITE_BOOL(prof_leak) OPT_WRITE_BOOL(prof_leak)
#undef OPT_WRITE_BOOL #undef OPT_WRITE_BOOL