refactor prof accum, so that tdata is not loaded if we aren't going to sample.

This commit is contained in:
Dave Watson 2018-10-09 11:07:24 -07:00
parent 9ed3bdc848
commit 0ac524308d

View File

@ -86,6 +86,14 @@ prof_sample_accum_update(tsd_t *tsd, size_t usize, bool update,
cassert(config_prof); cassert(config_prof);
bytes_until_sample = tsd_bytes_until_sample_get(tsd);
if (likely(bytes_until_sample >= usize)) {
if (update && tsd_nominal(tsd)) {
tsd_bytes_until_sample_set(tsd, bytes_until_sample - usize);
}
return true;
}
tdata = prof_tdata_get(tsd, true); tdata = prof_tdata_get(tsd, true);
if (unlikely((uintptr_t)tdata <= (uintptr_t)PROF_TDATA_STATE_MAX)) { if (unlikely((uintptr_t)tdata <= (uintptr_t)PROF_TDATA_STATE_MAX)) {
tdata = NULL; tdata = NULL;
@ -99,13 +107,6 @@ prof_sample_accum_update(tsd_t *tsd, size_t usize, bool update,
return true; return true;
} }
bytes_until_sample = tsd_bytes_until_sample_get(tsd);
if (likely(bytes_until_sample >= usize)) {
if (update && tsd_nominal(tsd)) {
tsd_bytes_until_sample_set(tsd, bytes_until_sample - usize);
}
return true;
} else {
if (tsd_reentrancy_level_get(tsd) > 0) { if (tsd_reentrancy_level_get(tsd) > 0) {
return true; return true;
} }
@ -115,7 +116,6 @@ prof_sample_accum_update(tsd_t *tsd, size_t usize, bool update,
} }
return !tdata->active; return !tdata->active;
} }
}
JEMALLOC_ALWAYS_INLINE prof_tctx_t * JEMALLOC_ALWAYS_INLINE prof_tctx_t *
prof_alloc_prep(tsd_t *tsd, size_t usize, bool prof_active, bool update) { prof_alloc_prep(tsd_t *tsd, size_t usize, bool prof_active, bool update) {