jemalloc 深入分析 之Region size 设计以及和 index 对应关系

为了更好的阅读效果,推荐下载pdf文档:
详细文章请参考:《jemalloc 深入分析》
https://github.com/everschen/tools/blob/master/DOC/Jemalloc.pdf
https://download.csdn.net/download/ip5108/10941278

  1. Region size 设计以及和 index 对应关系
    6.1. Region size步长的设计
    下图是对于从reg_size=64开始的增加规则,可以看出步长增加规则是每次在相邻幂次数位加1,得到下一个reg_size值。
    在这里插入图片描述

6.2. Region相关的参数定义(anrdoid 64bits)
以下配置是对应于如下的系统参数: (LG_SIZEOF_PTR == 3 && LG_TINY_MIN == 3 && LG_QUANTUM == 4 && LG_PAGE == 12)
#define NTBINS 1
#define NLBINS 29
#define NBINS 36
#define NSIZES 232
#define NPSIZES 199
#define LG_TINY_MAXCLASS 3
#define LOOKUP_MAXCLASS ((((size_t)1) << 11) + (((size_t)4) << 9))
#define SMALL_MAXCLASS ((((size_t)1) << 13) + (((size_t)3) << 11))
#define LG_LARGE_MINCLASS 14
#define HUGE_MAXCLASS ((((size_t)1) << 62) + (((size_t)3) << 60))
6.3. SIZE_CLASSES 定义
#define SIZE_CLASSES
/* index, lg_grp, lg_delta, ndelta, psz, bin, lg_delta_lookup /
SC( 0, 3, 3, 0, no, yes, 3)

SC( 1, 3, 3, 1, no, yes, 3)
SC( 2, 4, 4, 1, no, yes, 4)
SC( 3, 4, 4, 2, no, yes, 4)
SC( 4, 4, 4, 3, no, yes, 4)

SC( 5, 6, 4, 1, no, yes, 4)
SC( 6, 6, 4, 2, no, yes, 4)
SC( 7, 6, 4, 3, no, yes, 4)
SC( 8, 6, 4, 4, no, yes, 4)

SC( 9, 7, 5, 1, no, yes, 5)
SC( 10, 7, 5, 2, no, yes, 5)
SC( 11, 7, 5, 3, no, yes, 5)
SC( 12, 7, 5, 4, no, yes, 5)

SC( 13, 8, 6, 1, no, yes, 6)
SC( 14, 8, 6, 2, no, yes, 6)
SC( 15, 8, 6, 3, no, yes, 6)
SC( 16, 8, 6, 4, no, yes, 6)

SC( 17, 9, 7, 1, no, yes, 7)
SC( 18, 9, 7, 2, no, yes, 7)
SC( 19, 9, 7, 3, no, yes, 7)
SC( 20, 9, 7, 4, no, yes, 7)

SC( 21, 10, 8, 1, no, yes, 8)
SC( 22, 10, 8, 2, no, yes, 8)
SC( 23, 10, 8, 3, no, yes, 8)
SC( 24, 10, 8, 4, no, yes, 8)

SC( 25, 11, 9, 1, no, yes, 9)
SC( 26, 11, 9, 2, no, yes, 9)
SC( 27, 11, 9, 3, no, yes, 9)
SC( 28, 11, 9, 4, yes, yes, 9)

SC( 29, 12, 10, 1, no, yes, no)
SC( 30, 12, 10, 2, no, yes, no)
SC( 31, 12, 10, 3, no, yes, no)
SC( 32, 12, 10, 4, yes, yes, no)

SC( 33, 13, 11, 1, no, yes, no)
SC( 34, 13, 11, 2, yes, yes, no) \
SC( 35, 13, 11, 3, no, yes, no) \ //small max
SC( 36, 13, 11, 4, yes, no, no) \ //large start = 2^14

SC( 37, 14, 12, 1, yes, no, no)
SC( 38, 14, 12, 2, yes, no, no)
SC( 39, 14, 12, 3, yes, no, no)
SC( 40, 14, 12, 4, yes, no, no)

SC( 41, 15, 13, 1, yes, no, no)
SC( 42, 15, 13, 2, yes, no, no)
SC( 43, 15, 13, 3, yes, no, no)
SC( 44, 15, 13, 4, yes, no, no)

SC( 45, 16, 14, 1, yes, no, no)
SC( 46, 16, 14, 2, yes, no, no)
SC( 47, 16, 14, 3, yes, no, no)
SC( 48, 16, 14, 4, yes, no, no)

SC( 49, 17, 15, 1, yes, no, no)
SC( 50, 17, 15, 2, yes, no, no)
SC( 51, 17, 15, 3, yes, no, no)
SC( 52, 17, 15, 4, yes, no, no)

SC( 53, 18, 16, 1, yes, no, no)
SC( 54, 18, 16, 2, yes, no, no)
SC( 55, 18, 16, 3, yes, no, no)
SC( 56, 18, 16, 4, yes, no, no)

SC( 57, 19, 17, 1, yes, no, no)
SC( 58, 19, 17, 2, yes, no, no)
SC( 59, 19, 17, 3, yes, no, no)
SC( 60, 19, 17, 4, yes, no, no)

SC( 61, 20, 18, 1, yes, no, no)
SC( 62, 20, 18, 2, yes, no, no)
SC( 63, 20, 18, 3, yes, no, no)
SC( 64, 20, 18, 4, yes, no, no)

SC( 65, 21, 19, 1, yes, no, no)
SC( 66, 21, 19, 2, yes, no, no)
SC( 67, 21, 19, 3, yes, no, no)
SC( 68, 21, 19, 4, yes, no, no)

SC( 69, 22, 20, 1, yes, no, no)
SC( 70, 22, 20, 2, yes, no, no)
SC( 71, 22, 20, 3, yes, no, no)
SC( 72, 22, 20, 4, yes, no, no)

SC( 73, 23, 21, 1, yes, no, no)
SC( 74, 23, 21, 2, yes, no, no)
SC( 75, 23, 21, 3, yes, no, no)
SC( 76, 23, 21, 4, yes, no, no)

SC( 77, 24, 22, 1, yes, no, no)
SC( 78, 24, 22, 2, yes, no, no)
SC( 79, 24, 22, 3, yes, no, no)
SC( 80, 24, 22, 4, yes, no, no)

SC( 81, 25, 23, 1, yes, no, no)
SC( 82, 25, 23, 2, yes, no, no)
SC( 83, 25, 23, 3, yes, no, no)
SC( 84, 25, 23, 4, yes, no, no)

SC( 85, 26, 24, 1, yes, no, no)
SC( 86, 26, 24, 2, yes, no, no)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值