Skip to content

Size RTC num_workers from the container's CPU and memory limits - #228

Open
chris-thomas-ga wants to merge 3 commits into
GeoscienceAustralia:mainfrom
chris-thomas-ga:fix/rtc-num-workers-from-cgroup
Open

chris-thomas-ga wants to merge 3 commits into
GeoscienceAustralia:mainfrom
chris-thomas-ga:fix/rtc-num-workers-from-cgroup

Conversation

@chris-thomas-ga

@chris-thomas-ga chris-thomas-ga commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Description

With num_workers: 0, RTC falls back to os.cpu_count(), which inside a container is the host's core count. A small pod on a big node can end up starting a process per burst (up to ~27), and since RTC forces each child into single_block memory mode the pod gets OOM-killed after the download.

This adds --num-workers (default auto, also settable with RTC_NUM_WORKERS). auto reads the container's cgroup CPU and memory limits (v2, falling back to v1) and uses the smaller of the CPU count and (memory - reserve) / per-burst memory. The value is written to the run config, and the run script passes the options through.

  • --rtc-memory-per-burst-gib (default 8) is the expected peak for one burst process.
  • --rtc-memory-reserve-gib (default 2) is kept back for the parent rtc_s1.py process before dividing the rest.
  • --num-workers 0 keeps the old behaviour (RTC picks the number itself). So this can be deployed with RTC_NUM_WORKERS=0 first, with no change at all, and switched to auto once we've watched a few jobs.

The 8 GiB default is based on the peak we've seen for a single burst, so it may need tuning.

Testing

tests/sar_pipeline/test_resources.py uses fake cgroup files, and also checks the value ends up in a saved run config.

Type of change

  • Bug fix

chris-thomas-ga and others added 3 commits November 24, 2026 07:36
num_workers: 0 made RTC fall back to os.cpu_count(), which is the host
core count inside a container. RTC forces each child burst process to
memory_mode single_block, so a small pod on a large node could start far
more burst processes than its memory limit allows and be OOM-killed.

Add --num-workers (default "auto", env RTC_NUM_WORKERS) and
--rtc-memory-per-burst-gib (default 8, env RTC_MEMORY_PER_BURST_GIB).
"auto" uses min(cgroup CPU limit, cgroup memory limit / memory per burst),
reading cgroup v2 or v1 and falling back to host values, with a minimum
of 1. The value is written to runconfig.groups.processing.num_workers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e parent process

--num-workers 0 (or RTC_NUM_WORKERS=0) now writes 0 to the run config so RTC picks the
number of workers itself, the behaviour before this change. auto now subtracts
--rtc-memory-reserve-gib (default 2) from the memory limit before dividing by the
per-burst memory, leaving room for the parent rtc_s1.py process.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant