mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-05-11 23:46:22 +03:00
Fix bug in pa_microbench
pa_microbench was creating its own emap_t per shard on top of the arena_emap_global that JET malloc initializes during jet_malloc(16) at startup, breaking the production assumption of one rtree per process. Fix it by reusing the existing JET emap.
This commit is contained in:
parent
8072ccc5e9
commit
76015f519f
1 changed files with 12 additions and 11 deletions
|
|
@ -56,12 +56,20 @@ typedef struct {
|
|||
/* Structure to group per-shard PA infrastructure */
|
||||
typedef struct {
|
||||
base_t *base; /* Base allocator */
|
||||
emap_t emap; /* Extent map */
|
||||
pa_shard_t pa_shard; /* PA shard */
|
||||
pa_shard_stats_t shard_stats; /* PA shard statistics */
|
||||
malloc_mutex_t stats_mtx; /* Statistics mutex */
|
||||
} shard_infrastructure_t;
|
||||
|
||||
/*
|
||||
* The TSD-local rtree_ctx cache assumes a single rtree per process. JET's
|
||||
* malloc init already populates that cache against `arena_emap_global`, so
|
||||
* any additional emap we create would silently share the cache and have
|
||||
* its registrations leak into JET's leaves. Reuse arena_emap_global to
|
||||
* keep the invariant.
|
||||
*/
|
||||
extern emap_t jet_arena_emap_global;
|
||||
|
||||
static FILE *g_stats_output = NULL; /* Output file for stats */
|
||||
static size_t g_alloc_counter = 0; /* Global allocation counter */
|
||||
static allocation_record_t *g_alloc_records =
|
||||
|
|
@ -159,6 +167,8 @@ initialize_pa_infrastructure(int num_shards) {
|
|||
return true;
|
||||
}
|
||||
|
||||
/* jet_arena_emap_global was already initialized by JET malloc init. */
|
||||
|
||||
for (int i = 0; i < num_shards; i++) {
|
||||
/* Create a separate base allocator for each shard */
|
||||
g_shard_infra[i].base = base_new(tsd_tsdn(tsd_fetch()),
|
||||
|
|
@ -171,15 +181,6 @@ initialize_pa_infrastructure(int num_shards) {
|
|||
return true;
|
||||
}
|
||||
|
||||
/* Initialize emap for this shard */
|
||||
if (emap_init(&g_shard_infra[i].emap, g_shard_infra[i].base,
|
||||
/* zeroed */ false)) {
|
||||
printf("DEBUG: Failed to initialize emap %d\n", i);
|
||||
/* Clean up partially initialized shards */
|
||||
cleanup_pa_infrastructure(num_shards);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Initialize stats mutex */
|
||||
if (malloc_mutex_init(&g_shard_infra[i].stats_mtx,
|
||||
"pa_shard_stats", WITNESS_RANK_OMIT,
|
||||
|
|
@ -197,7 +198,7 @@ initialize_pa_infrastructure(int num_shards) {
|
|||
|
||||
if (pa_shard_init(tsd_tsdn(tsd_fetch()),
|
||||
&g_shard_infra[i].pa_shard, &g_pa_central,
|
||||
&g_shard_infra[i].emap /* emap */,
|
||||
&jet_arena_emap_global /* emap (shared) */,
|
||||
g_shard_infra[i].base, i /* ind */,
|
||||
&g_shard_infra[i].shard_stats /* stats */,
|
||||
&g_shard_infra[i].stats_mtx /* stats_mtx */,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue