fix(monitor): fix wandb internal RSS growth at high sample log frequency#2528
Draft
mikasenghaas wants to merge 2 commits into
Draft
fix(monitor): fix wandb internal RSS growth at high sample log frequency#2528mikasenghaas wants to merge 2 commits into
mikasenghaas wants to merge 2 commits into
Conversation
numpy/pandas allocate array data via malloc() (outside Python's allocator), so gc.collect() alone doesn't reclaim RSS after per-step DataFrames are freed. glibc retains freed pages in its internal pool, causing ~+6 MB/step monotonic RssAnon growth on the orchestrator process. malloc_trim(0) forces glibc to return freed heap pages to the OS, producing a stable sawtooth pattern (peak during rollout generation, drops after trim) with no upward trend. Verified on alphabet-sort (512 rollouts/step, 20 steps, no wandb): - Without fix: 941 MB → 973 MB by step 3 (+6 MB/step, unbounded) - With fix: 941 MB → 942 MB by step 5 (flat, sawtooth only) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ff4eb04 to
faf31fa
Compare
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.
Summary
Following the glibc heap fix (#2527), a secondary RSS accumulation was identified in the orchestrator's wandb sample logging path. This PR tracks investigation and fix.
Bug:
WandbMonitor.log_samples()causes ~2.5 MB/step RSS growth whenlog_extras.interval=1. At the defaultinterval=10this is ~0.3 MB/step — slow but unbounded over long runs.Root cause (partially understood): The accumulation is inside wandb's internals — not the Python
wandb.Tableobject itself. Resettingself.samples_tableafter eachwandb.log()call (which clearstable.data) had no measurable effect on RSS, ruling out the Python table object as the source. The leak is somewhere in wandb's serialization/upload layer.Reproduction
Data
Post-trim
RssAnonper completed step (alphabet-sort, 512 rollouts/step):No-wandb baseline is flat. With wandb at
interval=1: ~2.5 MB/step monotonic drift thatmalloc_trimcannot reclaim (Python/wandb heap, not glibc).At
interval=10(default) the drift is ~0.3 MB/step — approximately 18 MB per hour at a 60s/step pace.What was ruled out
wandb.TablePython object accumulation: resettingself.samples_tableafter eachwandb.log()call made no difference to the observed RSS drift — ruled out as the primary causemalloc_trim(0); confirmed not the cause of this residual drift