Raise the pool's heap limit to 4 GB, and log GC time and heap with each stall #49

Merged
namillis merged 1 commit from fix/gc-stalls into main 2026-11-20 20:27:21 +00:00
Owner

The freezes left after #48 (1-2 s, a few times an hour, around provider refreshes and merges) were garbage collection. The pool's heap sits at 1.4-1.8 GB with 15 providers, and Node's default limit on this VM is 2,096 MB. Near the limit V8 runs long full collections back to back, and every request waits for them.

Evidence from the live pool (20 Nov, 19:22-20:23 UTC):

  • A 40-minute CPU profile matched to the stall log: the stalls of 1,880 ms and 1,276 ms were 99% and 95% garbage collector samples.
  • A GC observer logged pauses of 1,377 ms, 2,084 ms and 1,721 ms at 1,700-1,850 MB of the 2,096 MB limit, at the same moments as the stalls.
  • A real refresh of the biggest guide (polar, 205k programmes) in a separate process with the full pool loaded never blocked over 200 ms when that process had headroom. The refresh code itself isn't the problem.

Changes:

  • npm start runs Node with --max-old-space-size=4096. The VM has 11.6 GB, about 6.6 GB of it available.
  • [POOL] Event loop blocked for N ms now adds how much of it was GC and how full the heap is.
  • [POOL] Merged ... adds the heap size, so growth over time shows up in the log.
  • README memory note updated with the real numbers.

Tests: 144/144 pass.

The freezes left after #48 (1-2 s, a few times an hour, around provider refreshes and merges) were garbage collection. The pool's heap sits at 1.4-1.8 GB with 15 providers, and Node's default limit on this VM is 2,096 MB. Near the limit V8 runs long full collections back to back, and every request waits for them. Evidence from the live pool (20 Nov, 19:22-20:23 UTC): - A 40-minute CPU profile matched to the stall log: the stalls of 1,880 ms and 1,276 ms were 99% and 95% garbage collector samples. - A GC observer logged pauses of 1,377 ms, 2,084 ms and 1,721 ms at 1,700-1,850 MB of the 2,096 MB limit, at the same moments as the stalls. - A real refresh of the biggest guide (polar, 205k programmes) in a separate process with the full pool loaded never blocked over 200 ms when that process had headroom. The refresh code itself isn't the problem. Changes: - `npm start` runs Node with `--max-old-space-size=4096`. The VM has 11.6 GB, about 6.6 GB of it available. - `[POOL] Event loop blocked for N ms` now adds how much of it was GC and how full the heap is. - `[POOL] Merged ...` adds the heap size, so growth over time shows up in the log. - README memory note updated with the real numbers. Tests: 144/144 pass.
Raise the pool's heap limit to 4 GB, and log GC time and heap with each stall
All checks were successful
CI / test (pull_request) Successful in 20s
7adb4a0c7d
With 15 providers the pool keeps 1.4-1.8 GB on the heap, close to Node's default 2 GB limit, so V8 ran 1-2 s collections back to back after refreshes and merges. A CPU profile of the live pool put 95-99% of each stall over a second in the garbage collector.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
namillis/iptv-pool!49
No description provided.