Repository navigation
Reference-chain cache: rebuild stale chains (improved path, correlation) instead of erasing them - #898
Reference-chain cache: rebuild stale chains (improved path, correlation) instead of erasing them#898jbachorik wants to merge 18 commits into
Conversation
CI Test ResultsRun: #43464775227 | Commit:
Status Overview
Legend: ✅ passed | ❌ failed | ⚪ skipped | 🚫 cancelled Summary: Total: 32 | Passed: 32 | Failed: 0 Updated: 2026-11-13 17:02:12 UTC |
7786904 to
bef4356
Compare
Scan-Build Report
Bug Summary
Filter Results by FileReports
|
|||||||||||||||||||||||||||||||||||||||||||||||||
|
@DataDog review |
There was a problem hiding this comment.
Rebuilding before leak-tag assignment can preserve an outdated cached target identity, causing subsequent dumps to lose allocation-sample correlation for newly tagged instances.
🤖 Bits Code Review · Commit bef4356
7f31c2e to
bdf0022
Compare
|
Scope addition: |
improveChain/reparent/root-kind upgrades queued a deferred invalidation that drainPendingChainEvents applied as an erase at dump time. If the search then terminated via the canary, nothing could rebuild the erased chains (candidate and discovered state are zeroed, search pain-budget blocked ~11-15s), losing the correlation for the rest of the window - against the restartSearch() contract that resolved chains stay cached across a restart. Split deferred invalidations into EVICT (noise eviction, filter: erased at dump time as before) and REBUILD (path changed, source still live: applied by the BFS-thread poll, which rebuilds the chain from the intact frontier and keeps the old chain if the rebuild fails). Kind is encoded in-band in the existing bounded pending buffers; no new allocation or locks. Reproducer: ReferenceChainsBfsTest.ImprovedPathInvalidationKeepsLeakChainAcrossTerminalReset (fails before, passes after). PROF-16316.
4455886 to
00d9cc2
Compare
All four reference-chain slow e2e tests leave quarantine: the pr-889 regime plus the W5 test-side pacing fixes and the PROF-16316 improveChain invalidation fix (PR #898) cleared the failures. The gc-root musl-aarch64 line is dropped after a 10/10 clean musl-aarch64 JDK11 container validation of the full stack.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 252683015a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Rebuilding a cached leak-correlated chain can leave its candidate marked unresolved, causing unnecessary heap walks, backoff, and eventual search abandonment despite a valid chain being cached.
🤖 Bits Code Review · Commit 2526830
…-lock guards; document the invalidation contract
There was a problem hiding this comment.
More details
The candidate-progress regression is fixed: rebuilt leak-correlated chains now mark matching candidates found. The PR preserves cached chains through bounded BFS rebuilds, retains eviction semantics, includes test quarantines, and now documents its invalidation policy and uses scoped pending-lock guards; no review findings remain open.
🤖 Bits Code Review · Commit 48f3bd6
…alidation # Conflicts: # ddprof-lib/src/test/cpp/referenceChainsLifecycleTests.inc # ddprof-test/quarantine.txt
…antine entry on main gates it while #979 fixes the root cause
|
@DataDog review |
There was a problem hiding this comment.
More details
Static analysis supports preserving stale chains across terminal cleanup while generation guards and replace-only updates prevent rebuilds from resurrecting evicted entries. No reportable defects were identified.
🤖 Bits Code Review · Commit 927e940
All four reference-chain slow e2e tests leave quarantine: the pr-889 regime plus the W5 test-side pacing fixes and the PROF-16316 improveChain invalidation fix (PR #898) cleared the failures. The gc-root musl-aarch64 line is dropped after a 10/10 clean musl-aarch64 JDK11 container validation of the full stack.
All four reference-chain slow e2e tests leave quarantine: the pr-889 regime plus the W5 test-side pacing fixes and the PROF-16316 improveChain invalidation fix (PR #898) cleared the failures. The gc-root musl-aarch64 line is dropped after a 10/10 clean musl-aarch64 JDK11 container validation of the full stack.
…alidation # Conflicts: # ddprof-test/quarantine.txt
All four reference-chain slow e2e tests leave quarantine: the pr-889 regime plus the W5 test-side pacing fixes and the PROF-16316 improveChain invalidation fix (PR #898) cleared the failures. The gc-root musl-aarch64 line is dropped after a 10/10 clean musl-aarch64 JDK11 container validation of the full stack.
…alidation # Conflicts: # doc/architecture/LiveHeapReferenceChainsImplementation.md
All four reference-chain slow e2e tests leave quarantine: the pr-889 regime plus the W5 test-side pacing fixes and the PROF-16316 improveChain invalidation fix (PR #898) cleared the failures. The gc-root musl-aarch64 line is dropped after a 10/10 clean musl-aarch64 JDK11 container validation of the full stack.
All four reference-chain slow e2e tests leave quarantine: the pr-889 regime plus the W5 test-side pacing fixes and the PROF-16316 improveChain invalidation fix (PR #898) cleared the failures. The gc-root musl-aarch64 line is dropped after a 10/10 clean musl-aarch64 JDK11 container validation of the full stack.
All four reference-chain slow e2e tests leave quarantine: the pr-889 regime plus the W5 test-side pacing fixes and the PROF-16316 improveChain invalidation fix (PR #898) cleared the failures. The gc-root musl-aarch64 line is dropped after a 10/10 clean musl-aarch64 JDK11 container validation of the full stack.
All four reference-chain slow e2e tests leave quarantine: the pr-889 regime plus the W5 test-side pacing fixes and the PROF-16316 improveChain invalidation fix (PR #898) cleared the failures. The gc-root musl-aarch64 line is dropped after a 10/10 clean musl-aarch64 JDK11 container validation of the full stack.
All four reference-chain slow e2e tests leave quarantine: the pr-889 regime plus the W5 test-side pacing fixes and the PROF-16316 improveChain invalidation fix (PR #898) cleared the failures. The gc-root musl-aarch64 line is dropped after a 10/10 clean musl-aarch64 JDK11 container validation of the full stack.
All four reference-chain slow e2e tests leave quarantine: the pr-889 regime plus the W5 test-side pacing fixes and the PROF-16316 improveChain invalidation fix (PR #898) cleared the failures. The gc-root musl-aarch64 line is dropped after a 10/10 clean musl-aarch64 JDK11 container validation of the full stack.
All four reference-chain slow e2e tests leave quarantine: the pr-889 regime plus the W5 test-side pacing fixes and the PROF-16316 improveChain invalidation fix (PR #898) cleared the failures. The gc-root musl-aarch64 line is dropped after a 10/10 clean musl-aarch64 JDK11 container validation of the full stack.
All four reference-chain slow e2e tests leave quarantine: the pr-889 regime plus the W5 test-side pacing fixes and the PROF-16316 improveChain invalidation fix (PR #898) cleared the failures. The gc-root musl-aarch64 line is dropped after a 10/10 clean musl-aarch64 JDK11 container validation of the full stack.
All four reference-chain slow e2e tests leave quarantine: the pr-889 regime plus the W5 test-side pacing fixes and the PROF-16316 improveChain invalidation fix (PR #898) cleared the failures. The gc-root musl-aarch64 line is dropped after a 10/10 clean musl-aarch64 JDK11 container validation of the full stack.
|
Closing: #899 landed the EVICT/REBUILD invalidation mechanism on main ( What #899 did not take is being reworked as a small follow-up against current main: correlation-triggered REBUILD in |
What does this PR do?:
Splits reference-chain deferred cache invalidations into two kinds. EVICT (noise eviction, event filter) keeps today's behavior: the cached chain is erased at dump time. REBUILD keeps the cached chain and has the BFS-thread poll rebuild it from the intact frontier, overwriting the cache entry on success and keeping the old chain if the rebuild fails. REBUILD is queued by three producers:
improveChain()deeper path, durable-root demotion / root-kind upgrade (source still live), andcorrelateAdmittedLeakTag()when a frontier entry that already has a cached chain gets its leak tag (the cached event's_target_tagis the frontier tag until the rebuild re-binds it).Motivation:
PROF-16316.
improveChain()'s deferred invalidation erased resolved leak-correlated chains that the documentedrestartSearch()contract says must stay cached across a restart ("a chain resolved by the finishing search stays cached (and keeps being re-emitted on every dump) across the restart, since it describes a sample that is still live"). When the improve fires in the terminal pass of a search (new backing array of a growing holder, deeper path), the drain erases the chains, the terminal branch then zeroes candidate/discovered state so nothing can rebuild them, and the search stays pain-budget-blocked ~11-15 s — every later dump re-emits 0 chains and the correlation is lost for the rest of the window.Deterministic reproducer in the e2e suite:
ThreadLocalLeakReferenceChainTest.shouldCorrelateLeakOnThreadCreatedAfterRecordingStarton JDK 11 fails exactly when the pass-1 CPU pain-budget debt is already repaid when the canary closes (15 instrumented runs: debt ≥1021 ms → 4/4 pass, ≤988 ms → 11/11 fail). Pre-existing behavior; the involved paths are untouched by #889.Additional Notes:
The kind is encoded in-band in the existing bounded pending buffers (sign bit; cache keys are non-negative frontier tags) — no new allocation, no new locks; dump-path drain now partitions in place under the existing pending lock. All pending-buffer reads/writes stay under
_pending_chain_invalidations_lock.Rebuild is generation-guarded (
source_search_ns) and replace-only: a rebuild never resurrects an entry a dump has already evicted. A dead-owner rebuild keeps the old chain; a dump evicts it only when the old event's own target is a leak tag whose owner died — a frontier-tag target waits for a later rebuild, cache-pressure eviction, orstart()/stop()'s cache clear.EVICT wins when both kinds are queued for the same tag; duplicate REBUILDs merge.
Accepted cost, flagged for reviewer acknowledgment: correlation-triggered REBUILDs add at most
MAX_CHAIN_REBUILDS_PER_POLL(8)buildChainEvent()heap walks per poll, reusing the existing per-poll rebuild budget, and a correlated chain's dumps carry the frontier-tagged target for at most one poll before the rebuild re-binds it to the leak tag.New gtests:
ReferenceChainsBfsTest.ImprovedPathInvalidationKeepsLeakChainAcrossTerminalReset(fails before, passes after — drives the realheapReferenceCallback→improveChain()path),DumpDrainAppliesEvictAndLeavesRebuildToPoll(EVICT semantics preserved: noise-evicted chains still erased; EVICT beats REBUILD; failed rebuild keeps the old chain),CorrelationQueuesRebuildForUncorrelatedCachedChain(fails before, passes after),CorrelationRebuildYieldsToEvictAndSkipsUncached, and the rebuild-budget/requeue/replace-only/dead-owner suites inreferenceChainsBfsTests.incandreferenceChainsTrackerTests.inc.Scope additions riding this PR, flagged for reviewer acknowledgment: the flaky
NativeThreadNameRaceTestgtest is skipped viaGTEST_SKIP()(test-only; its quarantine entry lands with the gtest-quarantine wiring PR), and the flakyCollapsingSleepTestweight assertion onel7-8-release-amd64is added toddprof-test/quarantine.txt(single observed failure; same-day pass on equivalent code). Also two assert/comment hardenings on the invalidation queue (compaction-invariant tripwire; the requeue-overflow branch is now the single behavior in every build type). The reference-chain churn stress test's budget-exhaustion skip (the approved fix from the allocation-churn PR) is carried here as well: the el7-shared-runner timing that exhausts the pass budget there reproduces on this branch's pipelines identically.Merge note: main syncs 415169a (quarantine.txt: main's #984 entry deletion + PROF-16621 TSan quarantine; the branch's PROF-16583 entry kept) and e877768 (
LiveHeapReferenceChainsImplementation.md: merged #991's doc alignment with the branch's EVICT/REBUILD paragraph; every #991 claim re-verified against the merged code). No production diff beyond the conflict resolutions.How to test the change?:
:ddprof-lib:gtestDebug_referenceChains_ut: 245/245 pass (build log, this candidate).ThreadLocalLeakReferenceChainTest.shouldCorrelateLeakOnThreadCreatedAfterRecordingStarton JDK 11 (11.0.32-tem), debug, quiet Linux x64: 10/10 pass vs ~2/10 failures before — measured on the earlier candidate5d71a2285; the later commits touch only the correlation rebuild path and comments.For Datadog employees:
credentials of any kind, I've requested a security review (run the
dd:platform-security-reviewskill, or file a request via the PSEC review form).
bewairealso runs automatically on every PR.