mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
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.
This commit is contained in:
parent
3d7c5cf64a
commit
84bf7a6701
@ -30,7 +30,6 @@
|
|||||||
//! through the full set of freelists.
|
//! through the full set of freelists.
|
||||||
|
|
||||||
const builtin = @import("builtin");
|
const builtin = @import("builtin");
|
||||||
const native_os = builtin.os.tag;
|
|
||||||
|
|
||||||
const std = @import("../std.zig");
|
const std = @import("../std.zig");
|
||||||
const assert = std.debug.assert;
|
const assert = std.debug.assert;
|
||||||
@ -56,11 +55,7 @@ var global: SmpAllocator = .{
|
|||||||
threadlocal var thread_id: Thread.Id = .none;
|
threadlocal var thread_id: Thread.Id = .none;
|
||||||
|
|
||||||
const max_thread_count = 128;
|
const max_thread_count = 128;
|
||||||
const slab_len: usize = @max(std.heap.page_size_max, switch (builtin.os.tag) {
|
const slab_len: usize = @max(std.heap.page_size_max, 256 * 1024);
|
||||||
.windows => 64 * 1024, // Makes `std.heap.PageAllocator` take the happy path.
|
|
||||||
.wasi => 64 * 1024, // Max alignment supported by `std.heap.WasmAllocator`.
|
|
||||||
else => 256 * 1024, // Avoids too many active mappings when `page_size_max` is low.
|
|
||||||
});
|
|
||||||
/// Because of storing free list pointers, the minimum size class is 3.
|
/// Because of storing free list pointers, the minimum size class is 3.
|
||||||
const min_class = math.log2(math.ceilPowerOfTwoAssert(usize, 1 + @sizeOf(usize)));
|
const min_class = math.log2(math.ceilPowerOfTwoAssert(usize, 1 + @sizeOf(usize)));
|
||||||
const size_class_count = math.log2(slab_len) - min_class;
|
const size_class_count = math.log2(slab_len) - min_class;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user