| @@ -238,3 +238,22 @@ The per-thread counts above stay, but no longer in every build. Release programs |
| 238 | 238 | - **Finalizers run later.** A resource inside a large structure is finalized when its step comes, not at the drop. A file may close a little later. |
| 239 | 239 | - **Exits are seen later.** An actor that ends with a large structure is seen as exited (by links, monitors and `main`) once it has freed it. |
| 240 | 240 | - **Frees outside an actor** (`drop_detached`, the scheduler freeing a message whose receiver is gone) still run to the end. |
| 241 | + |
| 242 | +## Note — 2026-10-12: no free lists in front of mimalloc (issue #132) |
| 243 | +**Status:** Proposed (epic #135); needs engineering review (#44). |
| 244 | + |
| 245 | +#132 asked whether a free list per scheduler thread in front of mimalloc would speed up allocation-heavy programs. The plan was to ship it only if it gained at least 5% on `floats`, `dict` or `lists` without slowing anything else by more than 5%. Two prototypes were measured against the stack's last PR, with the `lto` runtime (ADR 0032), which inlines mimalloc's fast paths into programs (user cycles, one thread, best of 11): |
| 246 | + |
| 247 | +| Benchmark | Free lists (16–64 bytes, 256 each) | `mi_malloc_small` | |
| 248 | +|---|---|---| |
| 249 | +| `floats` | +26.7% | −0.6% | |
| 250 | +| `dict` | −8.3% | −1.6% | |
| 251 | +| `lists` | −0.1% | −0.7% | |
| 252 | +| `arrays` | +14.6% | +12.3% | |
| 253 | +| `html` | −2.7% | −4.7% | |
| 254 | +| `records` | +4.9% | +1.6% | |
| 255 | + |
| 256 | +- **Free lists:** a freed block's size has to be computed from its header to find its list, which costs more than mimalloc's own free. With ThinLTO, `mi_malloc` and `mi_free` are about a dozen instructions inlined into the program. |
| 257 | +- **`mi_malloc_small`:** it skips one size check, and changes nothing measurable but `arrays`, which gets slower. |
| 258 | + |
| 259 | +Neither is kept. A prototype reached through a thread-local was enough to measure; one to ship would have to reach its lists through `ctx`, because a program function can resume on another thread (ADR 0032). |