authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-02-08 15:07:03-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-02-08 15:07:03-08:00
logbb5a4036e82ef15ac73003124fbf1adf3455e6d7
treefc5631f114a3f314a7fc0ad9cf4fe661123becc4
parentea1ce2df9b20b5c91278eb0ed99a9cd0b0949e1a

std.heap.SmpAllocator; fix freelist accounting


1 files changed, 2 insertions(+), 1 deletions(-)

lib/std/heap/SmpAllocator.zig+2-1
...@@ -53,7 +53,7 @@ const min_class = math.log2(@sizeOf(usize));...@@ -53,7 +53,7 @@ const min_class = math.log2(@sizeOf(usize));
53const size_class_count = math.log2(slab_len) - min_class;53const size_class_count = math.log2(slab_len) - min_class;
54/// When a freelist length exceeds this number, a `free` will rotate up to54/// When a freelist length exceeds this number, a `free` will rotate up to
55/// `max_free_search` times before pushing.55/// `max_free_search` times before pushing.
56const max_freelist_len: u8 = 16;56const max_freelist_len: u8 = 255;
57const max_free_search = 1;57const max_free_search = 1;
58/// Before mapping a fresh page, `alloc` will rotate this many times.58/// Before mapping a fresh page, `alloc` will rotate this many times.
59const max_alloc_search = 1;59const max_alloc_search = 1;
...@@ -223,6 +223,7 @@ fn free(context: *anyopaque, memory: []u8, alignment: mem.Alignment, ra: usize)...@@ -223,6 +223,7 @@ fn free(context: *anyopaque, memory: []u8, alignment: mem.Alignment, ra: usize)
223 if (freelist_len < max_freelist_len) {223 if (freelist_len < max_freelist_len) {
224 @branchHint(.likely);224 @branchHint(.likely);
225 defer t.unlock();225 defer t.unlock();
226 t.freelist_lens[class] = freelist_len +| 1;
226 node.* = t.frees[class];227 node.* = t.frees[class];
227 t.frees[class] = @intFromPtr(node);228 t.frees[class] = @intFromPtr(node);
228 return;229 return;