首页 > 代码库 > jemalloc存储块(region、run、chunk)
jemalloc存储块(region、run、chunk)
jemalloc中按存储单元的块大小分,有region、run、chunk三种存储块。
最小的单元是region,它的大小是8字节~14KB,1个或多个相同大小的region组成一个run。
run的大小必须是页(4kB)的整数倍,相同大小region对应的run的大小总是相同的,多个run组成一个chunk。
chunk的大小固定是2M(或4M,可配置)。
region size | run size | number of region in run |
8 | 4K | 512 |
16 | 4k | 256 |
32 | 4k | 128 |
48 | 12k | 256 |
64 | 4k | 64 |
80 | 20k | 256 |
96 | 12k | 128 |
112 | 28k | 256 |
128 | 4k | 32 |
160 | 20k | 128 |
192 | 12k | 64 |
224 | 28k | 128 |
256 | 4k | 16 |
320 | 20k | 64 |
384 | 12k | 32 |
448 | 28k | 64 |
512 | 4k | 8 |
640 | 20k | 32 |
768 | 12k | 16 |
896 | 28k | 32 |
1024 | 4k | 4 |
1280 | 20k | 16 |
1536 | 12k | 8 |
1792 | 28k | 16 |
2048 | 4k | 2 |
2560 | 20k | 8 |
3072 | 12k | 4 |
3584 | 20k | 8 |
4096 | 4k | 1 |
5120 | 20k | 4 |
6144 | 12k | 2 |
7168 | 28k | 4 |
8192 | 8k | 1 |
10240 | 20k | 2 |
12288 | 12k | 1 |
14336 | 28k | 2 |
相关代码:
arena_bin_info_t arena_bin_info[NBINS]; static void bin_info_init(void) { arena_bin_info_t *bin_info; #define BIN_INFO_INIT_bin_yes(index, size) \ bin_info = &arena_bin_info[index]; bin_info->reg_size = size; bin_info_run_size_calc(bin_info); bitmap_info_init(&bin_info->bitmap_info, bin_info->nregs); #define BIN_INFO_INIT_bin_no(index, size) #define SC(index, lg_grp, lg_delta, ndelta, bin, lg_delta_lookup) \ BIN_INFO_INIT_bin_##bin(index, (ZU(1)<<lg_grp) + (ZU(ndelta)<<lg_delta)) SIZE_CLASSES #undef BIN_INFO_INIT_bin_yes #undef BIN_INFO_INIT_bin_no #undef SC }
gdb中打印arena_bin_info:
(gdb) p je_arena_bin_info $353 = {{ reg_size = 8, redzone_size = 0, reg_interval = 8, run_size = 4096, nregs = 512, bitmap_info = { nbits = 512, ngroups = 8 }, reg0_offset = 0 }, { reg_size = 16, redzone_size = 0, reg_interval = 16, run_size = 4096, nregs = 256, bitmap_info = { nbits = 256, ngroups = 4 }, reg0_offset = 0 }, { reg_size = 32, redzone_size = 0, reg_interval = 32, run_size = 4096, nregs = 128, bitmap_info = { nbits = 128, ngroups = 2 }, reg0_offset = 0 }, { ... }, { reg_size = 12288, redzone_size = 0, reg_interval = 12288, run_size = 12288, nregs = 1, bitmap_info = { nbits = 1, ngroups = 1 }, reg0_offset = 0 }, { reg_size = 14336, redzone_size = 0, reg_interval = 14336, run_size = 28672, nregs = 2, bitmap_info = { nbits = 2, ngroups = 1 }, reg0_offset = 0 }}
region、run、chunk之间的位置关系如下:
jemalloc存储块(region、run、chunk)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。