Skip to content

Commit edd7320

Browse files
committed
Decay Range
Add a backend range that delays returning memory to the next level. This reduces the pressure on the backend global allocator.
1 parent c31afa7 commit edd7320

File tree

5 files changed

+430
-4
lines changed

5 files changed

+430
-4
lines changed

src/snmalloc/backend/meta_protected_range.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ namespace snmalloc
5555
LogRange<3>,
5656
GlobalRange,
5757
CommitRange<PAL>,
58+
DecayRange<PAL, Pagemap>,
5859
StatsRange>;
5960

6061
// Controls the padding around the meta-data range.

src/snmalloc/backend/standard_range.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,14 @@ namespace snmalloc
3737
LogRange<2>,
3838
GlobalRange>;
3939

40-
// Track stats of the committed memory
41-
using Stats = Pipe<GlobalR, CommitRange<PAL>, StatsRange>;
40+
// Decay range caches deallocated memory and gradually releases it
41+
// back to the parent, avoiding expensive repeated decommit/recommit
42+
// cycles for transient allocation patterns.
43+
using DecayR = Pipe<GlobalR, CommitRange<PAL>, DecayRange<PAL, Pagemap>>;
44+
45+
// Track stats of the memory handed out (outside decay so stats
46+
// methods are directly visible to StatsCombiner).
47+
using Stats = Pipe<DecayR, StatsRange>;
4248

4349
private:
4450
static constexpr size_t page_size_bits =

src/snmalloc/backend_helpers/backend_helpers.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "buddy.h"
66
#include "commitrange.h"
77
#include "commonconfig.h"
8+
#include "decayrange.h"
89
#include "defaultpagemapentry.h"
910
#include "empty_range.h"
1011
#include "globalrange.h"

0 commit comments

Comments
 (0)