annotate agent/test/jdi/sagclient.java @ 20543:e7d0505c8a30

8059758: Footprint regressions with JDK-8038423 Summary: Changes in JDK-8038423 always initialize (zero out) virtual memory used for auxiliary data structures. This causes a footprint regression for G1 in startup benchmarks. This is because they do not touch that memory at all, so the operating system does not actually commit these pages. The fix is to, if the initialization value of the data structures matches the default value of just committed memory (=0), do not do anything. Reviewed-by: jwilhelm, brutisso
author tschatzl
date Fri, 10 Oct 2014 15:51:58 +0200
parents c18cbe5936b8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
2 * Copyright (c) 2002, 2004, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 import com.sun.jdi.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
26 import com.sun.jdi.connect.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28 import java.util.Map;
a61af66fc99e Initial load
duke
parents:
diff changeset
29 import java.util.List;
a61af66fc99e Initial load
duke
parents:
diff changeset
30 import java.util.Iterator;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 import java.io.IOException;
a61af66fc99e Initial load
duke
parents:
diff changeset
32
a61af66fc99e Initial load
duke
parents:
diff changeset
33 public class sagclient {
a61af66fc99e Initial load
duke
parents:
diff changeset
34 static AttachingConnector myCoreConn;
a61af66fc99e Initial load
duke
parents:
diff changeset
35 static AttachingConnector myPIDConn;
a61af66fc99e Initial load
duke
parents:
diff changeset
36 static AttachingConnector myDbgSvrConn;
a61af66fc99e Initial load
duke
parents:
diff changeset
37 static VirtualMachine vm;
a61af66fc99e Initial load
duke
parents:
diff changeset
38 static VirtualMachineManager vmmgr;
a61af66fc99e Initial load
duke
parents:
diff changeset
39
a61af66fc99e Initial load
duke
parents:
diff changeset
40 public static void println(String msg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
41 System.out.println("jj: " + msg);
a61af66fc99e Initial load
duke
parents:
diff changeset
42 }
a61af66fc99e Initial load
duke
parents:
diff changeset
43
a61af66fc99e Initial load
duke
parents:
diff changeset
44
a61af66fc99e Initial load
duke
parents:
diff changeset
45 public static void main(String args[]) {
a61af66fc99e Initial load
duke
parents:
diff changeset
46 vmmgr = Bootstrap.virtualMachineManager();
a61af66fc99e Initial load
duke
parents:
diff changeset
47 List attachingConnectors = vmmgr.attachingConnectors();
a61af66fc99e Initial load
duke
parents:
diff changeset
48 if (attachingConnectors.isEmpty()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
49 System.err.println( "ERROR: No attaching connectors");
a61af66fc99e Initial load
duke
parents:
diff changeset
50 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
51 }
a61af66fc99e Initial load
duke
parents:
diff changeset
52 Iterator myIt = attachingConnectors.iterator();
a61af66fc99e Initial load
duke
parents:
diff changeset
53 while (myIt.hasNext()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
54 AttachingConnector tmpCon = (AttachingConnector)myIt.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
55 if (tmpCon.name().equals(
a61af66fc99e Initial load
duke
parents:
diff changeset
56 "sun.jvm.hotspot.jdi.SACoreAttachingConnector")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
57 myCoreConn = tmpCon;
a61af66fc99e Initial load
duke
parents:
diff changeset
58 } else if (tmpCon.name().equals(
a61af66fc99e Initial load
duke
parents:
diff changeset
59 "sun.jvm.hotspot.jdi.SAPIDAttachingConnector")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
60 myPIDConn = tmpCon;
a61af66fc99e Initial load
duke
parents:
diff changeset
61 } else if (tmpCon.name().equals(
a61af66fc99e Initial load
duke
parents:
diff changeset
62 "sun.jvm.hotspot.jdi.SADebugServerAttachingConnector")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
63 myDbgSvrConn = tmpCon;
a61af66fc99e Initial load
duke
parents:
diff changeset
64 }
a61af66fc99e Initial load
duke
parents:
diff changeset
65 }
a61af66fc99e Initial load
duke
parents:
diff changeset
66 String execPath = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
67 String pidText = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
68 String coreFilename = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
69 String debugServer = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
70 int pid = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
71 switch (args.length) {
a61af66fc99e Initial load
duke
parents:
diff changeset
72 case (0):
a61af66fc99e Initial load
duke
parents:
diff changeset
73 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
74 case (1):
a61af66fc99e Initial load
duke
parents:
diff changeset
75 // If all numbers, it is a PID to attach to
a61af66fc99e Initial load
duke
parents:
diff changeset
76 // Else, it is a pathname to a .../bin/java for a core file.
a61af66fc99e Initial load
duke
parents:
diff changeset
77 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
78 pidText = args[0];
a61af66fc99e Initial load
duke
parents:
diff changeset
79 pid = Integer.parseInt(pidText);
a61af66fc99e Initial load
duke
parents:
diff changeset
80 System.out.println( "pid: " + pid);
a61af66fc99e Initial load
duke
parents:
diff changeset
81 vm = attachPID(pid);
a61af66fc99e Initial load
duke
parents:
diff changeset
82 } catch (NumberFormatException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
83 System.out.println("trying remote server ..");
a61af66fc99e Initial load
duke
parents:
diff changeset
84 debugServer = args[0];
a61af66fc99e Initial load
duke
parents:
diff changeset
85 System.out.println( "remote server: " + debugServer);
a61af66fc99e Initial load
duke
parents:
diff changeset
86 vm = attachDebugServer(debugServer);
a61af66fc99e Initial load
duke
parents:
diff changeset
87 }
a61af66fc99e Initial load
duke
parents:
diff changeset
88 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
89
a61af66fc99e Initial load
duke
parents:
diff changeset
90 case (2):
a61af66fc99e Initial load
duke
parents:
diff changeset
91 execPath = args[0];
a61af66fc99e Initial load
duke
parents:
diff changeset
92 coreFilename = args[1];
a61af66fc99e Initial load
duke
parents:
diff changeset
93 System.out.println( "jdk: " + execPath);
a61af66fc99e Initial load
duke
parents:
diff changeset
94 System.out.println( "core: " + coreFilename);
a61af66fc99e Initial load
duke
parents:
diff changeset
95 vm = attachCore(coreFilename, execPath);
a61af66fc99e Initial load
duke
parents:
diff changeset
96 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
97 }
a61af66fc99e Initial load
duke
parents:
diff changeset
98
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 if (vm != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
101 System.out.println("sagclient: attached ok!");
a61af66fc99e Initial load
duke
parents:
diff changeset
102 sagdoit mine = new sagdoit(vm);
a61af66fc99e Initial load
duke
parents:
diff changeset
103 mine.doAll();
a61af66fc99e Initial load
duke
parents:
diff changeset
104 vm.dispose();
a61af66fc99e Initial load
duke
parents:
diff changeset
105 }
a61af66fc99e Initial load
duke
parents:
diff changeset
106 }
a61af66fc99e Initial load
duke
parents:
diff changeset
107
a61af66fc99e Initial load
duke
parents:
diff changeset
108 private static VirtualMachine attachCore(String coreFilename, String execPath) {
a61af66fc99e Initial load
duke
parents:
diff changeset
109 Map connArgs = myCoreConn.defaultArguments();
a61af66fc99e Initial load
duke
parents:
diff changeset
110 System.out.println("connArgs = " + connArgs);
a61af66fc99e Initial load
duke
parents:
diff changeset
111 VirtualMachine vm;
a61af66fc99e Initial load
duke
parents:
diff changeset
112 Connector.StringArgument connArg = (Connector.StringArgument)connArgs.get("core");
a61af66fc99e Initial load
duke
parents:
diff changeset
113 connArg.setValue(coreFilename);
a61af66fc99e Initial load
duke
parents:
diff changeset
114
a61af66fc99e Initial load
duke
parents:
diff changeset
115 connArg = (Connector.StringArgument)connArgs.get("javaExecutable");
a61af66fc99e Initial load
duke
parents:
diff changeset
116 connArg.setValue(execPath);
a61af66fc99e Initial load
duke
parents:
diff changeset
117 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
118 vm = myCoreConn.attach(connArgs);
a61af66fc99e Initial load
duke
parents:
diff changeset
119 } catch (IOException ee) {
a61af66fc99e Initial load
duke
parents:
diff changeset
120 System.err.println("ERROR: myCoreConn.attach got IO Exception:" + ee);
a61af66fc99e Initial load
duke
parents:
diff changeset
121 vm = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
122 } catch (IllegalConnectorArgumentsException ee) {
a61af66fc99e Initial load
duke
parents:
diff changeset
123 System.err.println("ERROR: myCoreConn.attach got illegal args exception:" + ee);
a61af66fc99e Initial load
duke
parents:
diff changeset
124 vm = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
125 }
a61af66fc99e Initial load
duke
parents:
diff changeset
126 return vm;
a61af66fc99e Initial load
duke
parents:
diff changeset
127 }
a61af66fc99e Initial load
duke
parents:
diff changeset
128
a61af66fc99e Initial load
duke
parents:
diff changeset
129 private static VirtualMachine attachPID(int pid) {
a61af66fc99e Initial load
duke
parents:
diff changeset
130 Map connArgs = myPIDConn.defaultArguments();
a61af66fc99e Initial load
duke
parents:
diff changeset
131 System.out.println("connArgs = " + connArgs);
a61af66fc99e Initial load
duke
parents:
diff changeset
132 VirtualMachine vm;
a61af66fc99e Initial load
duke
parents:
diff changeset
133 Connector.StringArgument connArg = (Connector.StringArgument)connArgs.get("pid");
a61af66fc99e Initial load
duke
parents:
diff changeset
134 connArg.setValue(Integer.toString(pid));
a61af66fc99e Initial load
duke
parents:
diff changeset
135
a61af66fc99e Initial load
duke
parents:
diff changeset
136 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
137 vm = myPIDConn.attach(connArgs);
a61af66fc99e Initial load
duke
parents:
diff changeset
138 } catch (IOException ee) {
a61af66fc99e Initial load
duke
parents:
diff changeset
139 System.err.println("ERROR: myPIDConn.attach got IO Exception:" + ee);
a61af66fc99e Initial load
duke
parents:
diff changeset
140 vm = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
141 } catch (IllegalConnectorArgumentsException ee) {
a61af66fc99e Initial load
duke
parents:
diff changeset
142 System.err.println("ERROR: myPIDConn.attach got illegal args exception:" + ee);
a61af66fc99e Initial load
duke
parents:
diff changeset
143 vm = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
144 }
a61af66fc99e Initial load
duke
parents:
diff changeset
145 return vm;
a61af66fc99e Initial load
duke
parents:
diff changeset
146 }
a61af66fc99e Initial load
duke
parents:
diff changeset
147
a61af66fc99e Initial load
duke
parents:
diff changeset
148
a61af66fc99e Initial load
duke
parents:
diff changeset
149 private static VirtualMachine attachDebugServer(String debugServer) {
a61af66fc99e Initial load
duke
parents:
diff changeset
150 Map connArgs = myDbgSvrConn.defaultArguments();
a61af66fc99e Initial load
duke
parents:
diff changeset
151 System.out.println("connArgs = " + connArgs);
a61af66fc99e Initial load
duke
parents:
diff changeset
152 VirtualMachine vm;
a61af66fc99e Initial load
duke
parents:
diff changeset
153 Connector.StringArgument connArg = (Connector.StringArgument)connArgs.get("debugServerName");
a61af66fc99e Initial load
duke
parents:
diff changeset
154 connArg.setValue(debugServer);
a61af66fc99e Initial load
duke
parents:
diff changeset
155
a61af66fc99e Initial load
duke
parents:
diff changeset
156 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
157 vm = myDbgSvrConn.attach(connArgs);
a61af66fc99e Initial load
duke
parents:
diff changeset
158 } catch (IOException ee) {
a61af66fc99e Initial load
duke
parents:
diff changeset
159 System.err.println("ERROR: myDbgSvrConn.attach got IO Exception:" + ee);
a61af66fc99e Initial load
duke
parents:
diff changeset
160 vm = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
161 } catch (IllegalConnectorArgumentsException ee) {
a61af66fc99e Initial load
duke
parents:
diff changeset
162 System.err.println("ERROR: myDbgSvrConn.attach got illegal args exception:" + ee);
a61af66fc99e Initial load
duke
parents:
diff changeset
163 vm = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
164 }
a61af66fc99e Initial load
duke
parents:
diff changeset
165 return vm;
a61af66fc99e Initial load
duke
parents:
diff changeset
166 }
a61af66fc99e Initial load
duke
parents:
diff changeset
167 }