perf(operator): mimalloc allocator + label-scope the Job watch#53
Merged
Conversation
Two related changes to bring the operator's resident memory down. 1. mimalloc as global allocator. Long-running Rust services on glibc commonly hold significantly more RSS than the live heap due to fragmentation and retained chunks. mimalloc keeps RSS closer to working-set size, which matters for a controller that runs indefinitely and was previously OOMKilled at a tight limit. 2. Scope the Job watch to pgro-owned Jobs via the pgro.bes.au/replica label selector. The previous watch was cluster-wide across all namespaces with no filter, so kube-rs cached every Job in the cluster — CI runners, batch tasks, cert-manager renewals, etc. — in the in-memory store. Restricting to Jobs that carry the pgro.bes.au/replica label cuts the watched set to only restore Jobs, snapshot-list Jobs, schema-migration Jobs, and credential-reset Jobs, all of which the operator builds with that label. Together these reduce the operator's RSS substantially in clusters with significant non-pgro Job activity, and reduce baseline RSS even in pgro-only clusters via the allocator change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two related changes to reduce the operator's resident memory.
1. mimalloc as global allocator. Long-running Rust services on glibc commonly hold significantly more RSS than the live heap due to fragmentation and retained chunks. mimalloc keeps RSS closer to working-set size, which matters for a controller that runs indefinitely and was hitting tight memory limits.
2. Scope the Job watch to pgro-owned Jobs. The previous
.watches(Api::<Job>::all(...), Config::default(), ...)was cluster-wide with no label selector, so kube-rs cached every Job in every namespace (CI runners, batch tasks, cert-manager renewals, etc.) in the in-memory store. Restricting to Jobs carrying thepgro.bes.au/replicalabel cuts the watched set to only the four Job types the operator builds — restore, snapshot-list, schema-migration, credential-reset — all of which already set that label.Together these reduce the operator's RSS substantially in clusters with significant non-pgro Job activity, and reduce baseline RSS even in pgro-only clusters via the allocator change.
Follow-up coming separately: connection pooling for the per-reconcile postgres connections (currently 3-4 fresh TCP connections per
reconcile_schema_migration).