mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-08-24 08:03:32 +03:00
Add bytes counter to arena large stats.
To prepare for the upcoming usize changes, stats collected by multiplying alive allocations and the bin size is no longer accurate. Thus, add separate counters to record the bytes malloced and dalloced.
This commit is contained in:
parent
bffe921ba0
commit
96b15d5d43
3 changed files with 41 additions and 8 deletions
24
src/arena.c
24
src/arena.c
|
|
@ -145,8 +145,18 @@ arena_stats_merge(tsdn_t *tsdn, arena_t *arena, unsigned *nthreads,
|
|||
assert(nmalloc - ndalloc <= SIZE_T_MAX);
|
||||
size_t curlextents = (size_t)(nmalloc - ndalloc);
|
||||
lstats[i].curlextents += curlextents;
|
||||
astats->allocated_large +=
|
||||
curlextents * sz_index2size(SC_NBINS + i);
|
||||
|
||||
if (config_limit_usize_gap) {
|
||||
uint64_t active_bytes = locked_read_u64(tsdn,
|
||||
LOCKEDINT_MTX(arena->stats.mtx),
|
||||
&arena->stats.lstats[i].active_bytes);
|
||||
locked_inc_u64_unsynchronized(
|
||||
&lstats[i].active_bytes, active_bytes);
|
||||
astats->allocated_large += active_bytes;
|
||||
} else {
|
||||
astats->allocated_large +=
|
||||
curlextents * sz_index2size(SC_NBINS + i);
|
||||
}
|
||||
}
|
||||
|
||||
pa_shard_stats_merge(tsdn, &arena->pa_shard, &astats->pa_shard_stats,
|
||||
|
|
@ -315,6 +325,11 @@ arena_large_malloc_stats_update(tsdn_t *tsdn, arena_t *arena, size_t usize) {
|
|||
LOCKEDINT_MTX_LOCK(tsdn, arena->stats.mtx);
|
||||
locked_inc_u64(tsdn, LOCKEDINT_MTX(arena->stats.mtx),
|
||||
&arena->stats.lstats[hindex].nmalloc, 1);
|
||||
if (config_limit_usize_gap) {
|
||||
locked_inc_u64(tsdn, LOCKEDINT_MTX(arena->stats.mtx),
|
||||
&arena->stats.lstats[hindex].active_bytes,
|
||||
usize);
|
||||
}
|
||||
LOCKEDINT_MTX_UNLOCK(tsdn, arena->stats.mtx);
|
||||
}
|
||||
}
|
||||
|
|
@ -338,6 +353,11 @@ arena_large_dalloc_stats_update(tsdn_t *tsdn, arena_t *arena, size_t usize) {
|
|||
LOCKEDINT_MTX_LOCK(tsdn, arena->stats.mtx);
|
||||
locked_inc_u64(tsdn, LOCKEDINT_MTX(arena->stats.mtx),
|
||||
&arena->stats.lstats[hindex].ndalloc, 1);
|
||||
if (config_limit_usize_gap) {
|
||||
locked_dec_u64(tsdn, LOCKEDINT_MTX(arena->stats.mtx),
|
||||
&arena->stats.lstats[hindex].active_bytes,
|
||||
usize);
|
||||
}
|
||||
LOCKEDINT_MTX_UNLOCK(tsdn, arena->stats.mtx);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue