diff options
| author | Taylan Kammer <taylan.kammer@gmail.com> | 2026-09-23 14:17:34 +0200 |
|---|---|---|
| committer | Taylan Kammer <taylan.kammer@gmail.com> | 2026-09-23 14:17:34 +0200 |
| commit | 6137e91c4a582417c519d19f9e903776b7d9fd04 (patch) | |
| tree | 8b0253c475b6feb726b4115f9e234a827ec4b65f | |
| parent | 470bcb1b7a34c5eb95c95f1b01343740d459d42c (diff) | |
Meta Alloc size classes start at 256.
| -rw-r--r-- | MetaAlloc.ods | bin | 29632 -> 35279 bytes | |||
| -rw-r--r-- | doc/0/A-meta_alloc.md | 14 | ||||
| -rw-r--r-- | src/zisp/gc/meta_alloc.zig | 4 |
3 files changed, 9 insertions, 9 deletions
diff --git a/MetaAlloc.ods b/MetaAlloc.ods Binary files differindex a3d88ea..1313aab 100644 --- a/MetaAlloc.ods +++ b/MetaAlloc.ods diff --git a/doc/0/A-meta_alloc.md b/doc/0/A-meta_alloc.md index 85c704c..7383ec2 100644 --- a/doc/0/A-meta_alloc.md +++ b/doc/0/A-meta_alloc.md @@ -104,14 +104,14 @@ Zisp runtime, that the operating system reports that the process is using hundreds of gigabytes of virtual memory, do not panic; it's a feature, not a bug, and completely benign. -As for the size classes: They simply go from 128 bytes to 4 MiB in -perfect powers of two; in other words, from 2^7 to 2^22. There are -certain benefits to using exact powers of two, and 128 bytes - 4 MiB +As for the size classes: They simply go from 256 bytes to 8 MiB in +perfect powers of two; in other words, from 2^8 to 2^23. There are +certain benefits to using exact powers of two, and 256 bytes - 8 MiB seems like a reasonable range. Code using Meta Alloc must be aware that only these size classes are supported, and try to make optimal use of them. -**WARNING:** Calling `alloc()` with a size smaller than 128 or one +**WARNING:** Calling `alloc()` with a size smaller than 256 or one that is not a perfect power of two will lead to catastrophic bugs under optimized builds of Zisp. @@ -218,11 +218,11 @@ values used by the implementation are as follows: * Maximum count: 16 Indexes -* Smallest size class: 128 bytes +* Smallest size class: 256 bytes The extra Index array starts after 64 bytes, and requires 64 bytes, -since it stores up to 16 32-bit integers; that's a total size of 128, -which fits exactly into the smallest size. +since it stores up to 16 32-bit integers; that's a total size of 256, +which fits into the smallest size. The 64-byte padding is to allow for efficient bulk memory transfer using up to 512-bit SIMD instructions on modern processors. diff --git a/src/zisp/gc/meta_alloc.zig b/src/zisp/gc/meta_alloc.zig index c8d46e1..248b00b 100644 --- a/src/zisp/gc/meta_alloc.zig +++ b/src/zisp/gc/meta_alloc.zig @@ -107,7 +107,6 @@ const SIZES: [16]usize = .{ // Important: Ensure the smallest size class is inherently immune to false // sharing, and no smaller than: 64 + @sizeOf(UnitIdx) * ( FSC_MAX / 2 ). // That's exactly 128 bytes assuming FSC_MAX = 32 (see below). - 128, 256, 512, 1024, @@ -123,6 +122,7 @@ const SIZES: [16]usize = .{ 1024 * 1024, 1024 * 1024 * 2, 1024 * 1024 * 4, + 1024 * 1024 * 8, }; /// Gets the index 0 to 15 of a size class, from the size value, returning a @@ -520,7 +520,7 @@ export fn flush_thread_reserves() void { // Given our chunked WM bumps and smallest size class, hi - lo > 4 KiB // implies that there's at least one entire untouched page, as well as - // at least one >=128-byte slot before it, which can hold the metadata + // at least one >=256-byte slot before it, which can hold the metadata // of the vacancy-list entry without faulting in an empty page. if (tl.wm_hi - tl.wm_lo > 4096 / @sizeOf(Unit)) { flush_to_vl(info, tl, slab); |
