Skip to content

Commit

Permalink
common: define kMiniHeapSize and use it in MeshableArena's CheapHeap (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
bpowers authored Apr 6, 2024
1 parent bc5cbe2 commit 0a4294e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ static constexpr int kMapShared = 1;
static constexpr int kMapShared = kMeshingEnabled ? MAP_SHARED : MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE;
#endif

// we have to define this here for use in meshable_arena's CheapHeap we allocate
// MiniHeaps out of. We validate (and fail compilation) if this gets out of date
// with a static_assert at the bottom of mini_heap.h
static constexpr size_t kMiniHeapSize = 64;

static constexpr size_t kMinObjectSize = 16;
static constexpr size_t kMaxSize = 16384;
static constexpr size_t kClassSizesMax = 25;
Expand Down
2 changes: 1 addition & 1 deletion src/meshable_arena.h
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ class MeshableArena : public mesh::OneWayMmapHeap {
atomic<MiniHeapID> *_mhIndex{nullptr};

protected:
CheapHeap<64, kArenaSize / kPageSize> _mhAllocator{};
CheapHeap<kMiniHeapSize, kArenaSize / kPageSize> _mhAllocator{};
MWC _fastPrng;

private:
Expand Down
1 change: 1 addition & 0 deletions src/mini_heap.h
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,7 @@ typedef FixedArray<MiniHeap, 63> MiniHeapArray;
static_assert(sizeof(pid_t) == 4, "pid_t not 32-bits!");
static_assert(sizeof(mesh::internal::Bitmap) == 32, "Bitmap too big!");
static_assert(sizeof(MiniHeap) == 64, "MiniHeap too big!");
static_assert(sizeof(MiniHeap) == kMiniHeapSize, "MiniHeap size mismatch");
static_assert(sizeof(MiniHeapArray) == 64 * sizeof(void *), "MiniHeapArray too big!");
} // namespace mesh

Expand Down

0 comments on commit 0a4294e

Please sign in to comment.