mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-07-23 09:07:18 +03:00
move bytes until sample to tsd. Fastpath allocation does not need
to load tdata now, avoiding several branches.
This commit is contained in:
parent
09adf18f1a
commit
9ed3bdc848
4 changed files with 13 additions and 11 deletions
13
src/prof.c
13
src/prof.c
|
|
@ -1136,15 +1136,12 @@ prof_lookup(tsd_t *tsd, prof_bt_t *bt) {
|
|||
void
|
||||
prof_sample_threshold_update(prof_tdata_t *tdata) {
|
||||
#ifdef JEMALLOC_PROF
|
||||
uint64_t r;
|
||||
double u;
|
||||
|
||||
if (!config_prof) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (lg_prof_sample == 0) {
|
||||
tdata->bytes_until_sample = 0;
|
||||
tsd_bytes_until_sample_set(tsd_fetch(), 0);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -1166,11 +1163,13 @@ prof_sample_threshold_update(prof_tdata_t *tdata) {
|
|||
* pp 500
|
||||
* (http://luc.devroye.org/rnbookindex.html)
|
||||
*/
|
||||
r = prng_lg_range_u64(&tdata->prng_state, 53);
|
||||
u = (double)r * (1.0/9007199254740992.0L);
|
||||
tdata->bytes_until_sample = (uint64_t)(log(u) /
|
||||
uint64_t r = prng_lg_range_u64(&tdata->prng_state, 53);
|
||||
double u = (double)r * (1.0/9007199254740992.0L);
|
||||
uint64_t bytes_until_sample = (uint64_t)(log(u) /
|
||||
log(1.0 - (1.0 / (double)((uint64_t)1U << lg_prof_sample))))
|
||||
+ (uint64_t)1U;
|
||||
tsd_bytes_until_sample_set(tsd_fetch(), bytes_until_sample);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue