Raise the production memory cap, and use jemalloc #19
Loading…
Reference in a new issue
No description provided.
Delete branch "armin-bot/impress:claude/memory-cap"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
We set the 1.2GB
MemoryMaxin Oct 2023 to work around an apparent leak, back when production was one Puma process. Since Jan 2024, Falcon forks one worker per core with no preloading. On our 6-core box that's 6 × ~225MB ≈ 1.35GB of healthy steady-state usage, already over the cap, which explains the ~3 kills a week.What I measured
I ran the app locally in production mode under Falcon, against the public data dump plus synthetic users, closets and outfits. I replayed a broad mix of request types and logged each worker's memory and Ruby heap stats.
Changes
falcon.rbreadsFALCON_COUNT(unset → Falcon's default of one per core, so dev is unchanged).FALCON_COUNT=6right next toMemoryMax, since they're coupled, and raises the cap to 4G: room for 6 YJIT workers plus spike headroom, on a 16GB box shared with MariaDB. I rewrote the comment to explain the history.libjemalloc.so.2(bare name, so it's arch-agnostic);setup.ymlinstallslibjemalloc2. If the library is missing, the dynamic linker warns and falls back to glibc.Testing
FALCON_COUNT=2with jemalloc preloaded gave 2 workers, with jemalloc mapped into each and pages serving 200s. With the variable unset, it fell back to 4 workers (one per core here).setup.ymlstill parses as YAML. I haven't run the playbook itself.Deploying
This needs
bin/deploy:setup(it changes the service file and installs a package), not justbin/deploy. Afterward, it's worth checkingsystemctl status impressand thatgrep jemalloc /proc/<worker pid>/mapsshows up. If the cap ever gets hit now, that's a real signal worth investigating.🤖 Generated with Claude Code
https://claude.ai/code/session_014PWWczFNVoGD1tQziaMfGe