diff --git a/helio b/helio index 33673ea29..deb4c1ac2 160000 --- a/helio +++ b/helio @@ -1 +1 @@ -Subproject commit 33673ea2952529c4e8a9dca9903e38a3dbafef58 +Subproject commit deb4c1ac263c00d6602a3e1158ccae04a9b28417 diff --git a/src/core/segment_allocator.cc b/src/core/segment_allocator.cc index abf6801ea..654af1847 100644 --- a/src/core/segment_allocator.cc +++ b/src/core/segment_allocator.cc @@ -7,15 +7,15 @@ #include "base/logging.h" -constexpr size_t kSegmentShift = MI_SEGMENT_SHIFT; - namespace dfly { SegmentAllocator::SegmentAllocator(mi_heap_t* heap) : heap_(heap) { - // mimalloc uses 4MiB segments and we might need change this code if it changes. - constexpr size_t kSegLogSpan = 32 - kSegmentIdBits + 3; - static_assert(kSegLogSpan == kSegmentShift); - static_assert((~kSegmentAlignMask) == (MI_SEGMENT_SIZE - 1)); + // 256GB + constexpr size_t limit = 1ULL << 35; + static_assert((1ULL << (kSegmentIdBits + kSegmentShift)) == limit); + // mimalloc uses 32MiB segments and we might need change this code if it changes. + static_assert(kSegmentShift == MI_SEGMENT_SHIFT); + static_assert((~kSegmentAlignMask) == (MI_SEGMENT_MASK)); } void SegmentAllocator::ValidateMapSize() { diff --git a/src/core/segment_allocator.h b/src/core/segment_allocator.h index 5c98c7719..cc5e640a5 100644 --- a/src/core/segment_allocator.h +++ b/src/core/segment_allocator.h @@ -17,16 +17,19 @@ namespace dfly { /** * @brief Tightly coupled with mi_malloc 2.x implementation. - * Fetches 4MiB segment pointers from the allocated pointers. + * Fetches 32MiB segment pointers from the allocated pointers. * Provides own indexing of small pointers to real address space using the segment ptrs/ */ class SegmentAllocator { - static constexpr uint32_t kSegmentIdBits = 13; + // (2 ^ 10) total segments + static constexpr uint32_t kSegmentIdBits = 10; static constexpr uint32_t kSegmentIdMask = (1u << kSegmentIdBits) - 1; + // (2 ^ 25) total bytes per segment = 32MiB + static constexpr uint32_t kSegmentShift = 25; // Segment range that we cover within a single segment. - static constexpr uint64_t kSegmentAlignMask = ~((1ULL << (32 - kSegmentIdBits + 3)) - 1); + static constexpr uint64_t kSegmentAlignMask = ~((1ULL << kSegmentShift) - 1); public: using Ptr = uint32_t;