FlatPagemap: Stop allocating way more space than needed

FlatPagemap computes the size of its internal `top` array as if it needed an
entry per byte, rather than an entry per instance of its template type T.  In
practice. T has always been uint8_t so far, so this hasn't mattered, but when
we use a larger type, suddenly FlatPagemap balloons to much larger than needed.
This commit is contained in:
Nathaniel Filardo
2020-07-31 23:22:37 +01:00
committed by Matthew Parkinson
parent 4e1f5829a7
commit c9b023be23

View File

@@ -326,9 +326,7 @@ namespace snmalloc
private:
static constexpr size_t COVERED_BITS =
bits::ADDRESS_BITS - GRANULARITY_BITS;
static constexpr size_t CONTENT_BITS =
bits::next_pow2_bits_const(sizeof(T));
static constexpr size_t ENTRIES = 1ULL << (COVERED_BITS + CONTENT_BITS);
static constexpr size_t ENTRIES = 1ULL << COVERED_BITS;
static constexpr size_t SHIFT = GRANULARITY_BITS;
std::atomic<T> top[ENTRIES];