3491a8e83b
Since #1360 routed ordinary malloc/new through mimalloc on Linux, the arena policy governs every allocation in the process rather than just the bound sqlite/tree_sitter populations. cbm sets arena_eager_commit=0, so mimalloc commits sub-ranges with mprotect(PROT_READ|PROT_WRITE) over a PROT_NONE reservation, and each partial commit SPLITS the reserved VMA. Measured on the Go corpus, Linux arm64, shipped binaries: v0.9.0 10 mappings, at ANY worker count v0.10.5 ~22k mappings, peak; the count tracks CONCURRENCY (999 at 1 worker, 8460 at 4, 11965 at 18) Two consequences, both of which #1654 reported from a 96-CPU/376 GB host: the mmap/mprotect churn serialises on the kernel's per-process mmap_lock, and the VMA count climbs toward vm.max_map_count, after which mmap fails for ANY size -- so mimalloc reported it could not allocate 10 KB while `free -g` still showed 246 GB available. mimalloc's own default for this option is 2, meaning "eager-commit arenas only on an OS that overcommits (i.e. linux)", precisely because commit is free there until pages are touched. Overriding it to 0 opted Linux out of the default written for Linux. Restore it on Linux only; every other platform keeps the lazy setting, where commit is NOT free and the upfront-memory reason still holds (Windows especially, #581). Measured effect, same corpus and host, baseline build vs this build: mappings 22450 -> 17312 (-23%) wall 92.4s -> 92.6s (unchanged) peak RSS 19.14 -> 19.22 GB (unchanged) This is a partial mitigation, not a cure: the remaining ~17k mappings are individual 64 KB-3 MB extraction buffers, each taking its own mmap (the worker reserves ~40 GB of address space for ~19 GB of RSS). Pooling those is the durable fix and is deliberately left out of this change. Guard: mem_arena_eager_commit_follows_platform_commit_cost pins the platform split so the Linux default cannot be silently opted out again. Reproduction and controlled 2x2 (only vm.max_map_count varied) are recorded on #1654. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>