2020public class MegamorphicCallTest extends AbstractProfilerTest {
2121 @ Override
2222 protected String getProfilerCommand () {
23- return "wall=100us" ;
23+ // wall=100us over the fixed workload below is ~10k samples/s. Under ASAN each
24+ // invocation is much slower, so the same fixed-rate sampling over a much longer
25+ // wall-clock duration produces hundreds of thousands of samples, and stack-trace
26+ // stringification of all of them (below) OOMs the test-runner heap. Sample 10x
27+ // coarser under ASAN, combined with a smaller workload, to bound the sample count.
28+ return isAsan () ? "wall=1ms" : "wall=100us" ;
2429 }
2530
2631 private static int calculation () {
@@ -60,9 +65,9 @@ public int calculate() {
6065 }
6166 }
6267
63- private int profiledWork (Calculator ... calculators ) {
68+ private int profiledWork (int iterations , Calculator ... calculators ) {
6469 int result = 0 ;
65- for (int i = 0 ; i < 1_000_000 ; i ++) {
70+ for (int i = 0 ; i < iterations ; i ++) {
6671 for (Calculator calculator : calculators ) {
6772 result += calculator .calculate ();
6873 }
@@ -74,7 +79,11 @@ private int profiledWork(Calculator... calculators) {
7479 public void testITableStubs () {
7580 Assumptions .assumeFalse (Platform .isZing () || Platform .isJ9 ());
7681 registerCurrentThreadForWallClockProfiling ();
77- int result = profiledWork (new Calculator1 (), new Calculator2 (), new Calculator3 ());
82+ // Reduce workload under ASAN: combined with the coarser wall rate above, this
83+ // bounds the number of samples (and thus the stack-trace strings materialized
84+ // below) regardless of how much ASAN slows down each invocation.
85+ int iterations = isAsan () ? 100_000 : 1_000_000 ;
86+ int result = profiledWork (iterations , new Calculator1 (), new Calculator2 (), new Calculator3 ());
7887 System .err .println (result );
7988 stopProfiler ();
8089 IItemCollection events = verifyEvents ("datadog.MethodSample" );
0 commit comments