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 @@...@@ -30,7 +30,6 @@
30//! through the full set of freelists.30//! through the full set of freelists.
3131
32const builtin = @import("builtin");32const builtin = @import("builtin");
33const native_os = builtin.os.tag;
3433
35const std = @import("../std.zig");34const std = @import("../std.zig");
36const assert = std.debug.assert;35const assert = std.debug.assert;
...@@ -56,11 +55,7 @@ var global: SmpAllocator = .{...@@ -56,11 +55,7 @@ var global: SmpAllocator = .{
56threadlocal var thread_id: Thread.Id = .none;55threadlocal var thread_id: Thread.Id = .none;
5756
58const max_thread_count = 128;57const max_thread_count = 128;
59const slab_len: usize = @max(std.heap.page_size_max, switch (builtin.os.tag) {58const slab_len: usize = @max(std.heap.page_size_max, 256 * 1024);
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});
64/// Because of storing free list pointers, the minimum size class is 3.59/// Because of storing free list pointers, the minimum size class is 3.
65const min_class = math.log2(math.ceilPowerOfTwoAssert(usize, 1 + @sizeOf(usize)));60const min_class = math.log2(math.ceilPowerOfTwoAssert(usize, 1 + @sizeOf(usize)));
66const size_class_count = math.log2(slab_len) - min_class;61const size_class_count = math.log2(slab_len) - min_class;