authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-02-06 17:35:27-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-02-07 12:20:12-08:00
log84bf7a6701d5f51a8307736d310d4049c9158921
treea8a42cd57ae15cf60ed513cdaa4d603d2a9f5382
parent3d7c5cf64a3bbe55dfa943133d1a5a7a34fe388c

std.heap.SmpAllocator: 256K slab_len

and no need for special handling of wasi and windows since we don't ask for anything more than page-aligned.

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

lib/std/heap/SmpAllocator.zig+1-6
......@@ -30,7 +30,6 @@
3030//! through the full set of freelists.
3131
3232const builtin = @import("builtin");
33const native_os = builtin.os.tag;
3433
3534const std = @import("../std.zig");
3635const assert = std.debug.assert;
......@@ -56,11 +55,7 @@ var global: SmpAllocator = .{
5655threadlocal var thread_id: Thread.Id = .none;
5756
5857const max_thread_count = 128;
59const slab_len: usize = @max(std.heap.page_size_max, switch (builtin.os.tag) {
60 .windows => 64 * 1024, // Makes `std.heap.PageAllocator` take the happy path.
61 .wasi => 64 * 1024, // Max alignment supported by `std.heap.WasmAllocator`.
62 else => 256 * 1024, // Avoids too many active mappings when `page_size_max` is low.
63});
58const slab_len: usize = @max(std.heap.page_size_max, 256 * 1024);
6459/// Because of storing free list pointers, the minimum size class is 3.
6560const min_class = math.log2(math.ceilPowerOfTwoAssert(usize, 1 + @sizeOf(usize)));
6661const size_class_count = math.log2(slab_len) - min_class;