
Kpa-clawbotandcorescope-bot
d05e468598
feat(memlimit): GOMEMLIMIT support, derive from packetStore.maxMemoryMB (#836) (#1077)
## Summary
Implements **part 1** of #836 — `GOMEMLIMIT` support so the Go runtime
self-throttles GC under cgroup memory pressure instead of getting
SIGKILLed.
(Parts 2 & 3 — bounded cold-load batching + README ops docs — land in
follow-up PRs.)
## Behavior
On startup `cmd/server/main.go` now calls `applyMemoryLimit(maxMemoryMB,
envSet)`:
| Condition | Action | Log |
|---|---|---|
| `GOMEMLIMIT` env set | Honor the runtime's parse, do nothing |
`[memlimit] using GOMEMLIMIT from environment (...)` |
| env unset, `packetStore.maxMemoryMB > 0` | `debug.SetMemoryLimit(maxMB
* 1.5 MiB)` | `[memlimit] derived from packetStore.maxMemoryMB=512 → 768
MiB (1.5x headroom)` |
| env unset, `maxMemoryMB == 0` | No-op | `[memlimit] no soft memory
limit set ... recommend setting one to avoid container OOM-kill` |
The 1.5x headroom covers Go's NextGC trigger at ~2× live heap (per #836
heap profile: 680 MB live → 1.38 GB NextGC).
## Tests (TDD red→green visible in commit history)
- `TestApplyMemoryLimit_FromEnv` — env wins, function does not override
- `TestApplyMemoryLimit_DerivedFromMaxMemoryMB` — verifies bytes
computation + `debug.SetMemoryLimit` actually applied at runtime
- `TestApplyMemoryLimit_None` — no env, no config → reports `"none"`, no
side effect
Red commit: `7de3c62` (assertion failures, builds clean)
Green commit: `454516d`
## Config docs
`config.example.json` `packetStore._comment_gomemlimit` documents
env/derived/override behavior.
## Out of scope
- Cold-load transient bounding (item 2 in #836)
- README container-size table (item 3)
- QA §1.1 rewrite
Closes part 1 of #836.
---------
Co-authored-by: corescope-bot <bot@corescope>
2026-05-05 01:33:23 -07:00
..
2026-04-21 09:09:39 -07:00
2026-04-03 13:51:13 -07:00
2026-04-05 14:50:40 -07:00
2026-04-05 09:49:39 -07:00
2026-05-03 17:56:42 -07:00
2026-05-03 17:56:42 -07:00
2026-05-01 06:47:55 +00:00
2026-04-12 18:09:23 -07:00
2026-05-03 17:41:22 -07:00
2026-04-20 21:46:34 -07:00
2026-05-02 10:30:54 -07:00
2026-05-02 10:30:54 -07:00
2026-04-16 00:18:25 -07:00
2026-04-05 09:49:39 -07:00
2026-04-17 09:24:40 -07:00
2026-05-05 01:17:52 -07:00
2026-05-02 12:04:37 -07:00
2026-05-02 12:04:37 -07:00
2026-05-02 16:05:56 -07:00
2026-05-02 12:03:42 -07:00
2026-04-30 23:45:00 -07:00
2026-05-03 19:50:01 -07:00
2026-05-03 11:17:25 -07:00
2026-05-03 11:17:25 -07:00
2026-05-05 01:16:57 -07:00
2026-05-05 01:16:57 -07:00
2026-04-16 00:09:36 -07:00
2026-04-20 19:55:00 -07:00
2026-03-31 01:10:56 -07:00
2026-05-02 20:15:30 -07:00
2026-03-27 01:16:59 -07:00
2026-04-18 11:52:22 -07:00
2026-04-18 11:52:22 -07:00
2026-05-01 07:55:57 -07:00
2026-05-01 07:55:57 -07:00
2026-04-03 13:11:59 -07:00
2026-04-20 22:15:02 -07:00
2026-05-03 20:10:02 -07:00
2026-04-21 04:51:24 +00:00
2026-05-02 20:35:15 -07:00
2026-05-05 01:33:23 -07:00
2026-05-05 01:33:23 -07:00
2026-05-05 01:33:23 -07:00
2026-04-20 23:10:33 -07:00
2026-04-18 11:39:13 -07:00
2026-05-03 08:56:09 -07:00
2026-05-05 06:42:58 +00:00
2026-04-16 21:35:14 -07:00
2026-04-17 23:43:05 +00:00
2026-04-02 23:45:03 -07:00
2026-04-02 23:45:03 -07:00
2026-04-30 09:25:51 -07:00
2026-04-30 09:25:51 -07:00
2026-04-14 23:22:35 -07:00
2026-05-02 12:03:42 -07:00
2026-05-02 20:15:30 -07:00
2026-04-17 23:43:05 +00:00
2026-04-03 13:33:26 -07:00
2026-05-01 23:11:27 -07:00
2026-04-05 15:05:20 -07:00
2026-05-03 17:56:42 -07:00
2026-03-30 03:42:11 +00:00
2026-04-30 23:28:16 -07:00
2026-04-30 23:28:16 -07:00
2026-05-02 11:15:25 -07:00
2026-04-01 19:26:11 -07:00
2026-04-30 09:25:51 -07:00
2026-05-03 19:50:01 -07:00
2026-05-05 01:17:52 -07:00
2026-05-05 01:17:52 -07:00
2026-04-30 09:25:51 -07:00
2026-04-20 19:55:00 -07:00
2026-04-21 04:51:24 +00:00
2026-05-03 17:56:12 -07:00
2026-05-03 17:56:12 -07:00
2026-04-20 22:50:01 -07:00
2026-05-05 01:17:52 -07:00
2026-05-02 20:15:30 -07:00
2026-05-02 20:15:30 -07:00
2026-05-03 17:40:54 -07:00
2026-04-20 23:10:33 -07:00
2026-04-21 09:09:39 -07:00
2026-05-05 01:16:57 -07:00
2026-05-03 17:41:22 -07:00
2026-05-03 17:41:22 -07:00
2026-05-03 17:41:22 -07:00
2026-04-20 19:55:00 -07:00
2026-04-20 19:55:00 -07:00
2026-05-02 12:03:42 -07:00
2026-05-02 20:15:30 -07:00
2026-03-30 03:42:11 +00:00
2026-04-01 12:19:20 -07:00