Andrew Kelley
42dbd35d3e
std.heap.SmpAllocator: back to simple free
...
In practice this is fine because eventually alloc wins the race and
grabs that massive freelist.
2025-02-08 16:46:56 -08:00
Andrew Kelley
b09e3efad4
std.heap.SmpAllocator: alternate freelist accounting
...
Freelist length accounting in alloc had a negative impact, especially
with the integer type bumped up to u16, so I changed the system to be
based on counting slabs rather than total allocations.
2025-02-08 16:20:51 -08:00
Andrew Kelley
bb5a4036e8
std.heap.SmpAllocator; fix freelist accounting
2025-02-08 15:07:03 -08:00
Andrew Kelley
1754e014f5
std.heap.SmpAllocator: rotate on free sometimes
...
* slab length reduced to 64K
* track freelist length with u8s
* on free(), rotate if freelist length exceeds max_freelist_len
Prevents memory leakage in the scenario where one thread only allocates
and another thread only frees.
2025-02-07 14:41:49 -08:00
Andrew Kelley
a9d3005616
std.heap.SmpAllocator: fix detection of slab end
2025-02-07 14:41:49 -08:00
Andrew Kelley
3246150d45
std.heap.SmpAllocator: fix getCpuCount logic
...
it was always returning max_cpu_count
2025-02-07 14:41:49 -08:00
Andrew Kelley
88e2e60e88
std.heap.SmpAllocator: simplify by putting freelist node at start
2025-02-07 14:41:49 -08:00
Andrew Kelley
1ffae59fec
std.heap.SmpAllocator: fix using wrong size class indices
2025-02-07 14:41:49 -08:00
Andrew Kelley
839c453d88
std.heap.SmpAllocator: eliminate the global mutex
2025-02-07 14:41:49 -08:00
Andrew Kelley
60765a9ee2
std.heap.SmpAllocator: implement searching on alloc
...
rotate a couple times before resorting to mapping more memory.
2025-02-07 14:41:49 -08:00
Andrew Kelley
84bf7a6701
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.
2025-02-07 12:20:12 -08:00
Andrew Kelley
3d7c5cf64a
std.heap: test smp_allocator
2025-02-07 12:20:12 -08:00
Andrew Kelley
51c4ffa410
add std.heap.SmpAllocator
...
An allocator intended to be used in -OReleaseFast mode when
multi-threading is enabled.
2025-02-07 12:20:12 -08:00