diff options
author | Jason Evans <je@facebook.com> | 2010-02-11 18:25:36 (GMT) |
---|---|---|
committer | Jason Evans <je@facebook.com> | 2010-02-11 18:25:36 (GMT) |
commit | b01a6c2057f8db470273b16c7eaad5306e2540b7 (patch) | |
tree | f03275c295ed69ace0c8a9509663001a2b6bac04 | |
parent | c7177181154a5bdce61edbfe008741a7583c7203 (diff) | |
download | jemalloc-b01a6c2057f8db470273b16c7eaad5306e2540b7.zip jemalloc-b01a6c2057f8db470273b16c7eaad5306e2540b7.tar.gz jemalloc-b01a6c2057f8db470273b16c7eaad5306e2540b7.tar.bz2 |
Add JEMALLOC_PROF_PREFIX support.
If JEMALLOC_PROF_PREFIX is set in the environment, use it as the
filename prefix when dumping heap profiles, rather than "jeprof".
-rw-r--r-- | jemalloc/configure.ac | 3 | ||||
-rw-r--r-- | jemalloc/doc/jemalloc.3.in | 39 | ||||
-rw-r--r-- | jemalloc/src/prof.c | 36 |
3 files changed, 64 insertions, 14 deletions
diff --git a/jemalloc/configure.ac b/jemalloc/configure.ac index 17c7aa6..b6ded7b 100644 --- a/jemalloc/configure.ac +++ b/jemalloc/configure.ac @@ -688,10 +688,13 @@ fi AC_SUBST([enable_prof]) if test "x$enable_prof" = "x0" ; then roff_prof=".\\\" " + roff_no_prof="" else roff_prof="" + roff_no_prof=".\\\" " fi AC_SUBST([roff_prof]) +AC_SUBST([roff_no_prof]) dnl If libunwind isn't enabled, try to use libgcc rather than gcc intrinsics dnl for backtracing. diff --git a/jemalloc/doc/jemalloc.3.in b/jemalloc/doc/jemalloc.3.in index e661177..3865ac9 100644 --- a/jemalloc/doc/jemalloc.3.in +++ b/jemalloc/doc/jemalloc.3.in @@ -38,7 +38,7 @@ .\" @(#)malloc.3 8.1 (Berkeley) 6/4/93 .\" $FreeBSD: head/lib/libc/stdlib/malloc.3 182225 2008-08-27 02:00:53Z jasone $ .\" -.Dd January 27, 2010 +.Dd February 11, 2010 .Dt JEMALLOC 3 .Os .Sh NAME @@ -345,7 +345,12 @@ will disable dirty page purging. @roff_prof@.Xr atexit 3 @roff_prof@function to dump final memory usage to a file named according to @roff_prof@the pattern -@roff_prof@.Pa jeprof.<pid>.<seq>.f.heap . +@roff_prof@.Pa <prefix>.<pid>.<seq>.f.heap , +@roff_prof@where +@roff_prof@.Pa <prefix> +@roff_prof@is controlled by the +@roff_prof@JEMALLOC_PROF_PREFIX +@roff_prof@environment variable. @roff_prof@See the @roff_prof@.Dq B @roff_prof@option for backtrace depth control. @@ -390,7 +395,12 @@ will disable dirty page purging. @roff_prof@This is an artifact of the concurrent algorithm that is used to @roff_prof@track allocation activity. @roff_prof@Profiles are dumped to files named according to the pattern -@roff_prof@.Pa jeprof.<pid>.<seq>.i<iseq>.heap . +@roff_prof@.Pa <prefix>.<pid>.<seq>.i<iseq>.heap , +@roff_prof@where +@roff_prof@.Pa <prefix> +@roff_prof@is controlled by the +@roff_prof@JEMALLOC_PROF_PREFIX +@roff_prof@environment variable. @roff_prof@The default maximum interval is 4 GiB. @roff_fill@.It J @roff_fill@Each byte of new memory allocated by @@ -474,7 +484,12 @@ The default value is 128 bytes. @roff_prof@Trigger a memory profile dump every time the total virtual memory @roff_prof@exceeds the previous maximum. @roff_prof@Profiles are dumped to files named according to the pattern -@roff_prof@.Pa jeprof.<pid>.<seq>.u<useq>.heap . +@roff_prof@.Pa <prefix>.<pid>.<seq>.u<useq>.heap , +@roff_prof@where +@roff_prof@.Pa <prefix> +@roff_prof@is controlled by the +@roff_prof@JEMALLOC_PROF_PREFIX +@roff_prof@environment variable. @roff_prof@This option is disabled by default. @roff_sysv@.It V @roff_sysv@Attempting to allocate zero bytes will return a @@ -970,7 +985,12 @@ Maximum size supported by this large size class. @roff_prof@.It Sy "prof.dump (void) --" @roff_prof@.Bd -ragged -offset indent -compact @roff_prof@Dump a memory profile to a file according to the pattern -@roff_prof@.Pa jeprof.<pid>.<seq>.m<mseq>.heap . +@roff_prof@.Pa <prefix>.<pid>.<seq>.m<mseq>.heap , +@roff_prof@where +@roff_prof@.Pa <prefix> +@roff_prof@is controlled by the +@roff_prof@JEMALLOC_PROF_PREFIX +@roff_prof@environment variable. @roff_prof@.Ed .\"----------------------------------------------------------------------------- @roff_stats@.It Sy "stats.allocated (size_t) r-" @@ -1356,12 +1376,19 @@ read/write processing. .Sh ENVIRONMENT The following environment variables affect the execution of the allocation functions: -.Bl -tag -width ".Ev JEMALLOC_OPTIONS" +@roff_prof@.Bl -tag -width ".Ev JEMALLOC_PROF_PREFIX" +@roff_no_prof@.Bl -tag -width ".Ev JEMALLOC_OPTIONS" .It Ev JEMALLOC_OPTIONS If the environment variable .Ev JEMALLOC_OPTIONS is set, the characters it contains will be interpreted as flags to the allocation functions. +@roff_prof@.It Ev JEMALLOC_PROF_PREFIX +@roff_prof@If the environment variable +@roff_prof@.Ev JEMALLOC_PROF_PREFIX +@roff_prof@is set, use itas the filename prefix for profile dumps; otherwise use +@roff_prof@.Pa jeprof +@roff_prof@as the prefix. .El .Sh EXAMPLES To dump core whenever a problem occurs: diff --git a/jemalloc/src/prof.c b/jemalloc/src/prof.c index f471c6a..8f69c01 100644 --- a/jemalloc/src/prof.c +++ b/jemalloc/src/prof.c @@ -854,13 +854,12 @@ prof_dump(const char *filename, bool leakcheck) } } -/* jeprof.<pid>.<seq>.v<vseq>.heap\0 */ -#define DUMP_FILENAME_BUFSIZE (7 + UMAX2S_BUFSIZE \ - + 1 \ - + UMAX2S_BUFSIZE \ - + 2 \ - + UMAX2S_BUFSIZE \ - + 5 + 1) +#define DUMP_FILENAME_BUFSIZE (PATH_MAX+ UMAX2S_BUFSIZE \ + + 1 \ + + UMAX2S_BUFSIZE \ + + 2 \ + + UMAX2S_BUFSIZE \ + + 5 + 1) static void prof_dump_filename(char *filename, char v, int64_t vseq) { @@ -868,9 +867,30 @@ prof_dump_filename(char *filename, char v, int64_t vseq) char *s; unsigned i, slen; + /* + * Construct a filename of the form: + * + * <prefix>.<pid>.<seq>.v<vseq>.heap\0 + * or + * jeprof.<pid>.<seq>.v<vseq>.heap\0 + */ + i = 0; - s = "jeprof."; + /* + * Use JEMALLOC_PROF_PREFIX if it's set, and if it is short enough to + * avoid overflowing DUMP_FILENAME_BUFSIZE. The result may exceed + * PATH_MAX, but creat(2) will catch that problem. + */ + if ((s = getenv("JEMALLOC_PROF_PREFIX")) != NULL + && strlen(s) + (DUMP_FILENAME_BUFSIZE - PATH_MAX) <= PATH_MAX) { + slen = strlen(s); + memcpy(&filename[i], s, slen); + i += slen; + + s = "."; + } else + s = "jeprof."; slen = strlen(s); memcpy(&filename[i], s, slen); i += slen; |