Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 2 additions & 5 deletions ddprof-lib/src/main/cpp/counters.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,8 @@
X(REFERENCE_CHAIN_CANDIDATE_COUNT, "reference_chain_candidate_count") \
X(REFERENCE_CHAIN_CANDIDATES_FOUND, "reference_chain_candidates_found") \
/* hasLeakSignal() gate evaluations refused while the OOM urgency latch is \
* set and selectLeakCandidates() found zero candidates - a heap-wide leak \
* no single klass explains, so no reference-chain search may start. \
* One increment per refused evaluation, not per urgency episode: evaluation \
* runs only after canAffordNewSearch()'s safepoint budget check and follows \
* the ramped cadence. */ \
* set and selectLeakCandidates() found zero candidates (a heap-wide leak no \
* single klass explains). Counts evaluations (~1/s while latched), not episodes. */ \
X(REFERENCE_CHAIN_URGENT_NO_CANDIDATE, "reference_chain_urgent_no_candidate") \
/* Heap-floor seqlock: samples DROPPED when a writer claims a slot whose \
* seq is still the sentinel - only possible if the ring lapped an \
Expand Down
104 changes: 104 additions & 0 deletions ddprof-lib/src/main/cpp/javaApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1473,6 +1473,75 @@ Java_com_datadoghq_profiler_JavaProfiler_isUrgentForTest0(JNIEnv *env,
return tracker->isUrgentForTest() ? JNI_TRUE : JNI_FALSE;
}

// Places the previous pass a controlled distance in the past and sets the effective cadence
// shouldRunPass()'s minimum-spacing gate enforces - see setPassSpacingForTest().
extern "C" DLLEXPORT void JNICALL
Java_com_datadoghq_profiler_JavaProfiler_setReferenceChainPassSpacingForTest0(
JNIEnv *env, jclass unused, jlong ms_since_last_pass, jlong cadence_ms) {
ProfiledThread::initCurrentThreadSignalSafe();
ReferenceChainTracker::instance()->setPassSpacingForTest(
(u64)ms_since_last_pass, (u64)cadence_ms);
}

// Sets the root-enumeration scheduling state (last attempt's time and measured in-safepoint
// cost) - see setRootEnumStateForTest().
extern "C" DLLEXPORT void JNICALL
Java_com_datadoghq_profiler_JavaProfiler_setReferenceChainRootEnumStateForTest0(
JNIEnv *env, jclass unused, jlong ms_since_last_enum,
jlong last_enum_cost_ms) {
ProfiledThread::initCurrentThreadSignalSafe();
ReferenceChainTracker::instance()->setRootEnumStateForTest(
(long)ms_since_last_enum, (u64)last_enum_cost_ms);
}

// Evaluates shouldRunRootEnum() with a synthetic clock so a test can place the last attempt a
// controlled distance in the past.
extern "C" DLLEXPORT jboolean JNICALL
Java_com_datadoghq_profiler_JavaProfiler_shouldRunRootEnumForTest0(
JNIEnv *env, jclass unused, jboolean manual_first_pass) {
ProfiledThread::initCurrentThreadSignalSafe();
return ReferenceChainTracker::instance()->shouldRunRootEnumForTest(
OS::nanotime(), manual_first_pass == JNI_TRUE)
? JNI_TRUE
: JNI_FALSE;
}

// Forces a started, RUNNING search with fresh pain budgets so shouldRunPassForTest0() evaluates
// the running-search gates deterministically - see forceRunningSearchForTest().
extern "C" DLLEXPORT void JNICALL
Java_com_datadoghq_profiler_JavaProfiler_forceRunningReferenceChainSearchForTest0(
JNIEnv *env, jclass unused) {
ProfiledThread::initCurrentThreadSignalSafe();
ReferenceChainTracker::instance()->forceRunningSearchForTest();
}

// Sets the canary chase's candidate count and found-bits mask so shouldRunPassForTest0()
// evaluates the canary lane - see setCanaryChaseStateForTest().
extern "C" DLLEXPORT void JNICALL
Java_com_datadoghq_profiler_JavaProfiler_setReferenceChainCanaryStateForTest0(
JNIEnv *env, jclass unused, jint candidate_count, jlong found_bits) {
ProfiledThread::initCurrentThreadSignalSafe();
ReferenceChainTracker::instance()->setCanaryChaseStateForTest(
(int)candidate_count, (u64)found_bits);
}

// Current adaptive root-enumeration interval floor - see rootEnumIntervalFloorNs().
extern "C" DLLEXPORT jlong JNICALL
Java_com_datadoghq_profiler_JavaProfiler_rootEnumIntervalFloorNsForTest0(
JNIEnv *env, jclass unused) {
ProfiledThread::initCurrentThreadSignalSafe();
return (jlong)ReferenceChainTracker::instance()
->rootEnumIntervalFloorNsForTest();
}

// Live GC-finish epoch - see gcFinishEpoch() (relaxed atomic load, no lock needed).
extern "C" DLLEXPORT jlong JNICALL
Java_com_datadoghq_profiler_JavaProfiler_referenceChainGcFinishEpochForTest0(
JNIEnv *env, jclass unused) {
ProfiledThread::initCurrentThreadSignalSafe();
return (jlong)ReferenceChainTracker::instance()->gcFinishEpoch();
}

#else // !DEBUG

// Release builds: no-op stubs so the Java natives still link.
Expand Down Expand Up @@ -1595,6 +1664,41 @@ Java_com_datadoghq_profiler_JavaProfiler_backdateLeakSignalActivationForTest0(
return 0;
}

extern "C" DLLEXPORT void JNICALL
Java_com_datadoghq_profiler_JavaProfiler_setReferenceChainPassSpacingForTest0(
JNIEnv *env, jclass unused, jlong ms_since_last_pass, jlong cadence_ms) {}

extern "C" DLLEXPORT void JNICALL
Java_com_datadoghq_profiler_JavaProfiler_setReferenceChainRootEnumStateForTest0(
JNIEnv *env, jclass unused, jlong ms_since_last_enum,
jlong last_enum_cost_ms) {}

extern "C" DLLEXPORT jboolean JNICALL
Java_com_datadoghq_profiler_JavaProfiler_shouldRunRootEnumForTest0(
JNIEnv *env, jclass unused, jboolean manual_first_pass) {
return JNI_FALSE;
}

extern "C" DLLEXPORT void JNICALL
Java_com_datadoghq_profiler_JavaProfiler_forceRunningReferenceChainSearchForTest0(
JNIEnv *env, jclass unused) {}

extern "C" DLLEXPORT void JNICALL
Java_com_datadoghq_profiler_JavaProfiler_setReferenceChainCanaryStateForTest0(
JNIEnv *env, jclass unused, jint candidate_count, jlong found_bits) {}

extern "C" DLLEXPORT jlong JNICALL
Java_com_datadoghq_profiler_JavaProfiler_rootEnumIntervalFloorNsForTest0(
JNIEnv *env, jclass unused) {
return 0;
}

extern "C" DLLEXPORT jlong JNICALL
Java_com_datadoghq_profiler_JavaProfiler_referenceChainGcFinishEpochForTest0(
JNIEnv *env, jclass unused) {
return 0;
}

extern "C" DLLEXPORT void JNICALL
Java_com_datadoghq_profiler_JavaProfiler_setLeakSignalActivatedNsForTest0(
JNIEnv *env, jclass unused, jlong activatedNs) {}
Expand Down
3 changes: 3 additions & 0 deletions ddprof-lib/src/main/cpp/referenceChainFrontier.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ constexpr u8 CANARY_STUCK = 3;
// starts from a brand-new-search shape (release-then-restart, fresh TTL clock, no urgency
// carry-over).
constexpr u8 RECORDING_END = 4;
// The root enumerator returned a JVMTI error on MAX_CONSECUTIVE_ENUM_ERRORS consecutive attempts -
// the root picture is unusable and retrying is not making progress.
constexpr u8 ROOT_ENUM_ERROR = 5;
} // namespace SearchAbandonReason

// Metadata for one tagged frontier object.
Expand Down
Loading
Loading