Prof: Add prof_unbias.

This gives more accurate attribution of bytes and counts to stack traces,
without introducing backwards incompatibilities in heap-profile parsing tools.
We track the ideal reported (to the end user) number of bytes more carefully
inside core jemalloc.  When dumping heap profiles, insteading of outputting our
counts directly, we output counts that will cause parsing tools to give a result
close to the value we want.

We retain the old version as an opt setting, to let users who are tracking
values on a per-component basis to keep their metrics stable until they decide
to switch.
This commit is contained in:
David Goldblatt
2020-08-03 13:05:34 -07:00
committed by David Goldblatt
parent 81c2f841e5
commit 60993697d8
5 changed files with 241 additions and 2 deletions

View File

@@ -19,6 +19,7 @@ extern char opt_prof_prefix[
PATH_MAX +
#endif
1];
extern bool opt_prof_unbias;
/* For recording recent allocations */
extern ssize_t opt_prof_recent_alloc_max;
@@ -40,6 +41,9 @@ extern uint64_t prof_interval;
* resets.
*/
extern size_t lg_prof_sample;
extern size_t prof_unbiased_sz[SC_NSIZES];
extern size_t prof_shifted_unbiased_cnt[SC_NSIZES];
void prof_unbias_map_init();
extern bool prof_booted;

View File

@@ -24,9 +24,13 @@ typedef struct {
struct prof_cnt_s {
/* Profiling counters. */
uint64_t curobjs;
uint64_t curobjs_shifted_unbiased;
uint64_t curbytes;
uint64_t curbytes_unbiased;
uint64_t accumobjs;
uint64_t accumobjs_shifted_unbiased;
uint64_t accumbytes;
uint64_t accumbytes_unbiased;
};
typedef enum {