Restructure setters for profiling info
Explicitly define three setters: - `prof_tctx_reset()`: set `prof_tctx` to `1U`, if we don't know in advance whether the allocation is large or not; - `prof_tctx_reset_sampled()`: set `prof_tctx` to `1U`, if we already know in advance that the allocation is large; - `prof_info_set()`: set a real `prof_tctx`, and also set other profiling info e.g. the allocation time. Code structure wise, the prof level is kept as a thin wrapper, the large level only provides low level setter APIs, and the arena level carries out the main logic.
This commit is contained in:
@@ -372,7 +372,7 @@ large_prof_info_get(const extent_t *extent, prof_info_t *prof_info) {
|
||||
extent_prof_info_get(extent, prof_info);
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
large_prof_tctx_set(extent_t *extent, prof_tctx_t *tctx) {
|
||||
extent_prof_tctx_set(extent, tctx);
|
||||
}
|
||||
@@ -383,6 +383,9 @@ large_prof_tctx_reset(extent_t *extent) {
|
||||
}
|
||||
|
||||
void
|
||||
large_prof_alloc_time_set(extent_t *extent, nstime_t *t) {
|
||||
extent_prof_alloc_time_set(extent, t);
|
||||
large_prof_info_set(extent_t *extent, prof_tctx_t *tctx) {
|
||||
large_prof_tctx_set(extent, tctx);
|
||||
nstime_t t;
|
||||
nstime_init_update(&t);
|
||||
extent_prof_alloc_time_set(extent, &t);
|
||||
}
|
||||
|
@@ -162,13 +162,7 @@ prof_alloc_rollback(tsd_t *tsd, prof_tctx_t *tctx, bool updated) {
|
||||
void
|
||||
prof_malloc_sample_object(tsd_t *tsd, const void *ptr, size_t usize,
|
||||
prof_tctx_t *tctx) {
|
||||
prof_tctx_set(tsd, ptr, NULL, tctx);
|
||||
|
||||
/* Get the current time and set this in the extent_t. We'll read this
|
||||
* when free() is called. */
|
||||
nstime_t t;
|
||||
nstime_init_update(&t);
|
||||
prof_alloc_time_set(tsd, ptr, &t);
|
||||
prof_info_set(tsd, ptr, tctx);
|
||||
|
||||
malloc_mutex_lock(tsd_tsdn(tsd), tctx->tdata->lock);
|
||||
tctx->cnts.curobjs++;
|
||||
|
Reference in New Issue
Block a user