Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
0643752
Keep resolved leak chains across improve-path invalidations
jbachorik Oct 24, 2026
153b138
Fix reference-chain revisits and leak candidate admission
kaahos Oct 23, 2026
7985937
Make reference-chain slow e2e tests robust to walk-pacing latency
jbachorik Oct 24, 2026
65fa1f8
Remove PROF-16305 quarantine from reference-chain slow tests
jbachorik Oct 25, 2026
d683666
sphinx: address review feedback on PR #899
jbachorik Nov 2, 2026
b86e74a
sphinx: address review feedback on PR #899
jbachorik Nov 3, 2026
e294de4
style(java): apply configured Java formatting
jbachorik Nov 11, 2026
89139af
Cap the durable anchor-index share with FIFO eviction
jbachorik Nov 11, 2026
c43c9ff
Re-enlist evicted durable anchors from traversal reports
jbachorik Nov 11, 2026
c18d911
Test the re-enlist wiring in both traversal callbacks
jbachorik Nov 11, 2026
6661d9b
Keep eviction resweep requests separate from sweep completion
jbachorik Nov 11, 2026
ea2e69a
Never drop eviction resweep requests during the restart cooldown
jbachorik Nov 11, 2026
4847e6e
Serve resweep generations only by a completing lap from class 0
jbachorik Nov 11, 2026
5a718ba
Quarantine ElfTestParam.invalidElfSmallMappingAfterUnmap on tsan cell…
jbachorik Nov 12, 2026
e2b2d60
Re-enlist evicted reparented containers via the shared eligibility check
jbachorik Nov 12, 2026
3fe2abf
Drop the eviction-side static sweep cursor restart
jbachorik Nov 12, 2026
3ba2412
Skip the elfparser unmap race under TSan instead of quarantining it
jbachorik Nov 12, 2026
6a5187b
Rotate anchor rotation across the re-enlistment wave and reclaim coll…
jbachorik Nov 13, 2026
14d8036
Address sphinx review findings on reference chains
jbachorik Nov 12, 2026
2263ff8
Fix review findings on the findings fix
jbachorik Nov 12, 2026
1e21c96
Fix reference-chain review findings
jbachorik Nov 16, 2026
fe22026
Keep anchor test hook out of release execution
jbachorik Nov 16, 2026
17b48cb
Defer anchor-index mutations outside JVMTI callbacks
jbachorik Nov 17, 2026
29598d5
Unify anchor reservation and flush thread walks
jbachorik Nov 17, 2026
0127960
refchain: skip journal records whose replay is a known no-op
jbachorik Nov 17, 2026
aeeec27
refchain: preserve progress across journal retries
jbachorik Nov 18, 2026
871a21c
refchain: bound LOCAL staging to what replay can absorb
jbachorik Nov 18, 2026
21e2110
refchain: count displaceable local anchors
jbachorik Nov 19, 2026
36565a0
test: dedupe refchain diagnostics
jbachorik Nov 19, 2026
ac496cc
liveness: retain challenger thread trends
jbachorik Nov 19, 2026
5ad9551
refchain: bound retry staging and overflow
jbachorik Nov 19, 2026
6760d76
refchain: validate journal and rotation boundaries
jbachorik Nov 19, 2026
3c6aca9
fuzz: guard UNIT_TEST staging-budget accessors
jbachorik Nov 19, 2026
ea8e380
refchain: keep the sweep latch across a first-chunk retry
jbachorik Nov 19, 2026
2920cd1
liveness: accumulate newcomers in the challenger pool
jbachorik Nov 20, 2026
d5bfaba
refchain: bound report suppression by index, stamps and retry sequence
jbachorik Nov 20, 2026
35a7019
refchain: consume first looks on walk and roll back overflow edges
jbachorik Nov 20, 2026
9c57d56
profiler: close the reference-chain gate before joining the BFS thread
jbachorik Nov 20, 2026
1de8e56
doc: weaker-JNI suppression no longer trusts a stale sweep stamp
jbachorik Nov 20, 2026
9345d3c
refchain: spend the cap-skipped leak suffix and keep overflow edges c…
jbachorik Nov 20, 2026
2122bf2
liveness: takeover earns against the victim's accumulated evidence
jbachorik Nov 20, 2026
f8fb5c3
refchain: keep fresh turns through the empty-selection return
jbachorik Nov 20, 2026
697569a
Merge remote-tracking branch 'origin/main' into findings-fix-rebase
jbachorik Nov 20, 2026
6aa575c
doc: fold the anchor-index facts into one section
jbachorik Nov 22, 2026
343d099
refchain: guard the class-tag map rebuild and fix the journal comment
jbachorik Nov 22, 2026
a9d7bce
Merge origin/main (PROF-16771 test-cost reduction) into findings-fix-…
jbachorik Nov 22, 2026
e0fd8a5
refchain+ liveness: address datadog-code-review findings on 343d09913
jbachorik Nov 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions ddprof-lib/src/main/cpp/counters.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,9 @@
* signal for spotting a recurrence. */ \
X(METADATA_TREE_NULL_CHILD, "metadata_tree_null_child") \
X(METADATA_TREE_DEPTH_EXCEEDED, "metadata_tree_depth_exceeded") \
/* A resolved datadog.ReferenceChain could not be cached in \
* ReferenceChainTracker::_resolved_chains (referenceChains.h): a brand-new \
* leak-candidate klass arrived with the cache already at \
* MAX_RESOLVED_CHAINS, so its chain is dropped rather than evicting some \
* other still-live sample's chain. See that constant's own comment. */ \
/* A reference-chain event could not be retained for a future dump: a \
* bounded cache or queue was full, or invalidation overflow cleared the \
* resolved-chain cache to avoid emitting stale output. */ \
X(REFERENCE_CHAIN_EVENTS_DROPPED, "reference_chain_events_dropped") \
/* ReferenceChainTracker::releaseSearchTags() (referenceChains.cpp) failed \
* to call GetObjectsWithTags() for at least one batch - the search's tag \
Expand Down
178 changes: 1 addition & 177 deletions ddprof-lib/src/main/cpp/livenessTracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -843,66 +843,6 @@ int LivenessTracker::tagLeakInstances(jvmtiEnv *jvmti,
return tagged;
}

void LivenessTracker::insertThreadGen(KlassCountScratch &scratch,
jint tid, u32 age) {
// Find or create the thread entry for this tid
for (int i = 0; i < scratch.thread_count; i++) {
if (scratch.threads[i].tid == tid) {
// Insert age into the thread's sorted distinct-age array
auto &t = scratch.threads[i];
// Every surviving object counts toward the per-tid retained-count
// bar (TID_RETAINED_COUNT_BAR) BEFORE the age-dedup early return
// below: the count is per-instance, the ages are per-cohort.
t.count++;
for (u32 j = 0; j < t.age_count; j++) {
if (t.ages[j] == age) {
return; // age already counted for this thread
}
}
if (t.age_count < KlassCountScratch::MAX_AGES_PER_THREAD) {
// Insert sorted (small array, linear scan + shift)
u32 pos = t.age_count;
for (u32 j = 0; j < t.age_count; j++) {
if (age < t.ages[j]) {
pos = j;
break;
}
}
for (u32 j = t.age_count; j > pos; j--) {
t.ages[j] = t.ages[j - 1];
}
t.ages[pos] = age;
t.age_count++;
}
return;
}
}
int idx;
if (scratch.thread_count < KlassCountScratch::MAX_THREADS_PER_KLASS) {
idx = scratch.thread_count++;
} else {
// Keeping only the first tids hides later, larger one-shot cohorts behind
// early small allocations. Replace the smallest observed retained set;
// ties prefer keeping the tid with more distinct surviving ages.
idx = 0;
for (int i = 1; i < scratch.thread_count; i++) {
const auto &candidate = scratch.threads[i];
const auto &victim = scratch.threads[idx];
if (candidate.count < victim.count ||
(candidate.count == victim.count && candidate.age_count < victim.age_count)) {
idx = i;
}
}
}
// Count only objects observed since this tid entered the scratch. Inherit
// neither the evicted tid's count nor its ages: both feed qualification.
// Reappearing tids can be undercounted at capacity, never overcounted.
scratch.threads[idx].tid = tid;
scratch.threads[idx].ages[0] = age;
scratch.threads[idx].age_count = 1;
scratch.threads[idx].count = 1;
}

void LivenessTracker::accumulateKlassCount(u32 klass_id, jlong age,
jweak sample_source,
jint tid) {
Expand Down Expand Up @@ -948,6 +888,7 @@ void LivenessTracker::accumulateKlassCount(u32 klass_id, jlong age,
slot.ages.push_back((u32)age);
slot.oldest_count = 0;
slot.thread_count = 0;
slot.challenger_count = 0;
insertOldestSample(slot, sample_source, (u32)age, tid);
insertThreadGen(slot, tid, (u32)age);
}
Expand Down Expand Up @@ -1380,123 +1321,6 @@ bool LivenessTracker::tidPushQualifies(
return hasQualifyingTidGrowth(trend);
}

void LivenessTracker::recordTidTrendSamplesLocked(
int slot, const KlassCountScratch &scratch) {
if (slot < 0 || slot >= _klass_population_size) {
return;
}
KlassPopulationEntry &entry = _klass_population[slot];
// Present tids first: find-or-create their trend and push this epoch's
// distinct-age count. (KlassCountScratch threads always carry >=1
// surviving instance, so every scratch thread has a real claim on a
// slot; a zero-count tid never reaches this fold.)
for (int ti = 0; ti < scratch.thread_count; ti++) {
jint tid = scratch.threads[ti].tid;
KlassPopulationEntry::TidTrend *trend = nullptr;
for (int i = 0; i < entry.tid_trend_count; i++) {
if (entry.tid_trends[i].tid == tid) {
trend = &entry.tid_trends[i];
break;
}
}
if (trend != nullptr && trend->synthetic) {
// Seam-owned history: the test maintains this ramp itself
// (seedTidTrendSample0), and a real fold interleaving its own low
// count for the same tid would reset the trend's hysteresis every
// System.gc() the scenario runs between rounds. Production data has
// no synthetic trends, so this exemption is inert there.
continue;
}
if (trend == nullptr) {
if (entry.tid_trend_count < KlassPopulationEntry::MAX_TID_TRENDS) {
trend = &entry.tid_trends[entry.tid_trend_count++];
} else {
// Full: evict the WEAKEST non-synthetic trend (lowest
// consecutive_positive, then lowest ring_fill) - a genuinely rising
// leak tid accumulates hysteresis fast and resists eviction, while
// machinery tids never build any. Synthetic (test-seeded) trends
// are never evicted by real data. If every slot is synthetic, the
// new tid is simply dropped - production data never marks
// anything synthetic, so this only caps a scenario's own seeding.
int victim = -1;
for (int i = 0; i < entry.tid_trend_count; i++) {
if (entry.tid_trends[i].synthetic) {
continue;
}
if (victim < 0 ||
(entry.tid_trends[i].consecutive_positive <
entry.tid_trends[victim].consecutive_positive) ||
(entry.tid_trends[i].consecutive_positive ==
entry.tid_trends[victim].consecutive_positive &&
entry.tid_trends[i].ring_fill <
entry.tid_trends[victim].ring_fill)) {
victim = i;
}
}
if (victim < 0) {
continue; // all slots synthetic - drop this tid's sample
}
trend = &entry.tid_trends[victim];
}
trend->tid = tid;
trend->ring_head = 0;
trend->ring_fill = 0;
trend->consecutive_positive = 0;
trend->synthetic = false;
}
trend->ring[trend->ring_head] = (u8)scratch.threads[ti].age_count;
trend->count_ring[trend->ring_head] =
(u8)std::min<u32>(scratch.threads[ti].count, UINT8_MAX);
trend->ring_head = (u8)((trend->ring_head + 1) %
KlassPopulationEntry::TID_TREND_RING_SIZE);
if (trend->ring_fill < KlassPopulationEntry::TID_TREND_RING_SIZE) {
trend->ring_fill++;
}
if (tidPushQualifies(*trend, scratch.threads[ti].count)) {
if (trend->consecutive_positive < UINT8_MAX) {
trend->consecutive_positive++;
}
} else {
trend->consecutive_positive = 0;
}
}
// Tracked tids ABSENT this epoch: a thread whose instances all died
// must not keep a stale rising ring - push 0 so the next
// hasQualifyingTidGrowth() fails and the trend's hysteresis resets (the
// per-tid analogue of the population simply stopping). Synthetic
// (test-seeded) trends are exempt: scenarios interleave real
// System.gc()-driven folds with their seeded ramps, and without the
// exemption every real fold would wipe the seeded qualification before
// the test could ever use it (see TidTrend::synthetic's own comment).
for (int i = 0; i < entry.tid_trend_count; i++) {
KlassPopulationEntry::TidTrend &trend = entry.tid_trends[i];
if (trend.synthetic) {
continue;
}
bool present = false;
for (int ti = 0; ti < scratch.thread_count; ti++) {
if (scratch.threads[ti].tid == trend.tid) {
present = true;
break;
}
}
if (present) {
continue;
}
trend.ring[trend.ring_head] = 0;
trend.count_ring[trend.ring_head] = 0;
trend.ring_head = (u8)((trend.ring_head + 1) %
KlassPopulationEntry::TID_TREND_RING_SIZE);
if (trend.ring_fill < KlassPopulationEntry::TID_TREND_RING_SIZE) {
trend.ring_fill++;
}
// A 0-count epoch cannot qualify as a rise - reset now rather than
// deferring to the next push, so a long-absent tid does not keep
// hysteresis from before its population died.
trend.consecutive_positive = 0;
}
}

u64 LivenessTracker::newestHeapFloorSample(u64 *seq_out) const {
// Per-slot seqlock read: the slot's seq validates the payload below it
// (writer: recordHeapFloorSampleUnchecked()). Bounded retry, never a torn
Expand Down
17 changes: 16 additions & 1 deletion ddprof-lib/src/main/cpp/livenessTracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ typedef struct KlassCandidate {
class alignas(alignof(SpinLock)) LivenessTracker {
friend Recording;
friend class LivenessTrackerTestAccessor;
friend class LivenessThreadTrendTestAccessor;

private:
// pre-c++17 we should mark these inline(or out of class)
Expand Down Expand Up @@ -572,6 +573,7 @@ class alignas(alignof(SpinLock)) LivenessTracker {
// generations. Thread ID is stable and naturally separates leak
// threads from noise threads.
static constexpr int MAX_THREADS_PER_KLASS = 16;
static constexpr int MAX_THREAD_CHALLENGERS_PER_KLASS = 4;
static constexpr int MAX_AGES_PER_THREAD = 32;
struct ThreadGens {
jint tid;
Expand All @@ -584,7 +586,15 @@ class alignas(alignof(SpinLock)) LivenessTracker {
};
ThreadGens threads[MAX_THREADS_PER_KLASS];
int thread_count;
// New tids accrue evidence separately when every incumbent meets the retained-count bar.
// At fold, only a challenger that outranks the weakest incumbent replaces a primary slot.
ThreadGens challengers[MAX_THREAD_CHALLENGERS_PER_KLASS];
int challenger_count;
} KlassCountScratch;
static_assert(sizeof(KlassCountScratch::ThreadGens) *
KlassCountScratch::MAX_THREAD_CHALLENGERS_PER_KLASS *
MAX_KLASS_POPULATION_ENTRIES == 143360,
"four-thread challenger scratch must stay within its approved budget");
KlassCountScratch _klass_count_scratch[MAX_KLASS_POPULATION_ENTRIES];
int _klass_count_scratch_size;

Expand Down Expand Up @@ -761,6 +771,11 @@ class alignas(alignof(SpinLock)) LivenessTracker {
void insertOldestSample(KlassCountScratch &scratch, jweak sample_source,
u32 age, jint tid);
void insertThreadGen(KlassCountScratch &scratch, jint tid, u32 age);
// `displaced` (optional, capacity MAX_THREAD_CHALLENGERS_PER_KLASS) receives the incumbents
// promotion replaced, with their pre-replacement epoch sample.
void promoteThreadGenCandidates(KlassCountScratch &scratch,
KlassCountScratch::ThreadGens *displaced = nullptr,
int *displaced_count = nullptr);

// Pushes `count` into klass_id's ring buffer, creating the entry (evicting
// the least-recently-updated entry first if the table is already at
Expand Down Expand Up @@ -867,7 +882,7 @@ class alignas(alignof(SpinLock)) LivenessTracker {
// tracked tid from the scratch and push it a spurious 0 - the same
// fixed-capacity best-effort the scratch itself already accepts.
// _table_lock held exclusively by the caller (foldKlassCountsLocked()).
void recordTidTrendSamplesLocked(int slot, const KlassCountScratch &scratch);
void recordTidTrendSamplesLocked(int slot, KlassCountScratch &scratch);

// The sustained-trend gate (this class's own header comment above,
// "Sustained-trend gate") - both-required growth-magnitude and floor-rise
Expand Down
Loading
Loading