<div dir="ltr">This explanation makes perfect sense, thanks! I'm also assuming that with prof_accum:true, the stats that are logged are *only* the cumulative stats, so when you run jeprof that s what you get.<div><br></div><div>This was extremely helpful, I'm going to try to create a patch for the jemalloc man page to make it clearer. This is a super, super useful feature, and I'm not sure why I found the configuration options so confusing, since I think they are fairly straightforward now that I understand them.</div><div><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Nov 8, 2015 at 2:35 PM, Jason Evans <span dir="ltr"><<a href="mailto:jasone@canonware.com" target="_blank">jasone@canonware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div>On Nov 6, 2015, at 2:01 PM, Evan Jones <<a href="mailto:ejones@twitter.com" target="_blank">ejones@twitter.com</a>> wrote:<div><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Nov 6, 2015 at 4:57 PM, Jason Evans <span dir="ltr"><<a href="mailto:jasone@canonware.com" target="_blank">jasone@canonware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word"><span>On Nov 6, 2015, at 12:53 PM, Evan Jones <<a href="mailto:ejones@twitter.com" target="_blank">ejones@twitter.com</a>> wrote:</span><div><span><blockquote type="cite"><div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Nov 6, 2015 at 3:45 PM, Jason Evans <span dir="ltr"><<a href="mailto:jasone@canonware.com" target="_blank">jasone@canonware.com</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">No, dumps are always based on the most recent stats reset (process start or "prof.reset" mallctl call).  You can view incremental differences between two dumps by using the --base option to jeprof.<br></blockquote><div><br></div><div>Is this true if you use opt.lg_prof_interval? Then what is the point of the opt.prof_accum option?</div></div></div></div></div></blockquote><div><br></div></span><div>opt.lg_prof_interval is merely a dump triggering mechanism.  opt.prof_accum controls whether cumulative stats are collected at all.</div></div></div></blockquote><div><br></div><div>There must be something stupid that I don't understand then. You said: "dumps are always based on the most recent stats reset", which is usually the process start time, unless you do some manual reset. Does this mean that prof_accum is *only* useful if you do manually trigger resets using mallctl("prof.reset")? Does this mean that with prof_accum:true, the dumps contain *both* the data since the last reset *and* the data since profiling was enabled?</div></div></div></div></div></blockquote><br></div></div></div><div>Take the following function as an example, run with MALLOC_CONF=prof:true,prof_accum:true :</div><div><br></div><div><span style="white-space:pre-wrap">  </span>void<span style="white-space:pre-wrap">    </span>g(void *p);</div><div><br></div><div><span style="white-space:pre-wrap">     </span>void</div><div><span style="white-space:pre-wrap">     </span>f(void) {</div><div><span style="white-space:pre-wrap">                </span>unsigned i;</div><div><br></div><div><span style="white-space:pre-wrap">             </span>for (i = 0; i < (1U << 20); i++) {</div><div><span style="white-space:pre-wrap">                      </span>void *p = malloc(1U << 30);</div><div><div><span style="white-space:pre-wrap">                     </span>if (i == (1U << 19)) {</div><div><span style="white-space:pre-wrap">                             </span>mallctl("prof.dump", NULL, NULL, NULL, 0); /* A */</div><div><span style="white-space:pre-wrap">                             </span>mallctl("prof.reset", NULL, NULL, NULL, 0);</div><div><span style="white-space:pre-wrap">                            </span>mallctl("prof.dump", NULL, NULL, NULL, 0); /* B */</div><div><span style="white-space:pre-wrap">                     </span>}</div></div><div><span style="white-space:pre-wrap">                    </span>if (p != NULL) {</div><div><span style="white-space:pre-wrap">                         </span>g(p);</div><div><span style="white-space:pre-wrap">                            </span>free(p);</div><div><span style="white-space:pre-wrap">                 </span>}</div><div><span style="white-space:pre-wrap">                </span>}</div><div><span style="white-space:pre-wrap">                </span>mallctl("prof.dump", NULL, NULL, NULL, 0); /* C */</div><div><span style="white-space:pre-wrap">     </span>}</div><div><br></div><div>What will the heap profiling stats (as interpreted by jeprof) dumped at A, B, and C say regarding the malloc() site in f()?</div><div><br></div><div><div>A:</div><div>  - Current: ~1 object, ~2^30 bytes</div><div>  - Cumulative: ~2^19 objects, ~2^49 bytes</div><div><div>B:</div><div>  - Current: 0 objects, 0 bytes</div><div>  - Cumulative: 0 objects, 0 bytes</div></div></div><div>C:</div><div>  - Current: 0 objects, 0 bytes</div><div>  - Cumulative: ~2^19 objects, ~2^49 bytes</div><div><br></div><div>opt.prof_accum controls whether jemalloc maintains the cumulative stats.  With MALLOC_CONF=prof:true,prof_accum:false, you will get no cumulative stats at all, no matter when/whether any resets occurred.</div><span><font color="#888888"><div><br></div><div>Jason</div></font></span></div></blockquote></div><br></div></div>