Skip to content

Commit bc07300

Browse files
committed
Refactored inline metadata and ptr resolution so that everything is OOL. noticeable speed improvements.
1 parent 6ce5a6c commit bc07300

4 files changed

Lines changed: 3 additions & 1161 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ docs/notes.md
22
perf.data
33
include/
44
src/
5+
zialloc_wrapper.cpp
56

67
# Build directories
78
build/

docs/zialloc-design.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ Within one page, all slots have identical stride/usable size and allocation stat
3535

3636
XL allocations semi-bypass the page/segment class system and are mmapped as standalone mappings with inline XL headers.
3737

38-
Metadata model is mixed inline + allocator-owned(OOL):
39-
- Inline per regular chunk header: owning page pointer, slot index, magic value (canary)
38+
Metadata model is entirely allocator-owned(OOL):
39+
- Chunks can resolve their owning page and slot idx using pointer arithmetic on themselves
4040
- Per-page metadata: bitmap, used counts, owner TID, deferred-free ring
4141
- Per-segment metadata: class, page array, full-page count, chunk-geometry lock-in, integrity key/canary
4242
- XL metadata is inline in front of returned pointer (`XLHeader`)

zialloc/mem.h

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,6 @@
11
#ifndef SEGMENTS_H
22
#define SEGMENTS_H
33

4-
/*
5-
Heap-Level: |Metadata|Segment|guard|Segment|guard|Segment|...| # size =
6-
2GB Segment-Level: |Metadata|guard|slot|slot|slot|...| # size = 4MB->(32MB*)
7-
(this would mean that about 2048 segments couldfit inside of our heap at any
8-
time which is almost a bit too much so what I will actualy do is set this value
9-
higher meaning each segment is larger. if we use the same pointer access trick
10-
as before and maintain our alignment then we should be able to access any given
11-
page in constant time so it hsouldn't be that big of a deal that we have a
12-
larger segment size. Thus set segment size to say 32MB?) Page-Level:
13-
|Metadata|chunk|chunk|chunk|...|guard| # size : small=64KB,
14-
med=512KB, large=4MiB ---> this means we can fit multiple large pages w/i a
15-
segment, XL allocations will still be handled using MMAP.
16-
17-
Heap metadata: we should track how many segments are active, their types,
18-
the location of the metadata corresponding to a given chunk so that we can
19-
access it if it contains a size and space we need.
20-
.
21-
It contains information about the sizes that the pages w/i it support, a
22-
bitmap that tracks the allocation status of the contained pages. This can be
23-
found by querying the metadata of each page and checking if used == 0. Maybe
24-
also track the status of the segment itself; any given segment could be
25-
completely empty, active, or full. But we should probably make sure there is a
26-
minimum number (1sm, 1md) active at all times.
27-
28-
29-
I don't intend to implement any form of coalescing - much like partition
30-
alloc, I will release memory to OS but keep the vmem reservation
31-
32-
*/
33-
// lets make sure our guard pages are the same size as the chunks so that we can
34-
// handle indexing w/ offsets normally
35-
364
#include "types.h"
375
#include <cstdint>
386
#include <iostream>

0 commit comments

Comments
 (0)