Repository navigation
refchain: reduce ancestor-fanout and batch allocation churn (PROF-16467) - #943
Conversation
Scan-Build Report
Bug Summary
Filter Results by FileReports
|
|||||||||||||||||||||||||||||||||||||||||||||||||
|
This comment will be updated automatically if new data arrives. 🔗 Commit SHA: 1105eb2 | Docs | View more details | Give us feedback! |
CI Test ResultsRun: #43883060606 | Commit:
Status Overview
Legend: ✅ passed | ❌ failed | ⚪ skipped | 🚫 cancelled Summary: Total: 32 | Passed: 32 | Failed: 0 Updated: 2026-11-16 14:38:18 UTC |
|
@DataDog review |
There was a problem hiding this comment.
More details
Static inspection found the bounded batch set preserves membership and completion bookkeeping, including clearing stale completion marks before JNI setup failures. Runtime behavior and allocation reductions were not independently verified.
🤖 Bits Code Review · Commit 8e83229
8e83229 to
f02503e
Compare
|
@DataDog review |
There was a problem hiding this comment.
More details
Static review found that the batch descriptor preserves traversal bookkeeping and clears completion marks before JNI setup can fail, preventing stale completion state from affecting a later batch. No actionable defects were identified.
🤖 Bits Code Review · Commit f02503e
5c27d95 to
4d5bacf
Compare
|
Rebased onto Re-review: Sphinx (range |
dfec3fa to
4ea7b58
Compare
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.
The oversized-batch cleanup test depends on a warmed singleton cache and fails when run alone: it counts 601 deleted JNI local references while expecting 600.
🤖 Bits Code Review · Commit 4ea7b58
There was a problem hiding this comment.
More details
The PR reduces ancestor-fanout and batch allocation churn and prevents stale completion marks from surviving JNI setup failures. The oversized-batch test now warms the Object-class cache before measuring cleanup, resolving the earlier isolated-run failure; no findings remain open.
🤖 Bits Code Review · Commit 1fd9c94
rkennke
left a comment
There was a problem hiding this comment.
Some comments from me inline.
Also, my clanker review found the following, feel free to fix or leave it out:
Tests (Low)
- Shared pause counter in the allocation tests (referenceChainsAllocation_ut.cpp:35)
- accountingHook changes the global g_pause_depth from whichever thread calls a mock. The thread check in shouldCount() only filters reads.
- If the tracker's background BFS thread ever called a mock while counting was on, the test thread would skip real allocations, and the "does not allocate" assertions could pass when they shouldn't.
- This is latent: the BFS thread is probably idle in these tests, but nothing enforces it. Making it thread_local fixes it.
- BatchTrackerGuard used inconsistently (referenceChainsBatchTests.inc:12, referenceChainsAllocation_ut.cpp:230)
- These tests call start() by hand and reach stop() only on success. A failed ASSERT_* or a throw from seedBatchEntry leaves the process-wide tracker running, so one failure spreads to later tests. The fixture
teardown doesn't stop the tracker. - The same pattern already exists in referenceChainsBfsTests.inc. What's new is that this PR adds BatchTrackerGuard for exactly this case and uses it only in referenceChainsBatchFailureTests.inc.
- No test for the empty-slot early exit (referenceChainBatchSet.h:106)
- reset() leaves stale keys in place. If the _flags[i] == 0 early exit in findSlot were removed, marking a tag from before the reset would silently succeed instead of throwing.
- ReuseAfterResetForgetsOldKeys only does reads, which the flag check hides, so it would still pass.
- Suggested test: addResolved(100); markMember(100); reset();, then EXPECT_THROW for both markers.
- No test for the reset in admitStaticFieldRoots (referenceChainTraversal.cpp:908)
- Removing the _batch_set.reset() there would let marks from the previous batch leak into the static-field sweep. No test would notice, because StaticFieldSweepAdmitsOneHopPastEachClass starts with an empty set.
- Suggested test: run expandFrontier() first, then the sweep, and check that it still goes only one hop past each class.
f9b3fa1 to
f5c720b
Compare
There was a problem hiding this comment.
More details
The batch reset now precedes JNI holder setup, preventing setup failures from consuming previous completion marks. Runtime behavior and allocation budgets remain unverified because unit tests could not run.
🤖 Bits Code Review · Commit f5c720b
|
Addressed the four test findings in f5c720b94: the allocation-test pause depth is thread-local, the batch/allocation tests (and the newly added rotation test) use Verified on the rebased head: |
kaahos
left a comment
There was a problem hiding this comment.
except 1 nit comment, this looks good to me, thanks!
Also asserts the unreachable addResolved full-table fall-through (kaahos review nits on #943).
rkennke
left a comment
There was a problem hiding this comment.
Looks good to me! Thank you!
|
Thanks all for reviews! Merging. |
f02c680
into
main
What does this PR do?:
Reduces per-batch and ancestor-fanout allocation churn in the live-heap reference-chain collector:
trackLeakAccumulation()now looks up the parent-fanout entry before inserting, so a repeated ancestor allocation event only allocates on a genuine miss.std::unordered_*containers inexpandFrontier()are replaced by one tracker-owned, fixed-capacityReferenceChainBatchSet(512 tags, load factor ≤ 0.5, no per-element allocation on valid paths), with one static descriptor instead of three heap containers per batch.EnsureLocalCapacity/array-setup failure can no longer consume completion marks recorded by a previous batch (behavior correction; reproduced in a regression test).Motivation:
Tracker: PROF-16467. Traced collector runs showed the fanout
emplacepath allocating a fresh 32-byte node for every repeated ancestor hop, and each expandFrontier batch allocating membership/live-map/completion containers plus rehash buckets. The batch fix also removes a completion-cursor interaction where a failed JNI setup silently consumed the previous batch's completion marks.Additional Notes:
.knowledgebase/memories/, 9 files — batch scratch, fanout emplace, lifetime map, JVM-side amplification, measured retention) now travel with this PR, per the knowledgebase rule.Measured on Linux x64/glibc/HotSpot 21 (one traced run per arm, 4-arm A/B: baseline / fanout-only / batch-only / combined; candidate
5c27d9534— the rebase changed no production code path):ReferenceChainTrackerinstance size +9,224 B (sizeof(ReferenceChainBatchSet), compile-time); measuredexpandFrontier/admitStaticFieldRootsstack frames shrink by 144 B / 64 B.How to test the change?:
referenceChainBatchSet_ut.cpp(bounded-set contract, capacity, probe behavior),referenceChainsAllocation_ut.cpp(allocation budgets on the production path), andreferenceChainsBatchTests.inc/referenceChainsBatchFailureTests.inc(batch success, failure exits, reordering, oversized batches, completion reset after JNI setup failure).5c27d9534): native debug 1,169 / release 1,142; Linux native debug 1,319, release allocation 6, ASan 255+6+8+3; Java reference-chain tests 21, zero skips on both platforms.dfec3fad7: CI green forcheck-formatting,gtest-release-amd64,gtest-asan-amd64,gtest-release-arm64,gtest-asan-arm64,gtest-tsan-amd64,gtest-tsan-arm64,stresstest:x64,stresstest:x64-musl.f5c720b94, rebased ontoe0e38db7d; PR diff patch-id unchanged from the reviewed range)::ddprof-lib:gtestDebug,qualityChecks, andspotlessCheck— 1,191 passed, 11 skipped, 0 failed across 1,202 native tests (skip reasons inbuild/reports/claude/gradle-summary.md).qualityCheckspassed; its signal-reachability subcheck skipped because the debug objects are not ELF. CI on this head: 68 pass, 45 pending, 9 skipped, no failures at last check. The separate OpenJ9 JDK 25 integration symptom is tracked as PROF-16618.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.