jemalloc / jemalloc

http://jemalloc.net/
Other
9.39k stars 1.44k forks source link

Tune tcache ncached_max #1588

Open interwq opened 5 years ago

interwq commented 5 years ago

Currently the tcache avail array occupies 24K+192B (3096 pointers), which is quite awkward since we are paying the 7 pages for the array but only utilize ~6 pages.

The ncached_max for each bin is calculated here: https://github.com/jemalloc/jemalloc/blob/dev/src/tcache.c#L757

There are some bins that might deserve larger size, e.g. bin 12 (sz 256) is only 32 now.

bin 0: 200 items (nregs 512), total 200
bin 1: 200 items (nregs 256), total 400
bin 2: 200 items (nregs 128), total 600
bin 3: 200 items (nregs 256), total 800
bin 4: 128 items (nregs 64), total 928
bin 5: 200 items (nregs 256), total 1128
bin 6: 200 items (nregs 128), total 1328
bin 7: 200 items (nregs 256), total 1528
bin 8: 64 items (nregs 32), total 1592
bin 9: 200 items (nregs 128), total 1792
bin 10: 128 items (nregs 64), total 1920
bin 11: 200 items (nregs 128), total 2120
bin 12: 32 items (nregs 16), total 2152
bin 13: 128 items (nregs 64), total 2280
bin 14: 64 items (nregs 32), total 2344
bin 15: 128 items (nregs 64), total 2472
bin 16: 20 items (nregs 8), total 2492
bin 17: 64 items (nregs 32), total 2556
bin 18: 32 items (nregs 16), total 2588
bin 19: 64 items (nregs 32), total 2652
bin 20: 20 items (nregs 4), total 2672
bin 21: 32 items (nregs 16), total 2704
bin 22: 20 items (nregs 8), total 2724
bin 23: 32 items (nregs 16), total 2756
bin 24: 20 items (nregs 2), total 2776
bin 25: 20 items (nregs 8), total 2796
bin 26: 20 items (nregs 4), total 2816
bin 27: 20 items (nregs 8), total 2836
bin 28: 20 items (nregs 1), total 2856
bin 29: 20 items (nregs 4), total 2876
bin 30: 20 items (nregs 2), total 2896
bin 31: 20 items (nregs 4), total 2916
bin 32: 20 items (nregs 1), total 2936
bin 33: 20 items (nregs 2), total 2956
bin 34: 20 items (nregs 1), total 2976
bin 35: 20 items (nregs 2), total 2996
bin 36: 20 items, total 3016
bin 37: 20 items, total 3036
bin 38: 20 items, total 3056
bin 39: 20 items, total 3076
bin 40: 20 items, total 3096
interwq commented 5 years ago

Discussed with @yinan1048576 offline; didn't see a quick fix w/o any arbitrary threshold etc. Will come back to this later when time allows.