annotate agent/test/jdi/serialvm.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) 2003, 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
a61af66fc99e Initial load
duke
parents:
diff changeset
34 /* This class is used to test multi VM connectivity feature of
a61af66fc99e Initial load
duke
parents:
diff changeset
35 * SA/JDI. Accepts two PIDs as arguments. Connects to first VM
a61af66fc99e Initial load
duke
parents:
diff changeset
36 *, disposes it, connects to second VM, disposes second VM.
a61af66fc99e Initial load
duke
parents:
diff changeset
37 */
a61af66fc99e Initial load
duke
parents:
diff changeset
38
a61af66fc99e Initial load
duke
parents:
diff changeset
39
a61af66fc99e Initial load
duke
parents:
diff changeset
40 public class serialvm {
a61af66fc99e Initial load
duke
parents:
diff changeset
41 static AttachingConnector myPIDConn;
a61af66fc99e Initial load
duke
parents:
diff changeset
42 static VirtualMachine vm1;
a61af66fc99e Initial load
duke
parents:
diff changeset
43 static VirtualMachine vm2;
a61af66fc99e Initial load
duke
parents:
diff changeset
44 static VirtualMachineManager vmmgr;
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46 public static void println(String msg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
47 System.out.println(msg);
a61af66fc99e Initial load
duke
parents:
diff changeset
48 }
a61af66fc99e Initial load
duke
parents:
diff changeset
49
a61af66fc99e Initial load
duke
parents:
diff changeset
50 private static void usage() {
a61af66fc99e Initial load
duke
parents:
diff changeset
51 System.err.println("Usage: java serialvm <pid1> <pid2>");
a61af66fc99e Initial load
duke
parents:
diff changeset
52 System.exit(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
53 }
a61af66fc99e Initial load
duke
parents:
diff changeset
54
a61af66fc99e Initial load
duke
parents:
diff changeset
55 public static void main(String args[]) {
a61af66fc99e Initial load
duke
parents:
diff changeset
56 vmmgr = Bootstrap.virtualMachineManager();
a61af66fc99e Initial load
duke
parents:
diff changeset
57 List attachingConnectors = vmmgr.attachingConnectors();
a61af66fc99e Initial load
duke
parents:
diff changeset
58 if (attachingConnectors.isEmpty()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
59 System.err.println( "ERROR: No attaching connectors");
a61af66fc99e Initial load
duke
parents:
diff changeset
60 return;
a61af66fc99e Initial load
duke
parents:
diff changeset
61 }
a61af66fc99e Initial load
duke
parents:
diff changeset
62 Iterator myIt = attachingConnectors.iterator();
a61af66fc99e Initial load
duke
parents:
diff changeset
63 while (myIt.hasNext()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
64 AttachingConnector tmpCon = (AttachingConnector)myIt.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
65 if (tmpCon.name().equals(
a61af66fc99e Initial load
duke
parents:
diff changeset
66 "sun.jvm.hotspot.jdi.SAPIDAttachingConnector")) {
a61af66fc99e Initial load
duke
parents:
diff changeset
67 myPIDConn = tmpCon;
a61af66fc99e Initial load
duke
parents:
diff changeset
68 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
69 }
a61af66fc99e Initial load
duke
parents:
diff changeset
70 }
a61af66fc99e Initial load
duke
parents:
diff changeset
71
a61af66fc99e Initial load
duke
parents:
diff changeset
72 int pid1 = 0, pid2 = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
73 String pidText = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
74 switch (args.length) {
a61af66fc99e Initial load
duke
parents:
diff changeset
75 case (2):
a61af66fc99e Initial load
duke
parents:
diff changeset
76 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
77 pidText = args[0];
a61af66fc99e Initial load
duke
parents:
diff changeset
78 pid1 = Integer.parseInt(pidText);
a61af66fc99e Initial load
duke
parents:
diff changeset
79 System.out.println( "pid1: " + pid1);
a61af66fc99e Initial load
duke
parents:
diff changeset
80 pidText = args[1];
a61af66fc99e Initial load
duke
parents:
diff changeset
81 pid2 = Integer.parseInt(pidText);
a61af66fc99e Initial load
duke
parents:
diff changeset
82 System.out.println( "pid2: " + pid2);
a61af66fc99e Initial load
duke
parents:
diff changeset
83 } catch (NumberFormatException e) {
a61af66fc99e Initial load
duke
parents:
diff changeset
84 println(e.getMessage());
a61af66fc99e Initial load
duke
parents:
diff changeset
85 usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
86 }
a61af66fc99e Initial load
duke
parents:
diff changeset
87 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
88 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
89 usage();
a61af66fc99e Initial load
duke
parents:
diff changeset
90 }
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 // attach, dispose, attach2, dispose2 pattern
a61af66fc99e Initial load
duke
parents:
diff changeset
93 // as opposed to attach1, attach2, dispose1, dispose2
a61af66fc99e Initial load
duke
parents:
diff changeset
94 vm1 = attachPID(pid1);
a61af66fc99e Initial load
duke
parents:
diff changeset
95 if (vm1 != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
96 System.out.println("vm1: attached ok!");
a61af66fc99e Initial load
duke
parents:
diff changeset
97 System.out.println(vm1.version());
a61af66fc99e Initial load
duke
parents:
diff changeset
98 sagdoit mine = new sagdoit(vm1);
a61af66fc99e Initial load
duke
parents:
diff changeset
99 mine.doAll();
a61af66fc99e Initial load
duke
parents:
diff changeset
100 }
a61af66fc99e Initial load
duke
parents:
diff changeset
101 if (vm1 != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
102 vm1.dispose();
a61af66fc99e Initial load
duke
parents:
diff changeset
103 }
a61af66fc99e Initial load
duke
parents:
diff changeset
104
a61af66fc99e Initial load
duke
parents:
diff changeset
105 vm2 = attachPID(pid2);
a61af66fc99e Initial load
duke
parents:
diff changeset
106 if (vm2 != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
107 System.out.println("vm2: attached ok!");
a61af66fc99e Initial load
duke
parents:
diff changeset
108 System.out.println(vm2.version());
a61af66fc99e Initial load
duke
parents:
diff changeset
109 sagdoit mine = new sagdoit(vm2);
a61af66fc99e Initial load
duke
parents:
diff changeset
110 mine.doAll();
a61af66fc99e Initial load
duke
parents:
diff changeset
111 }
a61af66fc99e Initial load
duke
parents:
diff changeset
112
a61af66fc99e Initial load
duke
parents:
diff changeset
113
a61af66fc99e Initial load
duke
parents:
diff changeset
114 if (vm2 != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
115 vm2.dispose();
a61af66fc99e Initial load
duke
parents:
diff changeset
116 }
a61af66fc99e Initial load
duke
parents:
diff changeset
117 }
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 private static VirtualMachine attachPID(int pid) {
a61af66fc99e Initial load
duke
parents:
diff changeset
120 Map connArgs = myPIDConn.defaultArguments();
a61af66fc99e Initial load
duke
parents:
diff changeset
121 System.out.println("connArgs = " + connArgs);
a61af66fc99e Initial load
duke
parents:
diff changeset
122 VirtualMachine vm;
a61af66fc99e Initial load
duke
parents:
diff changeset
123 Connector.StringArgument connArg = (Connector.StringArgument)connArgs.get("pid");
a61af66fc99e Initial load
duke
parents:
diff changeset
124 connArg.setValue(Integer.toString(pid));
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
127 vm = myPIDConn.attach(connArgs);
a61af66fc99e Initial load
duke
parents:
diff changeset
128 } catch (IOException ee) {
a61af66fc99e Initial load
duke
parents:
diff changeset
129 System.err.println("ERROR: myPIDConn.attach got IO Exception:" + ee);
a61af66fc99e Initial load
duke
parents:
diff changeset
130 vm = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
131 } catch (IllegalConnectorArgumentsException ee) {
a61af66fc99e Initial load
duke
parents:
diff changeset
132 System.err.println("ERROR: myPIDConn.attach got illegal args exception:" + ee);
a61af66fc99e Initial load
duke
parents:
diff changeset
133 vm = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
134 }
a61af66fc99e Initial load
duke
parents:
diff changeset
135 return vm;
a61af66fc99e Initial load
duke
parents:
diff changeset
136 }
a61af66fc99e Initial load
duke
parents:
diff changeset
137 }