Record request size in prof info

This commit is contained in:
Yinan Zhang 2020-08-21 11:31:53 -07:00
parent f9bb8dedef
commit afa489c3c5
7 changed files with 24 additions and 7 deletions

View File

@ -105,11 +105,12 @@ arena_prof_tctx_reset_sampled(tsd_t *tsd, const void *ptr) {
} }
JEMALLOC_ALWAYS_INLINE void JEMALLOC_ALWAYS_INLINE void
arena_prof_info_set(tsd_t *tsd, edata_t *edata, prof_tctx_t *tctx) { arena_prof_info_set(tsd_t *tsd, edata_t *edata, prof_tctx_t *tctx,
size_t size) {
cassert(config_prof); cassert(config_prof);
assert(!edata_slab_get(edata)); assert(!edata_slab_get(edata));
large_prof_info_set(edata, tctx); large_prof_info_set(edata, tctx, size);
} }
JEMALLOC_ALWAYS_INLINE void JEMALLOC_ALWAYS_INLINE void

View File

@ -40,6 +40,8 @@ typedef enum extent_pai_e extent_pai_t;
struct e_prof_info_s { struct e_prof_info_s {
/* Time when this was allocated. */ /* Time when this was allocated. */
nstime_t e_prof_alloc_time; nstime_t e_prof_alloc_time;
/* Allocation request size. */
size_t e_prof_alloc_size;
/* Points to a prof_tctx_t. */ /* Points to a prof_tctx_t. */
atomic_p_t e_prof_tctx; atomic_p_t e_prof_tctx;
/* /*
@ -390,6 +392,11 @@ edata_prof_alloc_time_get(const edata_t *edata) {
return &edata->e_prof_info.e_prof_alloc_time; return &edata->e_prof_info.e_prof_alloc_time;
} }
static inline size_t
edata_prof_alloc_size_get(const edata_t *edata) {
return edata->e_prof_info.e_prof_alloc_size;
}
static inline prof_recent_t * static inline prof_recent_t *
edata_prof_recent_alloc_get_dont_call_directly(const edata_t *edata) { edata_prof_recent_alloc_get_dont_call_directly(const edata_t *edata) {
return (prof_recent_t *)atomic_load_p( return (prof_recent_t *)atomic_load_p(
@ -526,6 +533,11 @@ edata_prof_alloc_time_set(edata_t *edata, nstime_t *t) {
nstime_copy(&edata->e_prof_info.e_prof_alloc_time, t); nstime_copy(&edata->e_prof_info.e_prof_alloc_time, t);
} }
static inline void
edata_prof_alloc_size_set(edata_t *edata, size_t size) {
edata->e_prof_info.e_prof_alloc_size = size;
}
static inline void static inline void
edata_prof_recent_alloc_set_dont_call_directly(edata_t *edata, edata_prof_recent_alloc_set_dont_call_directly(edata_t *edata,
prof_recent_t *recent_alloc) { prof_recent_t *recent_alloc) {

View File

@ -19,6 +19,6 @@ size_t large_salloc(tsdn_t *tsdn, const edata_t *edata);
void large_prof_info_get(tsd_t *tsd, edata_t *edata, prof_info_t *prof_info, void large_prof_info_get(tsd_t *tsd, edata_t *edata, prof_info_t *prof_info,
bool reset_recent); bool reset_recent);
void large_prof_tctx_reset(edata_t *edata); void large_prof_tctx_reset(edata_t *edata);
void large_prof_info_set(edata_t *edata, prof_tctx_t *tctx); void large_prof_info_set(edata_t *edata, prof_tctx_t *tctx, size_t size);
#endif /* JEMALLOC_INTERNAL_LARGE_EXTERNS_H */ #endif /* JEMALLOC_INTERNAL_LARGE_EXTERNS_H */

View File

@ -98,12 +98,12 @@ prof_tctx_reset_sampled(tsd_t *tsd, const void *ptr) {
} }
JEMALLOC_ALWAYS_INLINE void JEMALLOC_ALWAYS_INLINE void
prof_info_set(tsd_t *tsd, edata_t *edata, prof_tctx_t *tctx) { prof_info_set(tsd_t *tsd, edata_t *edata, prof_tctx_t *tctx, size_t size) {
cassert(config_prof); cassert(config_prof);
assert(edata != NULL); assert(edata != NULL);
assert((uintptr_t)tctx > (uintptr_t)1U); assert((uintptr_t)tctx > (uintptr_t)1U);
arena_prof_info_set(tsd, edata, tctx); arena_prof_info_set(tsd, edata, tctx, size);
} }
JEMALLOC_ALWAYS_INLINE bool JEMALLOC_ALWAYS_INLINE bool

View File

@ -103,6 +103,8 @@ struct prof_info_s {
nstime_t alloc_time; nstime_t alloc_time;
/* Points to the prof_tctx_t corresponding to the allocation. */ /* Points to the prof_tctx_t corresponding to the allocation. */
prof_tctx_t *alloc_tctx; prof_tctx_t *alloc_tctx;
/* Allocation request size. */
size_t alloc_size;
}; };
struct prof_gctx_s { struct prof_gctx_s {

View File

@ -281,6 +281,7 @@ large_prof_info_get(tsd_t *tsd, edata_t *edata, prof_info_t *prof_info,
if ((uintptr_t)alloc_tctx > (uintptr_t)1U) { if ((uintptr_t)alloc_tctx > (uintptr_t)1U) {
nstime_copy(&prof_info->alloc_time, nstime_copy(&prof_info->alloc_time,
edata_prof_alloc_time_get(edata)); edata_prof_alloc_time_get(edata));
prof_info->alloc_size = edata_prof_alloc_size_get(edata);
if (reset_recent) { if (reset_recent) {
/* /*
* Reset the pointer on the recent allocation record, * Reset the pointer on the recent allocation record,
@ -302,10 +303,11 @@ large_prof_tctx_reset(edata_t *edata) {
} }
void void
large_prof_info_set(edata_t *edata, prof_tctx_t *tctx) { large_prof_info_set(edata_t *edata, prof_tctx_t *tctx, size_t size) {
nstime_t t; nstime_t t;
nstime_prof_init_update(&t); nstime_prof_init_update(&t);
edata_prof_alloc_time_set(edata, &t); edata_prof_alloc_time_set(edata, &t);
edata_prof_alloc_size_set(edata, size);
edata_prof_recent_alloc_init(edata); edata_prof_recent_alloc_init(edata);
large_prof_tctx_set(edata, tctx); large_prof_tctx_set(edata, tctx);
} }

View File

@ -97,7 +97,7 @@ prof_malloc_sample_object(tsd_t *tsd, const void *ptr, size_t size,
edata_t *edata = emap_edata_lookup(tsd_tsdn(tsd), &arena_emap_global, edata_t *edata = emap_edata_lookup(tsd_tsdn(tsd), &arena_emap_global,
ptr); ptr);
prof_info_set(tsd, edata, tctx); prof_info_set(tsd, edata, tctx, size);
szind_t szind = sz_size2index(usize); szind_t szind = sz_size2index(usize);