Cache an arena's index in the arena.

This saves us a pointer hop down some perf-sensitive paths.
This commit is contained in:
David Goldblatt
2021-01-29 21:22:57 -08:00
committed by David Goldblatt
parent 229994a204
commit 4c46e11365
3 changed files with 8 additions and 1 deletions

View File

@@ -3,7 +3,7 @@
static inline unsigned
arena_ind_get(const arena_t *arena) {
return base_ind_get(arena->base);
return arena->ind;
}
static inline void

View File

@@ -83,6 +83,12 @@ struct arena_s {
*/
bins_t bins[SC_NBINS];
/*
* A cached copy of base->ind. This can get accessed on hot paths;
* looking it up in base requires an extra pointer hop / cache miss.
*/
unsigned ind;
/*
* Base allocator, from which arena metadata are allocated.
*