You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fast path tcache performance is critical as it's expected to be accessed very frequently. We aim to improve the fast path significantly with the following two changes:
Optimize tcache and tsd for a more compact layout. We'd like have higher density of the tcache bins to improve cache locality. Currently tbins are 32 bytes, which will be cut down to 24. Also pack TSD tighter.
@jasone : to embed tcache into tsd, my current plan is to split the tbins into two bins: small and large, basically:
tcache_t {
....
tbin_t small_bins[NBINS];
tbin_t *large_bins; /Dynamically sized/
}
So that we embed small bins for better locality, while keep the ability to set lg_tcache_max, i.e. nhbins. Does that make sense to you? Or you think we should just get rid of lg_tcache_max and make the size static?
I think we should make large_bins have NSIZES - NBINS elements so that no dynamic sizing is necessary, and probably place tcache at the end of tsd so that the unused elements don't break up the utilized cachelines.
The first half of this (embedding tcache into tsd) is implemented in #736. Tested with @davidtgoldblatt using test/stress/microbench, which shows a ~15% improvement on malloc / free / etc. Likely this made the fast path more pipeline friendly. A sample output w/ --enable-prof:
With #736:
I'll start working on splitting tcache into tcache_fast and tcache slow, to be placed at the beginning and end of tsd respectively. Also make tbin layout more compact.
Activity
interwq commentedon Mar 28, 2017
@jasone : to embed tcache into tsd, my current plan is to split the tbins into two bins: small and large, basically:
tcache_t {
....
tbin_t small_bins[NBINS];
tbin_t *large_bins; /Dynamically sized/
}
So that we embed small bins for better locality, while keep the ability to set lg_tcache_max, i.e. nhbins. Does that make sense to you? Or you think we should just get rid of lg_tcache_max and make the size static?
jasone commentedon Mar 28, 2017
I think we should make
large_binshaveNSIZES - NBINSelements so that no dynamic sizing is necessary, and probably place tcache at the end of tsd so that the unused elements don't break up the utilized cachelines.interwq commentedon Mar 28, 2017
That sounds reasonable. For the unused large bins (binind > nhbins), probably not allocating their avail arrays?
jasone commentedon Mar 28, 2017
Ah right, definitely avoid allocating more avail slots than actually used.
interwq commentedon Apr 6, 2017
The first half of this (embedding tcache into tsd) is implemented in #736. Tested with @davidtgoldblatt using test/stress/microbench, which shows a ~15% improvement on malloc / free / etc. Likely this made the fast path more pipeline friendly. A sample output w/ --enable-prof:
With #736:
Before (d4e98bc):
I'll start working on splitting tcache into tcache_fast and tcache slow, to be placed at the beginning and end of tsd respectively. Also make tbin layout more compact.
[-]Embed tcache struct into tsd[/-][+]Optimizing TSD and thread cache layout[/+]interwq commentedon Apr 7, 2017
Closed via #736 and #752.