Mercurial > hg > graal-jvmci-8
annotate graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationStatistics.java @ 14991:64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Sun, 06 Apr 2014 17:46:24 +0200 |
parents | 4877b0cb446f |
children | 3c3cd36a3836 |
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 java.lang.Thread.*; |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
26 |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
27 import java.io.*; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
28 import java.lang.annotation.*; |
7549
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
29 import java.lang.management.*; |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
30 import java.lang.reflect.*; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
31 import java.util.*; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
32 import java.util.concurrent.*; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
33 |
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
|
34 import com.oracle.graal.hotspot.meta.*; |
7549
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
35 import com.sun.management.ThreadMXBean; |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
36 |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
37 @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
|
38 public final class CompilationStatistics { |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
39 |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
40 private static final long RESOLUTION = 100000000; |
7549
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
41 private static final boolean ENABLED = Boolean.getBoolean("graal.comp.stats"); |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
42 |
7549
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
43 private static final CompilationStatistics DUMMY = new CompilationStatistics(null, false); |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
44 |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5541
diff
changeset
|
45 private static ConcurrentLinkedDeque<CompilationStatistics> list = new ConcurrentLinkedDeque<>(); |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
46 |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5541
diff
changeset
|
47 private static final ThreadLocal<Deque<CompilationStatistics>> current = new ThreadLocal<Deque<CompilationStatistics>>() { |
7553 | 48 |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
49 @Override |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5541
diff
changeset
|
50 protected Deque<CompilationStatistics> initialValue() { |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
51 return new ArrayDeque<>(); |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
52 } |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
53 }; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
54 |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
55 @Retention(RetentionPolicy.RUNTIME) |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
56 @Target(ElementType.FIELD) |
7549
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
57 private static @interface NotReported { |
5176
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 |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
60 @Retention(RetentionPolicy.RUNTIME) |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
61 @Target(ElementType.FIELD) |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
62 private static @interface TimeValue { |
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 |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
65 private static long zeroTime = System.nanoTime(); |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
66 |
7549
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
67 private static long getThreadAllocatedBytes() { |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
68 ThreadMXBean thread = (ThreadMXBean) ManagementFactory.getThreadMXBean(); |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
69 return thread.getThreadAllocatedBytes(currentThread().getId()); |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
70 } |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
71 |
7553 | 72 @NotReported private final long startTime; |
73 @NotReported private long threadAllocatedBytesStart; | |
7549
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 private int bytecodeCount; |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
76 private int codeSize; |
7553 | 77 @TimeValue private long duration; |
7549
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
78 private long memoryUsed; |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
79 private final boolean osr; |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
80 private final String holder; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
81 private final String name; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
82 private final String signature; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
83 |
7549
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
84 private CompilationStatistics(HotSpotResolvedJavaMethod method, boolean osr) { |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
85 this.osr = osr; |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
86 if (method != null) { |
7549
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
87 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
|
88 name = method.getName(); |
7549
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
89 signature = method.getSignature().getMethodDescriptor(); |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
90 startTime = System.nanoTime(); |
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
|
91 bytecodeCount = method.getCodeSize(); |
7549
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
92 threadAllocatedBytesStart = getThreadAllocatedBytes(); |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
93 } else { |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
94 holder = ""; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
95 name = ""; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
96 signature = ""; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
97 startTime = 0; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
98 } |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
99 } |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
100 |
14545
4877b0cb446f
removed ResolvedJavaMethod.getCompiledCodeSize()
Doug Simon <doug.simon@oracle.com>
parents:
10639
diff
changeset
|
101 public void finish(HotSpotResolvedJavaMethod method, HotSpotInstalledCode code) { |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
102 if (ENABLED) { |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
103 duration = System.nanoTime() - startTime; |
14545
4877b0cb446f
removed ResolvedJavaMethod.getCompiledCodeSize()
Doug Simon <doug.simon@oracle.com>
parents:
10639
diff
changeset
|
104 codeSize = (int) code.getCodeSize(); |
7549
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
105 memoryUsed = getThreadAllocatedBytes() - threadAllocatedBytesStart; |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
106 if (current.get().getLast() != this) { |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
107 throw new RuntimeException("mismatch in finish()"); |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
108 } |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
109 current.get().removeLast(); |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
110 } |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
111 } |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
112 |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5541
diff
changeset
|
113 public static CompilationStatistics current() { |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
114 return current.get().isEmpty() ? null : current.get().getLast(); |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
115 } |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
116 |
7549
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
117 public static CompilationStatistics create(HotSpotResolvedJavaMethod method, boolean isOSR) { |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
118 if (ENABLED) { |
7549
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
119 CompilationStatistics stats = new CompilationStatistics(method, isOSR); |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
120 list.add(stats); |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
121 current.get().addLast(stats); |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
122 return stats; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
123 } else { |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
124 return DUMMY; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
125 } |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
126 } |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
127 |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
128 @SuppressWarnings("deprecation") |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
129 public static void clear(String dumpName) { |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
130 if (!ENABLED) { |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
131 return; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
132 } |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
133 try { |
5547
b6617d13ea44
Dropping Ci* prefixes. Some additional renamings in the api.code interface.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5541
diff
changeset
|
134 ConcurrentLinkedDeque<CompilationStatistics> snapshot = list; |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
135 long snapshotZeroTime = zeroTime; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
136 |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
137 list = new ConcurrentLinkedDeque<>(); |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
138 zeroTime = System.nanoTime(); |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
139 |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
140 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
|
141 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
|
142 |
7549
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
143 dumpCompilations(snapshot, dumpName, dateString); |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
144 |
7549
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
145 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
|
146 |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
147 long[] timeSpent = new long[10000]; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
148 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
|
149 for (CompilationStatistics stats : snapshot) { |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
150 long start = stats.startTime - snapshotZeroTime; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
151 long duration = stats.duration; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
152 if (start < 0) { |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
153 duration -= -start; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
154 start = 0; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
155 } |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
156 |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
157 int tick = (int) (start / RESOLUTION); |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
158 long timeLeft = RESOLUTION - (start % RESOLUTION); |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
159 |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
160 while (tick < timeSpent.length && duration > 0) { |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
161 if (tick > maxTick) { |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
162 maxTick = tick; |
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 timeSpent[tick] += Math.min(timeLeft, duration); |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
165 duration -= timeLeft; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
166 tick++; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
167 timeLeft = RESOLUTION; |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
168 } |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
169 } |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
170 String timelineName = System.getProperty("stats.timeline.name"); |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
171 if (timelineName != null && !timelineName.isEmpty()) { |
7549
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
172 out.print(timelineName + "\t"); |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
173 } |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
174 for (int i = 0; i <= maxTick; i++) { |
7549
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
175 out.print((timeSpent[i] * 100 / RESOLUTION) + "\t"); |
5176
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 out.println(); |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
178 } |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
179 } catch (Exception e) { |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
180 throw new RuntimeException(e); |
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 } |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
183 |
7549
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
184 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
|
185 String fileName = "compilations_" + dateString + "_" + dumpName + ".csv"; |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
186 try (PrintStream out = new PrintStream(fileName)) { |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
187 // output the list of all compilations |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
188 |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
189 Field[] declaredFields = CompilationStatistics.class.getDeclaredFields(); |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
190 ArrayList<Field> fields = new ArrayList<>(); |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
191 for (Field field : declaredFields) { |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
192 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
|
193 fields.add(field); |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
194 } |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
195 } |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
196 for (Field field : fields) { |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
197 out.print(field.getName() + "\t"); |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
198 } |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
199 out.println(); |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
200 for (CompilationStatistics stats : snapshot) { |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
201 for (Field field : fields) { |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
202 if (field.isAnnotationPresent(TimeValue.class)) { |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
203 double value = field.getLong(stats) / 1000000d; |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
204 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
|
205 } else { |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
206 out.print(field.get(stats) + "\t"); |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
207 } |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
208 } |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
209 out.println(); |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
210 } |
5512fae3683b
added memory usage to CompilationStatistics
Doug Simon <doug.simon@oracle.com>
parents:
7547
diff
changeset
|
211 } |
5176
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
212 } |
af59b4dfc9e4
compilation queue changes:
Lukas Stadler <lukas.stadler@jku.at>
parents:
diff
changeset
|
213 } |