Skip to content

Commit 80a2a60

Browse files
committed
Stresstest fix - Add limits to the graph mutation stress test
1 parent c024517 commit 80a2a60

File tree

1 file changed

+14
-4
lines changed
  • ddprof-stresstest/src/jmh/java/com/datadoghq/profiler/stresstest/scenarios/counters

1 file changed

+14
-4
lines changed

ddprof-stresstest/src/jmh/java/com/datadoghq/profiler/stresstest/scenarios/counters/GraphMutation.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,27 @@
33
import org.openjdk.jmh.annotations.Benchmark;
44
import org.openjdk.jmh.annotations.Threads;
55

6-
import java.util.Queue;
7-
import java.util.concurrent.ConcurrentLinkedQueue;
86
import java.util.concurrent.ThreadLocalRandom;
7+
import java.util.concurrent.atomic.AtomicReferenceArray;
98

109
public class GraphMutation {
1110

1211
public static class GraphNode {
13-
private final Queue<GraphNode> nodes = new ConcurrentLinkedQueue<>();
12+
// Use a fixed-size array instead of unbounded queue
13+
// This naturally bounds memory while still allowing realistic stress testing
14+
private static final int MAX_LINKS = 10000;
15+
private final AtomicReferenceArray<GraphNode> links = new AtomicReferenceArray<>(MAX_LINKS);
16+
private volatile int linkIndex = 0;
1417

1518
public void link(GraphNode node) {
16-
nodes.add(node);
19+
// Simple round-robin replacement - no expensive size checks or polling
20+
int index = (linkIndex++) % MAX_LINKS;
21+
links.set(index, node);
22+
}
23+
24+
// Optional: method to access links if needed for verification
25+
public GraphNode getLink(int index) {
26+
return links.get(index % MAX_LINKS);
1727
}
1828
}
1929

0 commit comments

Comments
 (0)