chore: pull helio and adjust mimalloc for 32MiB segments (#3174)

* chore: pull helio and adjust mimalloc for 32MiB segments
This commit is contained in:
Kostas Kyrimis 2024-07-02 10:29:39 +03:00 committed by GitHub
parent 5956275818
commit 830d73a888
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 13 additions and 10 deletions

2
helio

@ -1 +1 @@
Subproject commit 33673ea2952529c4e8a9dca9903e38a3dbafef58
Subproject commit deb4c1ac263c00d6602a3e1158ccae04a9b28417

View file

@ -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() {

View file

@ -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;