Major refactor of snmalloc (#343)
# Pagemap The Pagemap now stores all the meta-data for the object allocation. The meta-data in the pagemap is effectively a triple of the sizeclass, the remote allocator, and a pointer to a 64 byte block of meta-data for this chunk of memory. By storing the pointer to a block, it allows the pagemap to handle multiple slab sizes without branching on the fast path. There is one entry in the pagemap per 16KiB of address space, but by using the same entry in the pagemap for 4 adjacent entries, then we can treat a 64KiB range can be treated as a single slab of allocations. This change also means there is almost no capability amplification required by the implementation on CHERI for finding meta-data. The only amplification is required, when we change the way a chunk is used to a size of object allocation. # Backend There is a second major aspect of the refactor that there is now a narrow API that abstracts the Pagemap, PAL and address space management. This should better enable the compartmentalisation and makes it easier to produce alternative backends for various research directions. This is a template parameter that can be used to specialised by the front-end in different ways. # Thread local state The thread local state has been refactored into two components, one (called 'localalloc') that is stored directly in the TLS and is constant initialised, and one that is allocated in the address space (called 'coreallloc') which is lazily created and pooled. # Difference This removes Superslabs/Medium slabs as there meta-data is now part of the pagemap.
This commit is contained in:
committed by
GitHub
parent
18d7cc99b6
commit
f0e2ab702a
@@ -1,13 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include "../ds/bits.h"
|
||||
#include "../mem/sizeclass.h"
|
||||
#include "../mem/sizeclasstable.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#ifdef USE_SNMALLOC_STATS
|
||||
# include "../ds/csv.h"
|
||||
# include "sizeclass.h"
|
||||
|
||||
# include <cstring>
|
||||
# include <iostream>
|
||||
@@ -18,11 +17,13 @@ namespace snmalloc
|
||||
template<size_t N, size_t LARGE_N>
|
||||
struct AllocStats
|
||||
{
|
||||
constexpr AllocStats() = default;
|
||||
|
||||
struct CurrentMaxPair
|
||||
{
|
||||
size_t current = 0;
|
||||
size_t max = 0;
|
||||
size_t used = 0;
|
||||
size_t current{0};
|
||||
size_t max{0};
|
||||
size_t used{0};
|
||||
|
||||
void inc()
|
||||
{
|
||||
@@ -34,7 +35,9 @@ namespace snmalloc
|
||||
|
||||
void dec()
|
||||
{
|
||||
SNMALLOC_ASSERT(current > 0);
|
||||
// Split stats means this is not true.
|
||||
// TODO reestablish checks, when we sanitise the stats.
|
||||
// SNMALLOC_ASSERT(current > 0);
|
||||
current--;
|
||||
}
|
||||
|
||||
@@ -64,11 +67,13 @@ namespace snmalloc
|
||||
|
||||
struct Stats
|
||||
{
|
||||
constexpr Stats() = default;
|
||||
|
||||
CurrentMaxPair count;
|
||||
CurrentMaxPair slab_count;
|
||||
uint64_t time = Aal::tick();
|
||||
uint64_t ticks = 0;
|
||||
double online_average = 0;
|
||||
uint64_t time{0};
|
||||
uint64_t ticks{0};
|
||||
double online_average{0};
|
||||
|
||||
bool is_empty()
|
||||
{
|
||||
@@ -413,5 +418,13 @@ namespace snmalloc
|
||||
<< csv.endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
void start()
|
||||
{
|
||||
#ifdef USE_SNMALLOC_STATS
|
||||
for (size_t i = 0; i < N; i++)
|
||||
sizeclass[i].time = Aal::tick();
|
||||
#endif
|
||||
}
|
||||
};
|
||||
} // namespace snmalloc
|
||||
|
||||
Reference in New Issue
Block a user