Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/debug/BenchmarkCounters.java @ 18845:f57d86eb036f
removed Node factory methods
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 12 Jan 2015 20:39:04 +0100 |
parents | abd10b6ef99d |
children | a8a2cc98eb55 |
rev | line source |
---|---|
11852
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
1 /* |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
2 * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. |
11852
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
4 * |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
8 * |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
13 * accompanied this code). |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
14 * |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
18 * |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
21 * questions. |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
22 */ |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
23 package com.oracle.graal.hotspot.debug; |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
24 |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
25 import java.io.*; |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
26 import java.util.*; |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
27 import java.util.concurrent.*; |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
28 import java.util.concurrent.atomic.*; |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
29 |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
30 import sun.misc.*; |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
31 |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
32 import com.oracle.graal.api.meta.*; |
15193
96bb07a5d667
Spit up and move GraalInternalError.
Josef Eisl <josef.eisl@jku.at>
parents:
14906
diff
changeset
|
33 import com.oracle.graal.compiler.common.*; |
15261
882f4cb7cfcf
Move Stamps to graal.compiler.common.
Josef Eisl <josef.eisl@jku.at>
parents:
15193
diff
changeset
|
34 import com.oracle.graal.compiler.common.type.*; |
16578
9793d86c21c5
use TTY in BenchmarkCounters
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16480
diff
changeset
|
35 import com.oracle.graal.debug.*; |
11852
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
36 import com.oracle.graal.hotspot.*; |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
37 import com.oracle.graal.hotspot.bridge.*; |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
38 import com.oracle.graal.hotspot.meta.*; |
11893
ec267141f753
more javadoc and output tweaks for dynamic counters
Lukas Stadler <lukas.stadler@jku.at>
parents:
11874
diff
changeset
|
39 import com.oracle.graal.hotspot.replacements.*; |
14724
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
40 import com.oracle.graal.nodes.HeapAccess.BarrierType; |
11852
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
41 import com.oracle.graal.nodes.*; |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
42 import com.oracle.graal.nodes.calc.*; |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
43 import com.oracle.graal.nodes.debug.*; |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
44 import com.oracle.graal.nodes.extended.*; |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
45 import com.oracle.graal.options.*; |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
46 import com.oracle.graal.replacements.nodes.*; |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
47 |
14776
07dd21c7d533
revived use of FindBugs annotations
Doug Simon <doug.simon@oracle.com>
parents:
14724
diff
changeset
|
48 import edu.umd.cs.findbugs.annotations.*; |
07dd21c7d533
revived use of FindBugs annotations
Doug Simon <doug.simon@oracle.com>
parents:
14724
diff
changeset
|
49 |
11874
e0041af765c5
some more javadoc for benchmark counters
Lukas Stadler <lukas.stadler@jku.at>
parents:
11852
diff
changeset
|
50 /** |
e0041af765c5
some more javadoc for benchmark counters
Lukas Stadler <lukas.stadler@jku.at>
parents:
11852
diff
changeset
|
51 * This class contains infrastructure to maintain counters based on {@link DynamicCounterNode}s. The |
e0041af765c5
some more javadoc for benchmark counters
Lukas Stadler <lukas.stadler@jku.at>
parents:
11852
diff
changeset
|
52 * infrastructure is enabled by specifying either the GenericDynamicCounters or |
14906 | 53 * BenchmarkDynamicCounters option. |
54 * <p> | |
14776
07dd21c7d533
revived use of FindBugs annotations
Doug Simon <doug.simon@oracle.com>
parents:
14724
diff
changeset
|
55 * |
14578
d927132f45a4
update comments on BenchmarkCounters (-XX options instead of preprocessor defs)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14163
diff
changeset
|
56 * The counters are kept in a special area allocated for each native JavaThread object, and the |
d927132f45a4
update comments on BenchmarkCounters (-XX options instead of preprocessor defs)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14163
diff
changeset
|
57 * number of counters is configured using {@code -XX:GraalCounterSize=value}. |
d927132f45a4
update comments on BenchmarkCounters (-XX options instead of preprocessor defs)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14163
diff
changeset
|
58 * {@code -XX:+/-GraalCountersExcludeCompiler} configures whether to exclude compiler threads |
d927132f45a4
update comments on BenchmarkCounters (-XX options instead of preprocessor defs)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14163
diff
changeset
|
59 * (defaults to true). |
14776
07dd21c7d533
revived use of FindBugs annotations
Doug Simon <doug.simon@oracle.com>
parents:
14724
diff
changeset
|
60 * |
11874
e0041af765c5
some more javadoc for benchmark counters
Lukas Stadler <lukas.stadler@jku.at>
parents:
11852
diff
changeset
|
61 * The subsystems that use the logging need to have their own options to turn on the counters, and |
e0041af765c5
some more javadoc for benchmark counters
Lukas Stadler <lukas.stadler@jku.at>
parents:
11852
diff
changeset
|
62 * insert DynamicCounterNodes when they're enabled. |
14776
07dd21c7d533
revived use of FindBugs annotations
Doug Simon <doug.simon@oracle.com>
parents:
14724
diff
changeset
|
63 * |
11893
ec267141f753
more javadoc and output tweaks for dynamic counters
Lukas Stadler <lukas.stadler@jku.at>
parents:
11874
diff
changeset
|
64 * Counters will be displayed as a rate (per second) if their group name starts with "~", otherwise |
ec267141f753
more javadoc and output tweaks for dynamic counters
Lukas Stadler <lukas.stadler@jku.at>
parents:
11874
diff
changeset
|
65 * they will be displayed as a total number. |
14776
07dd21c7d533
revived use of FindBugs annotations
Doug Simon <doug.simon@oracle.com>
parents:
14724
diff
changeset
|
66 * |
11893
ec267141f753
more javadoc and output tweaks for dynamic counters
Lukas Stadler <lukas.stadler@jku.at>
parents:
11874
diff
changeset
|
67 * <h1>Example</h1> In order to create statistics about allocations within the DaCapo pmd benchmark |
ec267141f753
more javadoc and output tweaks for dynamic counters
Lukas Stadler <lukas.stadler@jku.at>
parents:
11874
diff
changeset
|
68 * the following steps are necessary: |
ec267141f753
more javadoc and output tweaks for dynamic counters
Lukas Stadler <lukas.stadler@jku.at>
parents:
11874
diff
changeset
|
69 * <ul> |
14578
d927132f45a4
update comments on BenchmarkCounters (-XX options instead of preprocessor defs)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14163
diff
changeset
|
70 * <li>Set {@code -XX:GraalCounterSize=value}. The actual required value depends on the granularity |
d927132f45a4
update comments on BenchmarkCounters (-XX options instead of preprocessor defs)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14163
diff
changeset
|
71 * of the profiling, 10000 should be enough for most cases.</li> |
d927132f45a4
update comments on BenchmarkCounters (-XX options instead of preprocessor defs)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14163
diff
changeset
|
72 * <li>Also: {@code -XX:+/-GraalCountersExcludeCompiler} specifies whether the numbers generated by |
d927132f45a4
update comments on BenchmarkCounters (-XX options instead of preprocessor defs)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14163
diff
changeset
|
73 * compiler threads should be excluded (default: true).</li> |
11893
ec267141f753
more javadoc and output tweaks for dynamic counters
Lukas Stadler <lukas.stadler@jku.at>
parents:
11874
diff
changeset
|
74 * <li>Start the DaCapo pmd benchmark with |
ec267141f753
more javadoc and output tweaks for dynamic counters
Lukas Stadler <lukas.stadler@jku.at>
parents:
11874
diff
changeset
|
75 * {@code "-G:BenchmarkDynamicCounters=err, starting ====, PASSED in "} and |
ec267141f753
more javadoc and output tweaks for dynamic counters
Lukas Stadler <lukas.stadler@jku.at>
parents:
11874
diff
changeset
|
76 * {@code -G:+ProfileAllocations}.</li> |
ec267141f753
more javadoc and output tweaks for dynamic counters
Lukas Stadler <lukas.stadler@jku.at>
parents:
11874
diff
changeset
|
77 * <li>The numbers will only include allocation from compiled code!</li> |
ec267141f753
more javadoc and output tweaks for dynamic counters
Lukas Stadler <lukas.stadler@jku.at>
parents:
11874
diff
changeset
|
78 * <li>The counters can be further configured by modifying the |
ec267141f753
more javadoc and output tweaks for dynamic counters
Lukas Stadler <lukas.stadler@jku.at>
parents:
11874
diff
changeset
|
79 * {@link NewObjectSnippets#PROFILE_MODE} field.</li> |
ec267141f753
more javadoc and output tweaks for dynamic counters
Lukas Stadler <lukas.stadler@jku.at>
parents:
11874
diff
changeset
|
80 * </ul> |
11874
e0041af765c5
some more javadoc for benchmark counters
Lukas Stadler <lukas.stadler@jku.at>
parents:
11852
diff
changeset
|
81 */ |
11852
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
82 public class BenchmarkCounters { |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
83 |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
84 static class Options { |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
85 |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
86 //@formatter:off |
18674
ecb9d0cedbab
First draft of option classification.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18649
diff
changeset
|
87 @Option(help = "Turn on the benchmark counters, and displays the results on VM shutdown", type = OptionType.Debug) |
11852
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
88 private static final OptionValue<Boolean> GenericDynamicCounters = new OptionValue<>(false); |
18674
ecb9d0cedbab
First draft of option classification.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18649
diff
changeset
|
89 @Option(help = "Turn on the benchmark counters, and displays the results every n milliseconds", type = OptionType.Debug) |
14724
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
90 private static final OptionValue<Integer> TimedDynamicCounters = new OptionValue<>(-1); |
11852
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
91 |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
92 @Option(help = "Turn on the benchmark counters, and listen for specific patterns on System.out/System.err:%n" + |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
93 "Format: (err|out),start pattern,end pattern (~ matches multiple digits)%n" + |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
94 "Examples:%n" + |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
95 " dacapo = 'err, starting =====, PASSED in'%n" + |
18674
ecb9d0cedbab
First draft of option classification.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
18649
diff
changeset
|
96 " specjvm2008 = 'out,Iteration ~ (~s) begins:,Iteration ~ (~s) ends:'", type = OptionType.Debug) |
11852
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
97 private static final OptionValue<String> BenchmarkDynamicCounters = new OptionValue<>(null); |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
98 //@formatter:on |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
99 } |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
100 |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
101 private static final boolean DUMP_STATIC = false; |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
102 |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
103 public static boolean enabled = false; |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
104 |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
105 public static final ConcurrentHashMap<String, Integer> indexes = new ConcurrentHashMap<>(); |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
106 public static final ArrayList<String> groups = new ArrayList<>(); |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
107 public static long[] delta; |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
108 public static final ArrayList<AtomicLong> staticCounters = new ArrayList<>(); |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
109 |
14776
07dd21c7d533
revived use of FindBugs annotations
Doug Simon <doug.simon@oracle.com>
parents:
14724
diff
changeset
|
110 @SuppressFBWarnings(value = "AT_OPERATION_SEQUENCE_ON_CONCURRENT_ABSTRACTION", justification = "concurrent abstraction calls are in synchronized block") |
15353
520ab37fb5b6
show Truffle call target names in BenchmarkCounters
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15261
diff
changeset
|
111 private static int getIndex(DynamicCounterNode counter) { |
11852
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
112 if (!enabled) { |
13796
8cd953e97e2d
rework of benchmark counters: fix size at VM entry, not at build time
Lukas Stadler <lukas.stadler@jku.at>
parents:
12430
diff
changeset
|
113 throw new GraalInternalError("counter nodes shouldn't exist when counters are not enabled: " + counter.getGroup() + ", " + counter.getName()); |
11852
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
114 } |
15353
520ab37fb5b6
show Truffle call target names in BenchmarkCounters
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15261
diff
changeset
|
115 String name; |
11852
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
116 String group = counter.getGroup(); |
15353
520ab37fb5b6
show Truffle call target names in BenchmarkCounters
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15261
diff
changeset
|
117 if (counter.isWithContext()) { |
15368
44dcd95a4bf6
fix NPE in BenchmarkCounters, remove exclusion based on prefix
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15366
diff
changeset
|
118 StructuredGraph graph = counter.graph(); |
16480
10c12d09a8d2
moved format(String format, JavaMethod method) from MetaUtil to be a default method in JavaMethod
Doug Simon <doug.simon@oracle.com>
parents:
16215
diff
changeset
|
119 name = counter.getName() + " @ " + graph.graphId() + ":" + (graph.method() == null ? "" : graph.method().format("%h.%n")); |
15368
44dcd95a4bf6
fix NPE in BenchmarkCounters, remove exclusion based on prefix
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15366
diff
changeset
|
120 if (graph.name != null) { |
44dcd95a4bf6
fix NPE in BenchmarkCounters, remove exclusion based on prefix
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15366
diff
changeset
|
121 name += " (" + graph.name + ")"; |
15353
520ab37fb5b6
show Truffle call target names in BenchmarkCounters
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15261
diff
changeset
|
122 } |
520ab37fb5b6
show Truffle call target names in BenchmarkCounters
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15261
diff
changeset
|
123 name += "#" + group; |
520ab37fb5b6
show Truffle call target names in BenchmarkCounters
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15261
diff
changeset
|
124 |
520ab37fb5b6
show Truffle call target names in BenchmarkCounters
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15261
diff
changeset
|
125 } else { |
520ab37fb5b6
show Truffle call target names in BenchmarkCounters
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15261
diff
changeset
|
126 name = counter.getName() + "#" + group; |
520ab37fb5b6
show Truffle call target names in BenchmarkCounters
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15261
diff
changeset
|
127 } |
11852
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
128 Integer index = indexes.get(name); |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
129 if (index == null) { |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
130 synchronized (BenchmarkCounters.class) { |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
131 index = indexes.get(name); |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
132 if (index == null) { |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
133 index = indexes.size(); |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
134 indexes.put(name, index); |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
135 groups.add(group); |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
136 staticCounters.add(new AtomicLong()); |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
137 } |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
138 } |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
139 } |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
140 assert groups.get(index).equals(group) : "mismatching groups: " + groups.get(index) + " vs. " + group; |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
141 if (counter.getIncrement().isConstant()) { |
18187
9619ba4daf4c
Rename Constant to JavaConstant.
Roland Schatz <roland.schatz@oracle.com>
parents:
17197
diff
changeset
|
142 staticCounters.get(index).addAndGet(counter.getIncrement().asJavaConstant().asLong()); |
11852
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
143 } |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
144 return index; |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
145 } |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
146 |
15353
520ab37fb5b6
show Truffle call target names in BenchmarkCounters
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15261
diff
changeset
|
147 private static synchronized void dump(PrintStream out, double seconds, long[] counters, int maxRows) { |
11893
ec267141f753
more javadoc and output tweaks for dynamic counters
Lukas Stadler <lukas.stadler@jku.at>
parents:
11874
diff
changeset
|
148 if (!groups.isEmpty()) { |
11852
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
149 out.println("====== dynamic counters (" + staticCounters.size() + " in total) ======"); |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
150 for (String group : new TreeSet<>(groups)) { |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
151 if (group != null) { |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
152 if (DUMP_STATIC) { |
14724
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
153 dumpCounters(out, seconds, counters, true, group, maxRows); |
11852
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
154 } |
14724
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
155 dumpCounters(out, seconds, counters, false, group, maxRows); |
11852
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
156 } |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
157 } |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
158 out.println("============================"); |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
159 |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
160 clear(counters); |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
161 } |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
162 } |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
163 |
15353
520ab37fb5b6
show Truffle call target names in BenchmarkCounters
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15261
diff
changeset
|
164 private static synchronized void clear(long[] counters) { |
11852
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
165 delta = counters; |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
166 } |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
167 |
14724
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
168 private static synchronized void dumpCounters(PrintStream out, double seconds, long[] counters, boolean staticCounter, String group, int maxRows) { |
11852
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
169 TreeMap<Long, String> sorted = new TreeMap<>(); |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
170 |
14724
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
171 // collect the numbers |
11852
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
172 long[] array; |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
173 if (staticCounter) { |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
174 array = new long[indexes.size()]; |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
175 for (int i = 0; i < array.length; i++) { |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
176 array[i] = staticCounters.get(i).get(); |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
177 } |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
178 } else { |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
179 array = counters.clone(); |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
180 for (int i = 0; i < array.length; i++) { |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
181 array[i] -= delta[i]; |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
182 } |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
183 } |
14724
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
184 // sort the counters by putting them into a sorted map |
11852
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
185 long sum = 0; |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
186 for (Map.Entry<String, Integer> entry : indexes.entrySet()) { |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
187 int index = entry.getValue(); |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
188 if (groups.get(index).equals(group)) { |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
189 sum += array[index]; |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
190 sorted.put(array[index] * array.length + index, entry.getKey().substring(0, entry.getKey().length() - group.length() - 1)); |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
191 } |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
192 } |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
193 |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
194 if (sum > 0) { |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
195 long cutoff = sorted.size() < 10 ? 1 : Math.max(1, sum / 100); |
14724
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
196 int cnt = sorted.size(); |
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
197 |
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
198 // remove everything below cutoff and keep at most maxRows |
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
199 Iterator<Map.Entry<Long, String>> iter = sorted.entrySet().iterator(); |
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
200 while (iter.hasNext()) { |
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
201 Map.Entry<Long, String> entry = iter.next(); |
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
202 long counter = entry.getKey() / array.length; |
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
203 if (counter < cutoff || cnt > maxRows) { |
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
204 iter.remove(); |
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
205 } |
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
206 cnt--; |
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
207 } |
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
208 |
11852
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
209 if (staticCounter) { |
11893
ec267141f753
more javadoc and output tweaks for dynamic counters
Lukas Stadler <lukas.stadler@jku.at>
parents:
11874
diff
changeset
|
210 out.println("=========== " + group + " (static counters):"); |
11852
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
211 for (Map.Entry<Long, String> entry : sorted.entrySet()) { |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
212 long counter = entry.getKey() / array.length; |
14724
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
213 out.format(Locale.US, "%,19d %3d%% %s\n", counter, percentage(counter, sum), entry.getValue()); |
11852
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
214 } |
14724
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
215 out.format(Locale.US, "%,19d total\n", sum); |
11852
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
216 } else { |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
217 if (group.startsWith("~")) { |
11893
ec267141f753
more javadoc and output tweaks for dynamic counters
Lukas Stadler <lukas.stadler@jku.at>
parents:
11874
diff
changeset
|
218 out.println("=========== " + group + " (dynamic counters), time = " + seconds + " s:"); |
ec267141f753
more javadoc and output tweaks for dynamic counters
Lukas Stadler <lukas.stadler@jku.at>
parents:
11874
diff
changeset
|
219 for (Map.Entry<Long, String> entry : sorted.entrySet()) { |
ec267141f753
more javadoc and output tweaks for dynamic counters
Lukas Stadler <lukas.stadler@jku.at>
parents:
11874
diff
changeset
|
220 long counter = entry.getKey() / array.length; |
14724
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
221 out.format(Locale.US, "%,19d/s %3d%% %s\n", (long) (counter / seconds), percentage(counter, sum), entry.getValue()); |
11893
ec267141f753
more javadoc and output tweaks for dynamic counters
Lukas Stadler <lukas.stadler@jku.at>
parents:
11874
diff
changeset
|
222 } |
14724
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
223 out.format(Locale.US, "%,19d/s total\n", (long) (sum / seconds)); |
11893
ec267141f753
more javadoc and output tweaks for dynamic counters
Lukas Stadler <lukas.stadler@jku.at>
parents:
11874
diff
changeset
|
224 } else { |
ec267141f753
more javadoc and output tweaks for dynamic counters
Lukas Stadler <lukas.stadler@jku.at>
parents:
11874
diff
changeset
|
225 out.println("=========== " + group + " (dynamic counters):"); |
11852
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
226 for (Map.Entry<Long, String> entry : sorted.entrySet()) { |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
227 long counter = entry.getKey() / array.length; |
14724
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
228 out.format(Locale.US, "%,19d %3d%% %s\n", counter, percentage(counter, sum), entry.getValue()); |
11852
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
229 } |
14724
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
230 out.format(Locale.US, "%,19d total\n", sum); |
11852
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
231 } |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
232 } |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
233 } |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
234 } |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
235 |
14724
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
236 private static long percentage(long counter, long sum) { |
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
237 return (counter * 200 + 1) / sum / 2; |
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
238 } |
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
239 |
15353
520ab37fb5b6
show Truffle call target names in BenchmarkCounters
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15261
diff
changeset
|
240 private abstract static class CallbackOutputStream extends OutputStream { |
11852
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
241 |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
242 protected final PrintStream delegate; |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
243 private final byte[][] patterns; |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
244 private final int[] positions; |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
245 |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
246 public CallbackOutputStream(PrintStream delegate, String... patterns) { |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
247 this.delegate = delegate; |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
248 this.positions = new int[patterns.length]; |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
249 this.patterns = new byte[patterns.length][]; |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
250 for (int i = 0; i < patterns.length; i++) { |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
251 this.patterns[i] = patterns[i].getBytes(); |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
252 } |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
253 } |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
254 |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
255 protected abstract void patternFound(int index); |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
256 |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
257 @Override |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
258 public void write(int b) throws IOException { |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
259 try { |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
260 delegate.write(b); |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
261 for (int i = 0; i < patterns.length; i++) { |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
262 int j = positions[i]; |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
263 byte[] cs = patterns[i]; |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
264 byte patternChar = cs[j]; |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
265 if (patternChar == '~' && Character.isDigit(b)) { |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
266 // nothing to do... |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
267 } else { |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
268 if (patternChar == '~') { |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
269 patternChar = cs[++positions[i]]; |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
270 } |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
271 if (b == patternChar) { |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
272 positions[i]++; |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
273 } else { |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
274 positions[i] = 0; |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
275 } |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
276 } |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
277 if (positions[i] == patterns[i].length) { |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
278 positions[i] = 0; |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
279 patternFound(i); |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
280 } |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
281 } |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
282 } catch (RuntimeException e) { |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
283 e.printStackTrace(delegate); |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
284 throw e; |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
285 } |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
286 } |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
287 } |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
288 |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
289 public static void initialize(final CompilerToVM compilerToVM) { |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
290 final class BenchmarkCountersOutputStream extends CallbackOutputStream { |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
291 |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
292 private long startTime; |
15366
a2f4ffc18d9d
more fixes in BenchmarkCounters
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15353
diff
changeset
|
293 private boolean running; |
11852
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
294 private boolean waitingForEnd; |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
295 |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
296 private BenchmarkCountersOutputStream(PrintStream delegate, String start, String end) { |
15366
a2f4ffc18d9d
more fixes in BenchmarkCounters
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15353
diff
changeset
|
297 super(delegate, new String[]{"\n", end, start}); |
11852
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
298 } |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
299 |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
300 @Override |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
301 protected void patternFound(int index) { |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
302 switch (index) { |
15366
a2f4ffc18d9d
more fixes in BenchmarkCounters
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15353
diff
changeset
|
303 case 2: |
11852
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
304 startTime = System.nanoTime(); |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
305 BenchmarkCounters.clear(compilerToVM.collectCounters()); |
15366
a2f4ffc18d9d
more fixes in BenchmarkCounters
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15353
diff
changeset
|
306 running = true; |
11852
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
307 break; |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
308 case 1: |
15366
a2f4ffc18d9d
more fixes in BenchmarkCounters
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15353
diff
changeset
|
309 if (running) { |
a2f4ffc18d9d
more fixes in BenchmarkCounters
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15353
diff
changeset
|
310 waitingForEnd = true; |
a2f4ffc18d9d
more fixes in BenchmarkCounters
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15353
diff
changeset
|
311 } |
11852
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
312 break; |
15366
a2f4ffc18d9d
more fixes in BenchmarkCounters
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15353
diff
changeset
|
313 case 0: |
11852
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
314 if (waitingForEnd) { |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
315 waitingForEnd = false; |
15366
a2f4ffc18d9d
more fixes in BenchmarkCounters
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15353
diff
changeset
|
316 running = false; |
14724
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
317 BenchmarkCounters.dump(delegate, (System.nanoTime() - startTime) / 1000000000d, compilerToVM.collectCounters(), 100); |
11852
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
318 } |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
319 break; |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
320 } |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
321 } |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
322 } |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
323 |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
324 if (Options.BenchmarkDynamicCounters.getValue() != null) { |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
325 String[] arguments = Options.BenchmarkDynamicCounters.getValue().split(","); |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
326 if (arguments.length == 0 || (arguments.length % 3) != 0) { |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
327 throw new GraalInternalError("invalid arguments to BenchmarkDynamicCounters: (err|out),start,end,(err|out),start,end,... (~ matches multiple digits)"); |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
328 } |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
329 for (int i = 0; i < arguments.length; i += 3) { |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
330 if (arguments[i].equals("err")) { |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
331 System.setErr(new PrintStream(new BenchmarkCountersOutputStream(System.err, arguments[i + 1], arguments[i + 2]))); |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
332 } else if (arguments[i].equals("out")) { |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
333 System.setOut(new PrintStream(new BenchmarkCountersOutputStream(System.out, arguments[i + 1], arguments[i + 2]))); |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
334 } else { |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
335 throw new GraalInternalError("invalid arguments to BenchmarkDynamicCounters: err|out"); |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
336 } |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
337 } |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
338 enabled = true; |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
339 } |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
340 if (Options.GenericDynamicCounters.getValue()) { |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
341 enabled = true; |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
342 } |
14724
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
343 if (Options.TimedDynamicCounters.getValue() > 0) { |
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
344 Thread thread = new Thread() { |
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
345 long lastTime = System.nanoTime(); |
16578
9793d86c21c5
use TTY in BenchmarkCounters
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16480
diff
changeset
|
346 PrintStream out = TTY.cachedOut; |
14724
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
347 |
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
348 @Override |
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
349 public void run() { |
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
350 while (true) { |
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
351 try { |
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
352 Thread.sleep(Options.TimedDynamicCounters.getValue()); |
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
353 } catch (InterruptedException e) { |
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
354 } |
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
355 long time = System.nanoTime(); |
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
356 dump(out, (time - lastTime) / 1000000000d, compilerToVM.collectCounters(), 10); |
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
357 lastTime = time; |
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
358 } |
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
359 } |
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
360 }; |
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
361 thread.setDaemon(true); |
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
362 thread.setPriority(Thread.MAX_PRIORITY); |
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
363 thread.start(); |
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
364 enabled = true; |
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
365 } |
c3ec1e4494b8
update BenchmarkCounters (add TimedDynamicCounters, fix -XX:+GraalCountersExcludeCompiler)
Lukas Stadler <lukas.stadler@oracle.com>
parents:
14578
diff
changeset
|
366 if (enabled) { |
11852
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
367 clear(compilerToVM.collectCounters()); |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
368 } |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
369 } |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
370 |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
371 public static void shutdown(CompilerToVM compilerToVM, long compilerStartTime) { |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
372 if (Options.GenericDynamicCounters.getValue()) { |
16578
9793d86c21c5
use TTY in BenchmarkCounters
Lukas Stadler <lukas.stadler@oracle.com>
parents:
16480
diff
changeset
|
373 dump(TTY.cachedOut, (System.nanoTime() - compilerStartTime) / 1000000000d, compilerToVM.collectCounters(), 100); |
11852
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
374 } |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
375 } |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
376 |
18698
abd10b6ef99d
Benchmark counters should have their own LocationIdentity
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18674
diff
changeset
|
377 private static final LocationIdentity COUNTER_LOCATION = NamedLocationIdentity.mutable("COUNTER_LOCATION"); |
abd10b6ef99d
Benchmark counters should have their own LocationIdentity
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
18674
diff
changeset
|
378 |
12430
c0e660b07e02
introduced HotSpotRegistersProvider interface
Doug Simon <doug.simon@oracle.com>
parents:
12429
diff
changeset
|
379 public static void lower(DynamicCounterNode counter, HotSpotRegistersProvider registers, HotSpotVMConfig config, Kind wordKind) { |
11852
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
380 StructuredGraph graph = counter.graph(); |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
381 |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18698
diff
changeset
|
382 ReadRegisterNode thread = graph.add(new ReadRegisterNode(registers.getThreadRegister(), wordKind, true, false)); |
11852
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
383 |
15368
44dcd95a4bf6
fix NPE in BenchmarkCounters, remove exclusion based on prefix
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15366
diff
changeset
|
384 int index = BenchmarkCounters.getIndex(counter); |
44dcd95a4bf6
fix NPE in BenchmarkCounters, remove exclusion based on prefix
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15366
diff
changeset
|
385 if (index >= config.graalCountersSize) { |
44dcd95a4bf6
fix NPE in BenchmarkCounters, remove exclusion based on prefix
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15366
diff
changeset
|
386 throw new GraalInternalError("too many counters, reduce number of counters or increase -XX:GraalCounterSize=... (current value: " + config.graalCountersSize + ")"); |
44dcd95a4bf6
fix NPE in BenchmarkCounters, remove exclusion based on prefix
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15366
diff
changeset
|
387 } |
18845
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18698
diff
changeset
|
388 ConstantLocationNode arrayLocation = graph.unique(new ConstantLocationNode(COUNTER_LOCATION, config.graalCountersThreadOffset)); |
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18698
diff
changeset
|
389 ReadNode readArray = graph.add(new ReadNode(thread, arrayLocation, StampFactory.forKind(wordKind), BarrierType.NONE)); |
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18698
diff
changeset
|
390 ConstantLocationNode location = graph.unique(new ConstantLocationNode(COUNTER_LOCATION, Unsafe.ARRAY_LONG_INDEX_SCALE * index)); |
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18698
diff
changeset
|
391 ReadNode read = graph.add(new ReadNode(readArray, location, StampFactory.forKind(Kind.Long), BarrierType.NONE)); |
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18698
diff
changeset
|
392 AddNode add = graph.unique(new AddNode(read, counter.getIncrement())); |
f57d86eb036f
removed Node factory methods
Doug Simon <doug.simon@oracle.com>
parents:
18698
diff
changeset
|
393 WriteNode write = graph.add(new WriteNode(readArray, add, location, BarrierType.NONE)); |
11852
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
394 |
15368
44dcd95a4bf6
fix NPE in BenchmarkCounters, remove exclusion based on prefix
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15366
diff
changeset
|
395 graph.addBeforeFixed(counter, thread); |
44dcd95a4bf6
fix NPE in BenchmarkCounters, remove exclusion based on prefix
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15366
diff
changeset
|
396 graph.addBeforeFixed(counter, readArray); |
44dcd95a4bf6
fix NPE in BenchmarkCounters, remove exclusion based on prefix
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15366
diff
changeset
|
397 graph.addBeforeFixed(counter, read); |
44dcd95a4bf6
fix NPE in BenchmarkCounters, remove exclusion based on prefix
Lukas Stadler <lukas.stadler@oracle.com>
parents:
15366
diff
changeset
|
398 graph.addBeforeFixed(counter, write); |
11852
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
399 graph.removeFixed(counter); |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
400 } |
d7964e96b0b0
move benchmark counters into separate class and make them correct for multithreaded applications
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
401 } |