Skip to content

Commit c9b023b

Browse files
nwf-msrmjp41
authored andcommitted
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.
1 parent 4e1f582 commit c9b023b

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/mem/pagemap.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -326,9 +326,7 @@ namespace snmalloc
326326
private:
327327
static constexpr size_t COVERED_BITS =
328328
bits::ADDRESS_BITS - GRANULARITY_BITS;
329-
static constexpr size_t CONTENT_BITS =
330-
bits::next_pow2_bits_const(sizeof(T));
331-
static constexpr size_t ENTRIES = 1ULL << (COVERED_BITS + CONTENT_BITS);
329+
static constexpr size_t ENTRIES = 1ULL << COVERED_BITS;
332330
static constexpr size_t SHIFT = GRANULARITY_BITS;
333331

334332
std::atomic<T> top[ENTRIES];

0 commit comments

Comments
 (0)