Move some structures to cache lines

Prevent some bad sharing of cache lines by aligning some concurrently
accessed strucutures.
This commit is contained in:
Matthew Parkinson
2021-10-28 14:23:15 +01:00
committed by Matthew Parkinson
parent 3407347925
commit fd408637a7
3 changed files with 8 additions and 8 deletions

View File

@@ -11,7 +11,7 @@ namespace snmalloc
using ABAT = ABA<T, c>;
private:
ABAT stack;
alignas(CACHELINE_SIZE) ABAT stack;
public:
constexpr MPMCStack() = default;

View File

@@ -79,6 +79,12 @@ namespace snmalloc
ModArray<NUM_SLAB_SIZES, MPMCStack<ChunkRecord, RequiresInit>>
decommitted_chunk_stack;
/**
* Which is the current epoch to place dealloced chunks, and the
* first place we look for allocating chunks.
*/
alignas(CACHELINE_SIZE) std::atomic<size_t> epoch{0};
/**
* All memory issued by this address space manager
*/
@@ -88,12 +94,6 @@ namespace snmalloc
std::atomic<ChunkAllocatorLocalState*> all_local{nullptr};
/**
* Which is the current epoch to place dealloced chunks, and the
* first place we look for allocating chunks.
*/
std::atomic<size_t> epoch{0};
// Flag to ensure one-shot registration with the PAL for notifications.
std::atomic_flag register_decay{};

View File

@@ -28,8 +28,8 @@ namespace snmalloc
friend class Pool;
private:
std::atomic_flag lock = ATOMIC_FLAG_INIT;
MPMCStack<T, PreZeroed> stack;
std::atomic_flag lock = ATOMIC_FLAG_INIT;
T* list{nullptr};
public: