Mercurial > hg > truffle
annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationStatistics.java @ 7553:d34f5456475f
applied eclipseformat
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Thu, 24 Jan 2013 17:06:00 +0100 |
parents | a200d10867f1 |
children | 08e06d4a9e73 |
rev | line source |
---|---|
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
1 /* |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
4 * |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
8 * |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
13 * accompanied this code). |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
14 * |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
18 * |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
21 * questions. |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
22 */ |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5541
diff
changeset
|
23 package com.oracle.graal.hotspot; |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
24 |
7549
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
25 import static com.oracle.graal.graph.UnsafeAccess.*; |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
26 import static java.lang.Thread.*; |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
27 |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
28 import java.io.*; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
29 import java.lang.annotation.*; |
7549
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
30 import java.lang.management.*; |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
31 import java.lang.reflect.*; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
32 import java.util.*; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
33 import java.util.concurrent.*; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
34 |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5541
diff
changeset
|
35 import com.oracle.graal.api.code.*; |
5507
dc71b06d09f8
Moving classes from cri.ri to api.meta.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5176
diff
changeset
|
36 import com.oracle.graal.api.meta.*; |
7549
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
37 import com.oracle.graal.graph.*; |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5719
diff
changeset
|
38 import com.oracle.graal.hotspot.meta.*; |
7549
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
39 import com.sun.management.ThreadMXBean; |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
40 |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
41 @SuppressWarnings("unused") |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5541
diff
changeset
|
42 public final class CompilationStatistics { |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
43 |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
44 private static final long RESOLUTION = 100000000; |
7549
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
45 private static final boolean ENABLED = Boolean.getBoolean("graal.comp.stats"); |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
46 |
7549
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
47 private static final CompilationStatistics DUMMY = new CompilationStatistics(null, false); |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
48 |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5541
diff
changeset
|
49 private static ConcurrentLinkedDeque<CompilationStatistics> list = new ConcurrentLinkedDeque<>(); |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
50 |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5541
diff
changeset
|
51 private static final ThreadLocal<Deque<CompilationStatistics>> current = new ThreadLocal<Deque<CompilationStatistics>>() { |
7553 | 52 |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
53 @Override |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5541
diff
changeset
|
54 protected Deque<CompilationStatistics> initialValue() { |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
55 return new ArrayDeque<>(); |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
56 } |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
57 }; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
58 |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
59 @Retention(RetentionPolicy.RUNTIME) |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
60 @Target(ElementType.FIELD) |
7549
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
61 private static @interface NotReported { |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
62 } |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
63 |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
64 @Retention(RetentionPolicy.RUNTIME) |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
65 @Target(ElementType.FIELD) |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
66 private static @interface TimeValue { |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
67 } |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
68 |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
69 private static long zeroTime = System.nanoTime(); |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
70 |
7549
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
71 private static long getThreadAllocatedBytes() { |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
72 ThreadMXBean thread = (ThreadMXBean) ManagementFactory.getThreadMXBean(); |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
73 return thread.getThreadAllocatedBytes(currentThread().getId()); |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
74 } |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
75 |
7553 | 76 @NotReported private final long startTime; |
77 @NotReported private long threadAllocatedBytesStart; | |
78 @NotReported private int startInvCount; | |
79 @NotReported private int endInvCount; | |
7549
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
80 |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
81 private int bytecodeCount; |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
82 private int codeSize; |
7553 | 83 @TimeValue private long duration; |
7549
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
84 private long memoryUsed; |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
85 private final boolean osr; |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
86 private final String holder; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
87 private final String name; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
88 private final String signature; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
89 |
7549
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
90 private CompilationStatistics(HotSpotResolvedJavaMethod method, boolean osr) { |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
91 this.osr = osr; |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
92 if (method != null) { |
7549
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
93 holder = method.getDeclaringClass().getName(); |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5719
diff
changeset
|
94 name = method.getName(); |
7549
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
95 signature = method.getSignature().getMethodDescriptor(); |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
96 startTime = System.nanoTime(); |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
97 startInvCount = method.invocationCount(); |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5719
diff
changeset
|
98 bytecodeCount = method.getCodeSize(); |
7549
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
99 threadAllocatedBytesStart = getThreadAllocatedBytes(); |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
100 } else { |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
101 holder = ""; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
102 name = ""; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
103 signature = ""; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
104 startTime = 0; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
105 } |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
106 } |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
107 |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5719
diff
changeset
|
108 public void finish(HotSpotResolvedJavaMethod method) { |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
109 if (ENABLED) { |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
110 duration = System.nanoTime() - startTime; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
111 endInvCount = method.invocationCount(); |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
5719
diff
changeset
|
112 codeSize = method.getCompiledCodeSize(); |
7549
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
113 memoryUsed = getThreadAllocatedBytes() - threadAllocatedBytesStart; |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
114 if (current.get().getLast() != this) { |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
115 throw new RuntimeException("mismatch in finish()"); |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
116 } |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
117 current.get().removeLast(); |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
118 } |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
119 } |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
120 |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5541
diff
changeset
|
121 public static CompilationStatistics current() { |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
122 return current.get().isEmpty() ? null : current.get().getLast(); |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
123 } |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
124 |
7549
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
125 public static CompilationStatistics create(HotSpotResolvedJavaMethod method, boolean isOSR) { |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
126 if (ENABLED) { |
7549
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
127 CompilationStatistics stats = new CompilationStatistics(method, isOSR); |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
128 list.add(stats); |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
129 current.get().addLast(stats); |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
130 return stats; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
131 } else { |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
132 return DUMMY; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
133 } |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
134 } |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
135 |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
136 @SuppressWarnings("deprecation") |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
137 public static void clear(String dumpName) { |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
138 if (!ENABLED) { |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
139 return; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
140 } |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
141 try { |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5541
diff
changeset
|
142 ConcurrentLinkedDeque<CompilationStatistics> snapshot = list; |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
143 long snapshotZeroTime = zeroTime; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
144 |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
145 list = new ConcurrentLinkedDeque<>(); |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
146 zeroTime = System.nanoTime(); |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
147 |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
148 Date now = new Date(); |
7547
f7ca24d268c4
changed format of files generated by CompilationStatistics to avoid spaces
Doug Simon <doug.simon@oracle.com>
parents:
6539
diff
changeset
|
149 String dateString = (now.getYear() + 1900) + "-" + (now.getMonth() + 1) + "-" + now.getDate() + "-" + now.getHours() + "" + now.getMinutes(); |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
150 |
7549
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
151 dumpCompilations(snapshot, dumpName, dateString); |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
152 |
7549
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
153 try (FileOutputStream fos = new FileOutputStream("timeline_" + dateString + "_" + dumpName + ".csv", true); PrintStream out = new PrintStream(fos)) { |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
154 |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
155 long[] timeSpent = new long[10000]; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
156 int maxTick = 0; |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5541
diff
changeset
|
157 for (CompilationStatistics stats : snapshot) { |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
158 long start = stats.startTime - snapshotZeroTime; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
159 long duration = stats.duration; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
160 if (start < 0) { |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
161 duration -= -start; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
162 start = 0; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
163 } |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
164 |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
165 int tick = (int) (start / RESOLUTION); |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
166 long timeLeft = RESOLUTION - (start % RESOLUTION); |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
167 |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
168 while (tick < timeSpent.length && duration > 0) { |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
169 if (tick > maxTick) { |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
170 maxTick = tick; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
171 } |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
172 timeSpent[tick] += Math.min(timeLeft, duration); |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
173 duration -= timeLeft; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
174 tick++; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
175 timeLeft = RESOLUTION; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
176 } |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
177 } |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
178 String timelineName = System.getProperty("stats.timeline.name"); |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
179 if (timelineName != null && !timelineName.isEmpty()) { |
7549
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
180 out.print(timelineName + "\t"); |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
181 } |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
182 for (int i = 0; i <= maxTick; i++) { |
7549
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
183 out.print((timeSpent[i] * 100 / RESOLUTION) + "\t"); |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
184 } |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
185 out.println(); |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
186 } |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
187 } catch (Exception e) { |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
188 throw new RuntimeException(e); |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
189 } |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
190 } |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
191 |
7549
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
192 protected static void dumpCompilations(ConcurrentLinkedDeque<CompilationStatistics> snapshot, String dumpName, String dateString) throws IllegalAccessException, FileNotFoundException { |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
193 String fileName = "compilations_" + dateString + "_" + dumpName + ".csv"; |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
194 try (PrintStream out = new PrintStream(fileName)) { |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
195 // output the list of all compilations |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
196 |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
197 Field[] declaredFields = CompilationStatistics.class.getDeclaredFields(); |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
198 ArrayList<Field> fields = new ArrayList<>(); |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
199 for (Field field : declaredFields) { |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
200 if (!Modifier.isStatic(field.getModifiers()) && !field.isAnnotationPresent(NotReported.class)) { |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
201 fields.add(field); |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
202 } |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
203 } |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
204 for (Field field : fields) { |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
205 out.print(field.getName() + "\t"); |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
206 } |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
207 out.println(); |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
208 for (CompilationStatistics stats : snapshot) { |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
209 for (Field field : fields) { |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
210 if (field.isAnnotationPresent(TimeValue.class)) { |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
211 double value = field.getLong(stats) / 1000000d; |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
212 out.print(String.format(Locale.ENGLISH, "%.3f", value) + "\t"); |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
213 } else { |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
214 out.print(field.get(stats) + "\t"); |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
215 } |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
216 } |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
217 out.println(); |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
218 } |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
219 } |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
220 } |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
221 } |