align CentralFreeList on cache line size instead of just 64

We had hardcoded size alignment on 64 bytes, seemingly to avoid
cacheline contention when taking per-size-class central free list
locks. But it makes more sense to do platform specific alignment.

I did consider std::hardware_constructive_interference_size, but
practical values seem to differ from what we have configured at least
on some platforms.
This commit is contained in:
Aliaksey Kandratsenka 2024-02-04 19:33:12 -05:00
parent 353816fd9d
commit a05bab586a
2 changed files with 2 additions and 3 deletions

View File

@ -45,7 +45,7 @@
namespace tcmalloc {
// Data kept per size-class in central cache.
class alignas(64) CentralFreeList {
class CACHELINE_ALIGNED CentralFreeList {
public:
constexpr CentralFreeList() {}

View File

@ -60,8 +60,7 @@ void Static::InitStaticVars() {
span_allocator_.New(); // Reduce cache conflicts
span_allocator_.New(); // Reduce cache conflicts
stacktrace_allocator_.Init();
// Do a bit of sanitizing: make sure central_cache is aligned properly
CHECK_CONDITION((sizeof(central_cache_[0]) % 64) == 0);
for (int i = 0; i < num_size_classes(); ++i) {
central_cache_[i].Init(i);
}