Skip to content

Commit d1f2a0f

Browse files
jbachorikclaude
andcommitted
Gate DirectMemoryAntagonist.burstLoop() on governor; log throttle transitions; disable Gradle daemon in inline chaos.jar build
burstLoop() had its own fixed sleep but never checked MemoryGovernor, letting it allocate at full rate regardless of memory pressure. Governor now logs each throttle/release transition so CI runs show whether it engaged. A lingering Gradle daemon from the inline chaosJar build was also sharing the CI container's cgroup with the chaos JVM. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 2a3e926 commit d1f2a0f

3 files changed

Lines changed: 15 additions & 3 deletions

File tree

ddprof-stresstest/src/chaos/java/com/datadoghq/profiler/chaos/DirectMemoryAntagonist.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ private void burstLoop() {
115115
Thread.currentThread().interrupt();
116116
return;
117117
}
118+
MemoryGovernor.pace();
118119
}
119120
sink.addAndGet(acc);
120121
}

ddprof-stresstest/src/chaos/java/com/datadoghq/profiler/chaos/MemoryGovernor.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,22 @@ private static void update(Path usagePath, long limitBytes) throws IOException {
119119

120120
boolean high = cgroupFraction >= CGROUP_HIGH_WATERMARK || heapFraction >= HEAP_HIGH_WATERMARK;
121121
boolean low = cgroupFraction <= CGROUP_LOW_WATERMARK && heapFraction <= HEAP_LOW_WATERMARK;
122-
if (high) {
122+
if (high && !throttled) {
123123
throttled = true;
124-
} else if (low) {
124+
log(cgroupFraction, heapFraction, true);
125+
} else if (low && throttled) {
125126
throttled = false;
127+
log(cgroupFraction, heapFraction, false);
126128
}
127129
// else: in the dead zone between watermarks — keep current state.
128130
}
129131

132+
private static void log(double cgroupFraction, double heapFraction, boolean nowThrottled) {
133+
System.out.println("[chaos] memory-governor " + (nowThrottled ? "throttling" : "released")
134+
+ " cgroup=" + String.format("%.2f", cgroupFraction)
135+
+ " heap=" + String.format("%.2f", heapFraction));
136+
}
137+
130138
private static Path firstReadable(Path[] candidates) {
131139
for (Path p : candidates) {
132140
if (Files.isReadable(p)) {

utils/run-chaos-harness.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,10 @@ fi
110110
CHAOS_JAR="${ROOT}/ddprof-stresstest/build/libs/chaos.jar"
111111
if [ ! -f "${CHAOS_JAR}" ]; then
112112
echo "chaos.jar not present — building inline"
113-
( cd "${ROOT}" && ./gradlew :ddprof-stresstest:chaosJar -q )
113+
# --no-daemon: a lingering Gradle daemon shares this container's cgroup with
114+
# the chaos JVM we're about to launch and eats into the same memory ceiling
115+
# the MemoryGovernor is trying to protect.
116+
( cd "${ROOT}" && ./gradlew :ddprof-stresstest:chaosJar -q --no-daemon )
114117
fi
115118
if [ ! -f "${CHAOS_JAR}" ]; then
116119
echo "FAIL:chaos.jar unavailable" >&2

0 commit comments

Comments
 (0)