Repository navigation
chore: remove outdated var usages - #1364
Merged
Merged
Conversation
Jarred-Sumner
added a commit
that referenced
this pull request
Aug 24, 2026
) (#40138) ### What does this PR do? Bumps mimalloc to oven-sh/mimalloc#27, which combines oven-sh/mimalloc#22–#26 and replaces their per-reader fixes with one teardown protocol for `mi_heap_delete` / `mi_heap_destroy`. The problem those PRs were circling: a heap is torn down while a concurrent cross-thread `mi_free`, or a thread that used the heap earlier and still caches a theap for it, can reach it. The hole in the middle was that the deleter claimed pages by *writing* to them (`atomic_or` of the owned bit) with nothing pinning the page, so a concurrent free could release the page and the slice be reused in between. Now: detach theaps → abandon their pages as thread-exit does → pin-then-claim every abandoned page (the same bitmap-as-pin protocol the abandoned-page map already uses) → free theaps → free heap. Details, contract and tests in the mimalloc PR. Also in the bump: mimalloc#22 (THP opt-out only when the system setting is `always` — saves a `madvise` per mmap on Debian/Ubuntu defaults), from mimalloc#23 only the scavenger signal mask (a fault on that thread produced no crash report), the scavenger thread starting lazily (a single-threaded `bun -e` no longer spawns it: −1 thread, −24 syscalls), and targeted upstream dev3 fixes (thread-locals-after-free guard, #1364, #1371, NUMA node count). Upstream's in-progress page-meta layout rework is deliberately *not* included. **What this does not do:** fix the Windows corrupted-free-list crash family (BUN-40BH and siblings). Those lists are written by Bun — #39897 (file read completing into a freed buffer, merged) and #39643 (poll handle freed twice from a nested event loop, open) — and mimalloc is only where the damage surfaces. #23's "validate links and cut the list" is not taken for that reason: it would keep running past the write and hide it. ### How did you verify your code works? - mimalloc `ctest`: Release 23/23, Debug (`MI_DEBUG_FULL`) 24/24 (was 20/21 on the old pin), ASAN 22/22, TSAN 19/19 with 0 reports (see mimalloc#27). - `bun bd test`: transpiler (190/190), bundler_edgecase (138/138), bundler_minify (43/43), css (2358 pass; 6 debug-timeout fuzz tests), workers/serve (same 4 failures as a `main` debug build on this box). - Release x64, n=7 interleaved, old pin vs new pin on the same Bun commit: | | old pin median (range) | new pin median (range) | Δ | |---|---|---|---| | `bun -e 1` peak RSS | 27024 KB (26564–27088) | 26016 KB (25984–26020)¹ | −3.7% | | `bun -e 1` syscalls | 270 | 246 | −24 (no `clone3` for the scavenger, −6 `rt_sigprocmask`, −5 `madvise`) | | `Bun.serve` hello RSS after 200k req (c=64) | 49760 KB (48540–50040) | 47948 KB (46384–48252) | −3.6% | | `bun build --minify --sourcemap` three.js×10 peak | 345696 KB (340672–348928) | 343724 KB (339612–348828) | −0.6% (overlaps) | ¹ one run at 17212 KB excluded from the range as an outlier. The first two rows come from the scavenger thread now starting on first use (first park / first scheduled purge) instead of at process init — a change made because the eager start aborted macOS processes that `DYLD_INSERT` the dylib (thread created before libobjc initializes); `bun -e 1` never needs it. Before that change the same A/B was flat (+0.1–0.3%, overlapping), so the teardown protocol itself is RSS-neutral as forecast.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.