mirror of
https://github.com/zeronsh/comet.git
synced 2026-11-16 18:57:19 +00:00
* Engine: cap glibc malloc arenas on Linux glibc gives every thread a 64MB arena (default cap 8 × cores) and trims only the top of a heap, so a headless engine held 6.6GB in 129 arenas (7.2GB RSS) after a day. mallopt at startup caps arenas at 2 and sets trim/mmap thresholds to 128KB; GLIBC_TUNABLES/MALLOC_* still win. Bench RSS after 60s idle: 226MB → 159MB (this checkout 278MB → 191MB). * Engine: trim glibc arenas periodically instead of capping them Capping glibc at two arenas cut idle RSS in the streaming bench but multiplied the engine's CPU about six times (futex calls 166k -> 1.6M) as threads queued on the shared arena locks. A periodic malloc_trim(0) releases the free pages inside every arena, which is what was being retained, and costs nothing while chats stream. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Wing <contact@winglee.io> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
172 lines
11 KiB
172 lines
11 KiB