changeset 844:f742ae6dd9d6

profilers: perfasm should guard itself from humongous regions.
author shade
date Thu, 26 Jun 2014 20:25:17 +0400
parents 5b9c5c60a11c
children a9b803488cb9
files jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java
diffstat 1 files changed, 15 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java	Thu Jun 26 19:56:26 2014 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java	Thu Jun 26 20:25:17 2014 +0400
@@ -70,6 +70,9 @@
     /** Cutoff threshold for hot region: the regions with event count over threshold would be shown */
     private static final double THRESHOLD_RATE = Double.valueOf(System.getProperty("jmh.perfasm.hotThreshold", "0.10"));
 
+    /** Cutoff threshold for large region: the region larger than this would be truncated */
+    private static final int THRESHOLD_TOO_BIG = Integer.getInteger("jmh.perfasm.tooBigThreshold", 1000);
+
     /** Print margin: how many "context" lines without counters to show in each region */
     private static final int PRINT_MARGIN = Integer.getInteger("jmh.perfasm.printMargin", 10);
 
@@ -307,16 +310,20 @@
             int cnt = 1;
             for (Region r : interestingRegions) {
                 printDottedLine(pw, "Region " + cnt);
-                for (ASMLine line : r.code) {
-                    for (String event : EVENTS) {
-                        long count = (line.addr != null) ? r.events.get(event).count(line.addr) : 0;
-                        if (count > 0) {
-                            pw.printf("%6.2f%%  ", 100.0 * count / totalCounts.get(event));
-                        } else {
-                            pw.printf("%9s", "");
+                if (r.code.size() > THRESHOLD_TOO_BIG) {
+                    pw.printf(" <region is too big to display, has %d lines, but threshold is %d>%n", r.code.size(), THRESHOLD_TOO_BIG);
+                } else {
+                    for (ASMLine line : r.code) {
+                        for (String event : EVENTS) {
+                            long count = (line.addr != null) ? r.events.get(event).count(line.addr) : 0;
+                            if (count > 0) {
+                                pw.printf("%6.2f%%  ", 100.0 * count / totalCounts.get(event));
+                            } else {
+                                pw.printf("%9s", "");
+                            }
                         }
+                        pw.println(line.code);
                     }
-                    pw.println(line.code);
                 }
 
                 printDottedLine(pw, null);