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