58 * infrastructure is enabled by specifying either the GenericDynamicCounters or
59 * BenchmarkDynamicCounters option.
60 * <p>
61 *
62 * The counters are kept in a special area allocated for each native JavaThread object, and the
63 * number of counters is configured using {@code -XX:JVMCICounterSize=value}.
64 * {@code -XX:+/-JVMCICountersExcludeCompiler} configures whether to exclude compiler threads
65 * (defaults to true).
66 *
67 * The subsystems that use the logging need to have their own options to turn on the counters, and
68 * insert DynamicCounterNodes when they're enabled.
69 *
70 * Counters will be displayed as a rate (per second) if their group name starts with "~", otherwise
71 * they will be displayed as a total number.
72 *
73 * See <a href="BenchmarkDynamicCountersHelp.txt">here</a> for a detailed example of how to use
74 * benchmark counters.
75 */
76 public class BenchmarkCounters {
77
78 static class Options {
79
80 //@formatter:off
81 @Option(help = "Turn on the benchmark counters, and displays the results on VM shutdown", type = OptionType.Debug)
82 public static final OptionKey<Boolean> GenericDynamicCounters = new OptionKey<>(false);
83 @Option(help = "Turn on the benchmark counters, and displays the results every n milliseconds", type = OptionType.Debug)
84 public static final OptionKey<Integer> TimedDynamicCounters = new OptionKey<>(-1);
85
86 @Option(help = "file:doc-files/BenchmarkDynamicCountersHelp.txt", type = OptionType.Debug)
87 public static final OptionKey<String> BenchmarkDynamicCounters = new OptionKey<>(null);
88 @Option(help = "Use grouping separators for number printing", type = OptionType.Debug)
89 public static final OptionKey<Boolean> DynamicCountersPrintGroupSeparator = new OptionKey<>(true);
90 @Option(help = "File to which benchmark counters are dumped. A CSV format is used if the file ends with .csv " +
91 "otherwise a more human readable format is used. The fields in the CSV format are: " +
92 "category, group, name, value", type = OptionType.Debug)
93 public static final OptionKey<String> BenchmarkCountersFile = new OptionKey<>(null);
94 @Option(help = "Dump dynamic counters", type = OptionType.Debug)
95 public static final OptionKey<Boolean> BenchmarkCountersDumpDynamic = new OptionKey<>(true);
96 @Option(help = "Dump static counters", type = OptionType.Debug)
97 public static final OptionKey<Boolean> BenchmarkCountersDumpStatic = new OptionKey<>(false);
98 //@formatter:on
99 }
100
101 public static boolean enabled = false;
102
103 private static class Counter {
104 public final int index;
105 public final String group;
106 public final AtomicLong staticCounters;
107
108 Counter(int index, String group, AtomicLong staticCounters) {
109 this.index = index;
110 this.group = group;
111 this.staticCounters = staticCounters;
112 }
113 }
114
115 public static final ConcurrentHashMap<String, Counter> counterMap = new ConcurrentHashMap<>();
116 public static long[] delta;
117
|
58 * infrastructure is enabled by specifying either the GenericDynamicCounters or
59 * BenchmarkDynamicCounters option.
60 * <p>
61 *
62 * The counters are kept in a special area allocated for each native JavaThread object, and the
63 * number of counters is configured using {@code -XX:JVMCICounterSize=value}.
64 * {@code -XX:+/-JVMCICountersExcludeCompiler} configures whether to exclude compiler threads
65 * (defaults to true).
66 *
67 * The subsystems that use the logging need to have their own options to turn on the counters, and
68 * insert DynamicCounterNodes when they're enabled.
69 *
70 * Counters will be displayed as a rate (per second) if their group name starts with "~", otherwise
71 * they will be displayed as a total number.
72 *
73 * See <a href="BenchmarkDynamicCountersHelp.txt">here</a> for a detailed example of how to use
74 * benchmark counters.
75 */
76 public class BenchmarkCounters {
77
78 public static class Options {
79
80 //@formatter:off
81 @Option(help = "Turn on the benchmark counters, and displays the results on VM shutdown", type = OptionType.Debug)
82 public static final OptionKey<Boolean> GenericDynamicCounters = new OptionKey<>(false);
83 @Option(help = "Turn on the benchmark counters, and displays the results every n milliseconds", type = OptionType.Debug)
84 public static final OptionKey<Integer> TimedDynamicCounters = new OptionKey<>(-1);
85
86 @Option(help = "file:doc-files/BenchmarkDynamicCountersHelp.txt", type = OptionType.Debug)
87 public static final OptionKey<String> BenchmarkDynamicCounters = new OptionKey<>(null);
88 @Option(help = "Use grouping separators for number printing", type = OptionType.Debug)
89 public static final OptionKey<Boolean> DynamicCountersPrintGroupSeparator = new OptionKey<>(true);
90 @Option(help = "File to which benchmark counters are dumped. A CSV format is used if the file ends with .csv " +
91 "otherwise a more human readable format is used. The fields in the CSV format are: " +
92 "category, group, name, value", type = OptionType.Debug)
93 public static final OptionKey<String> BenchmarkCountersFile = new OptionKey<>(null);
94 @Option(help = "Dump dynamic counters", type = OptionType.Debug)
95 public static final OptionKey<Boolean> BenchmarkCountersDumpDynamic = new OptionKey<>(true);
96 @Option(help = "Dump static counters", type = OptionType.Debug)
97 public static final OptionKey<Boolean> BenchmarkCountersDumpStatic = new OptionKey<>(false);
98 @Option(help = "file:doc-files/AbortOnBenchmarkCounterOverflowHelp.txt", type = OptionType.Debug)
99 public static final OptionKey<Boolean> AbortOnBenchmarkCounterOverflow = new OptionKey<>(false);
100 //@formatter:on
101 }
102
103 public static boolean enabled = false;
104
105 private static class Counter {
106 public final int index;
107 public final String group;
108 public final AtomicLong staticCounters;
109
110 Counter(int index, String group, AtomicLong staticCounters) {
111 this.index = index;
112 this.group = group;
113 this.staticCounters = staticCounters;
114 }
115 }
116
117 public static final ConcurrentHashMap<String, Counter> counterMap = new ConcurrentHashMap<>();
118 public static long[] delta;
119
|