Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ protected void after() throws Exception {

@Override
protected String getProfilerCommand() {
return "cpu=100us,event=ctimer";
// cpu=100us signal-based sampling is much more expensive under ASAN (the signal
// handler itself is ASAN-instrumented), which can inflate the sample count and,
// via the per-sample stack-trace materialization above, the test heap. Sample
// coarser under ASAN.
return isAsan() ? "cpu=1ms,event=ctimer" : "cpu=100us,event=ctimer";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ protected void after() throws Exception {

@Override
protected String getProfilerCommand() {
return "cpu=100us,lightweight=yes";
// cpu=100us signal-based sampling is much more expensive under ASAN (the signal
// handler itself is ASAN-instrumented), which can inflate the sample count and,
// via the per-sample accessor calls above, the test heap. Sample coarser under ASAN.
return isAsan() ? "cpu=1ms,lightweight=yes" : "cpu=100us,lightweight=yes";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ public class VtableReceiverFrameTest extends AbstractProfilerTest {

@Override
protected String getProfilerCommand() {
return "cpu=1ms";
// cpu=1ms sampling over the fixed workload below still produces an ASAN-scaled
// number of samples (signal handling is slower under ASAN), and every sample's
// stack trace is materialized below, so sample coarser under ASAN.
return isAsan() ? "cpu=10ms" : "cpu=1ms";
}

abstract static class Shape {
Expand All @@ -41,7 +44,11 @@ static class Triangle extends Shape {

private int profiledWork(Shape... shapes) {
int result = 0;
for (int i = 0; i < 10_000_000; i++) {
// Reduce workload under ASAN: combined with the coarser sampling rate above, this
// bounds the number of samples (and thus the stack-trace strings materialized
// below) regardless of how much ASAN slows down signal handling.
int iterations = isAsan() ? 1_000_000 : 10_000_000;
Comment thread
jbachorik marked this conversation as resolved.
Outdated
for (int i = 0; i < iterations; i++) {
for (Shape shape : shapes) {
result += shape.area();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,18 @@ public void test() throws Exception {
Method arrayListAdd = ArrayList.class.getDeclaredMethod("add", Object.class);
Constructor<?> linkedListConstructor = LinkedList.class.getConstructor();
Method linkedListAdd = LinkedList.class.getDeclaredMethod("add", Object.class);
// need to invoke enough times to result in generation of accessors and to record some cpu time
// need to invoke enough times to result in generation of accessors and to record some cpu time.
// Under ASAN, cpu=100us sampling combined with this fixed iteration count produces a much
// larger sample set (stack-trace signal handling is slower under ASAN), and every sample's
// stack trace is materialized below, so reduce the iteration count to bound the sample count.
int iterations = isAsan() ? 10_000 : 100_000;
int count = 0;
for (int i = 0; i < 100_000; i++) {
for (int i = 0; i < iterations; i++) {
Object list = arrayListConstructor.newInstance();
arrayListAdd.invoke(list, "element");
count += ((List<?>) list).size();
}
for (int i = 0; i < 100_000; i++) {
for (int i = 0; i < iterations; i++) {
Object list = linkedListConstructor.newInstance();
linkedListAdd.invoke(list, "element");
count += ((List<?>) list).size();
Expand Down Expand Up @@ -63,6 +67,6 @@ public void test() throws Exception {

@Override
protected String getProfilerCommand() {
return "cpu=100us";
return isAsan() ? "cpu=1ms" : "cpu=100us";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@
public class MegamorphicCallTest extends AbstractProfilerTest {
@Override
protected String getProfilerCommand() {
return "wall=100us";
// wall=100us over the fixed workload below is ~10k samples/s. Under ASAN each
// invocation is much slower, so the same fixed-rate sampling over a much longer
// wall-clock duration produces hundreds of thousands of samples, and stack-trace
// stringification of all of them (below) OOMs the test-runner heap. Sample 10x
// coarser under ASAN, combined with a smaller workload, to bound the sample count.
return isAsan() ? "wall=1ms" : "wall=100us";
}

private static int calculation() {
Expand Down Expand Up @@ -60,9 +65,9 @@ public int calculate() {
}
}

private int profiledWork(Calculator... calculators) {
private int profiledWork(int iterations, Calculator... calculators) {
int result = 0;
for (int i = 0; i < 1_000_000; i++) {
for (int i = 0; i < iterations; i++) {
for (Calculator calculator : calculators) {
result += calculator.calculate();
}
Expand All @@ -74,7 +79,11 @@ private int profiledWork(Calculator... calculators) {
public void testITableStubs() {
Assumptions.assumeFalse(Platform.isZing() || Platform.isJ9());
registerCurrentThreadForWallClockProfiling();
int result = profiledWork(new Calculator1(), new Calculator2(), new Calculator3());
// Reduce workload under ASAN: combined with the coarser wall rate above, this
// bounds the number of samples (and thus the stack-trace strings materialized
// below) regardless of how much ASAN slows down each invocation.
int iterations = isAsan() ? 100_000 : 1_000_000;
int result = profiledWork(iterations, new Calculator1(), new Calculator2(), new Calculator3());
System.err.println(result);
stopProfiler();
IItemCollection events = verifyEvents("datadog.MethodSample");
Expand Down
Loading