mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-08-26 00:53:34 +03:00
psset stats: Simplify handling.
We can treat the huge and nonhuge cases uniformly using huge state as an array index.
This commit is contained in:
parent
94cd9444c5
commit
55e0f60ca1
5 changed files with 77 additions and 83 deletions
49
src/psset.c
49
src/psset.c
|
|
@ -19,21 +19,20 @@ psset_init(psset_t *psset) {
|
|||
|
||||
static void
|
||||
psset_bin_stats_accum(psset_bin_stats_t *dst, psset_bin_stats_t *src) {
|
||||
dst->npageslabs_huge += src->npageslabs_huge;
|
||||
dst->nactive_huge += src->nactive_huge;
|
||||
dst->ninactive_huge += src->ninactive_huge;
|
||||
|
||||
dst->npageslabs_nonhuge += src->npageslabs_nonhuge;
|
||||
dst->nactive_nonhuge += src->nactive_nonhuge;
|
||||
dst->ninactive_nonhuge += src->ninactive_nonhuge;
|
||||
dst->npageslabs += src->npageslabs;
|
||||
dst->nactive += src->nactive;
|
||||
dst->ninactive += src->ninactive;
|
||||
}
|
||||
|
||||
void
|
||||
psset_stats_accum(psset_stats_t *dst, psset_stats_t *src) {
|
||||
psset_bin_stats_accum(&dst->full_slabs, &src->full_slabs);
|
||||
psset_bin_stats_accum(&dst->full_slabs[0], &src->full_slabs[0]);
|
||||
psset_bin_stats_accum(&dst->full_slabs[1], &src->full_slabs[1]);
|
||||
for (pszind_t i = 0; i < PSSET_NPSIZES; i++) {
|
||||
psset_bin_stats_accum(&dst->nonfull_slabs[i],
|
||||
&src->nonfull_slabs[i]);
|
||||
psset_bin_stats_accum(&dst->nonfull_slabs[i][0],
|
||||
&src->nonfull_slabs[i][0]);
|
||||
psset_bin_stats_accum(&dst->nonfull_slabs[i][1],
|
||||
&src->nonfull_slabs[i][1]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -50,42 +49,34 @@ psset_stats_accum(psset_stats_t *dst, psset_stats_t *src) {
|
|||
JEMALLOC_ALWAYS_INLINE void
|
||||
psset_bin_stats_insert_remove(psset_bin_stats_t *binstats, hpdata_t *ps,
|
||||
bool insert) {
|
||||
size_t *npageslabs_dst = hpdata_huge_get(ps)
|
||||
? &binstats->npageslabs_huge : &binstats->npageslabs_nonhuge;
|
||||
size_t *nactive_dst = hpdata_huge_get(ps)
|
||||
? &binstats->nactive_huge : &binstats->nactive_nonhuge;
|
||||
size_t *ninactive_dst = hpdata_huge_get(ps)
|
||||
? &binstats->ninactive_huge : &binstats->ninactive_nonhuge;
|
||||
|
||||
size_t nactive = hpdata_nactive_get(ps);
|
||||
size_t ninactive = HUGEPAGE_PAGES - nactive;
|
||||
|
||||
size_t mul = insert ? (size_t)1 : (size_t)-1;
|
||||
*npageslabs_dst += mul * 1;
|
||||
*nactive_dst += mul * nactive;
|
||||
*ninactive_dst += mul * ninactive;
|
||||
size_t huge_idx = (size_t)hpdata_huge_get(ps);
|
||||
binstats[huge_idx].npageslabs += mul * 1;
|
||||
size_t nactive = hpdata_nactive_get(ps);
|
||||
binstats[huge_idx].nactive += mul * nactive;
|
||||
binstats[huge_idx].ninactive += mul * (HUGEPAGE_PAGES - nactive);
|
||||
}
|
||||
|
||||
static void
|
||||
psset_bin_stats_insert(psset_bin_stats_t *binstats, hpdata_t *ps) {
|
||||
psset_bin_stats_insert_remove(binstats, ps, /* insert */ true);
|
||||
psset_bin_stats_insert_remove(binstats, ps, true);
|
||||
}
|
||||
|
||||
static void
|
||||
psset_bin_stats_remove(psset_bin_stats_t *binstats, hpdata_t *ps) {
|
||||
psset_bin_stats_insert_remove(binstats, ps, /* insert */ false);
|
||||
psset_bin_stats_insert_remove(binstats, ps, false);
|
||||
}
|
||||
|
||||
static void
|
||||
psset_hpdata_heap_remove(psset_t *psset, pszind_t pind, hpdata_t *ps) {
|
||||
hpdata_age_heap_remove(&psset->pageslabs[pind], ps);
|
||||
psset_bin_stats_remove(&psset->stats.nonfull_slabs[pind], ps);
|
||||
psset_bin_stats_remove(psset->stats.nonfull_slabs[pind], ps);
|
||||
}
|
||||
|
||||
static void
|
||||
psset_hpdata_heap_insert(psset_t *psset, pszind_t pind, hpdata_t *ps) {
|
||||
hpdata_age_heap_insert(&psset->pageslabs[pind], ps);
|
||||
psset_bin_stats_insert(&psset->stats.nonfull_slabs[pind], ps);
|
||||
psset_bin_stats_insert(psset->stats.nonfull_slabs[pind], ps);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -101,7 +92,7 @@ psset_insert(psset_t *psset, hpdata_t *ps) {
|
|||
* We don't ned to track full slabs; just pretend to for stats
|
||||
* purposes. See the comment at psset_bin_stats_adjust.
|
||||
*/
|
||||
psset_bin_stats_insert(&psset->stats.full_slabs, ps);
|
||||
psset_bin_stats_insert(psset->stats.full_slabs, ps);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -124,7 +115,7 @@ psset_remove(psset_t *psset, hpdata_t *ps) {
|
|||
size_t longest_free_range = hpdata_longest_free_range_get(ps);
|
||||
|
||||
if (longest_free_range == 0) {
|
||||
psset_bin_stats_remove(&psset->stats.full_slabs, ps);
|
||||
psset_bin_stats_remove(psset->stats.full_slabs, ps);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue