From db15a39d75d59fd20bb2ed10905297f312054d32 Mon Sep 17 00:00:00 2001 From: Slobodan Predolac Date: Fri, 26 Jun 2026 15:15:36 -0700 Subject: [PATCH] Keep pac last in pa_shard_s to fix SEC-in-PAC layout regression 9c1a484e embedded sec_t in pac_t (+~48B). Since pac sits before the hot hpa/edata_cache fields in pa_shard_s, the larger pac_t shifts them and regresses the free/extent paths ~2% on the fill-flush microbenchmark -- even though SEC is disabled by default and no SEC code runs; it is purely a struct-layout effect. Move pac to the last field so its growth shifts only the trailing all_bins[] flex array. Pure reorder, no functional change. Validated with the fill-flush microbenchmark (500 threads, 256 B, MALLOC_CONF=tcache:true,prof:true), turbo pinned, interleaved medians: on AMD EPYC 9D64 (x86-64) bad regresses ~2% and the reorder restores the baseline; on ARM Neoverse-V2 (aarch64) there is no measurable regression and the reorder is neutral. --- include/jemalloc/internal/pa.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/jemalloc/internal/pa.h b/include/jemalloc/internal/pa.h index fb017f65..3010a3be 100644 --- a/include/jemalloc/internal/pa.h +++ b/include/jemalloc/internal/pa.h @@ -91,9 +91,6 @@ struct pa_shard_s { */ bool ever_used_hpa; - /* Allocates from a PAC. */ - pac_t pac; - hpa_shard_t hpa; /* The source of edata_t objects. */ @@ -109,6 +106,9 @@ struct pa_shard_s { /* The base from which we get the ehooks and allocate metadat. */ base_t *base; + + /* Allocates from a PAC. */ + pac_t pac; }; static inline bool