Visitar URL original
aosp: bound git repack memory to avoid container OOM by yaoge123 · Pull Request #215 · tuna/tunasync-scripts · GitHub
Skip to content

aosp: bound git repack memory to avoid container OOM - #215

Open
yaoge123 wants to merge 1 commit into
tuna:masterfrom
yaoge123:aosp-repack-oom
Open

yaoge123 wants to merge 1 commit into
tuna:masterfrom
yaoge123:aosp-repack-oom

Conversation

@yaoge123

@yaoge123 yaoge123 commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

pack.threads defaults to the host CPU count and pack.windowMemory is unbounded; on a many-core worker running the job in a memory-limited container, git repack -a -b -d on large AOSP repos gets SIGKILLed during the bitmap-index step (error: pack-objects died of signal 9), failing the whole job after repo sync succeeded.

Cap both per thread, configurable via env since container limits and CPU counts differ per site:

  • TUNASYNC_AOSP_PACK_THREADS (default 4)
  • TUNASYNC_AOSP_PACK_WINDOW_MEMORY (default 256m)

pack.deltaCacheSize needs no explicit cap — git already defaults it to 256m. (Git's own GIT_CONFIG_COUNT/GIT_CONFIG_KEY_n env injection was considered, but command-line -c takes precedence over it and the repo convention is TUNASYNC_* variables.) Seen in production on a 64-core worker with an 8G container limit.

Copilot AI lite review requested due to automatic review settings September 24, 2026 03:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The reviewed change addresses the stated OOM risk with no unresolved blocking issues.

Review effort: Lite
Findings: None

What changed in this PR

This pull request bounds Git repack resource usage for large AOSP repositories to prevent container OOM failures.

Changes:

  • Limits repack parallelism to four threads.
  • Caps window and delta cache memory at 256 MiB each.
File Description
aosp.sh Applies bounded Git repack settings during bitmap generation.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@yaoge123

Copy link
Copy Markdown
Contributor Author

Updated: the threads/memory caps are now configurable via TUNASYNC_AOSP_PACK_THREADS / TUNASYNC_AOSP_PACK_WINDOW_MEMORY / TUNASYNC_AOSP_PACK_DELTA_CACHE_SIZE since container limits and CPU counts differ per site; defaults (4 / 256m / 256m) fit an 8G container.

pack.threads defaults to the host CPU count and pack.windowMemory is
unbounded; on large repos 'git repack -a -b -d' can then get SIGKILLed
by the container memory limit ('pack-objects died of signal 9' during
the bitmap-index step).

Cap both per thread via TUNASYNC_AOSP_PACK_THREADS (default 4) and
TUNASYNC_AOSP_PACK_WINDOW_MEMORY (default 256m) so sites can tune for
their own container limit. pack.deltaCacheSize needs no cap here since
git already defaults it to 256m.
@yaoge123

Copy link
Copy Markdown
Contributor Author

Follow-up data point from production (NJU): with this patch applied, the repack no longer dies within minutes, but a job-wide memory cap still matters. Repacking the largest AOSP repos (100GB+ class, tens of millions of objects) pushed git's anonymous RSS to ~8.2GB (total-vm 130GB) even with pack.threads=4 and pack.windowMemory=256m, and the kernel OOM-killed it inside an 8G container. The per-thread knobs bound the delta-window growth, but the object array/bitmap structures scale with repo object count and are not config-capped.

So the practical recipe for sites with huge repos is: this patch (sane defaults + env overrides) plus a larger container memory limit for the aosp job (we now run it with 32G; host RAM is cheap compared to a 2-day retry loop). Defaults of 4 threads / 256m are still the right conservative choice for arbitrary deployments.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

No unresolved review issues were identified.

Review effort: Lite
Findings: None

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.

2 participants