VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/tests/benchmarks/tdBenchmark2.py@ 102666

Last change on this file since 102666 was 101679, checked in by vboxsync, 13 months ago

ValidationKit/tests/benchmark/tdBenchmark2: Fix for 7.1, bugref:10507

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 7.3 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3# $Id: tdBenchmark2.py 101679 2023-10-31 11:39:59Z vboxsync $
4
5"""
6VirtualBox Validation Kit - Test that runs various benchmarks.
7"""
8
9__copyright__ = \
10"""
11Copyright (C) 2010-2023 Oracle and/or its affiliates.
12
13This file is part of VirtualBox base platform packages, as
14available from https://www.virtualbox.org.
15
16This program is free software; you can redistribute it and/or
17modify it under the terms of the GNU General Public License
18as published by the Free Software Foundation, in version 3 of the
19License.
20
21This program is distributed in the hope that it will be useful, but
22WITHOUT ANY WARRANTY; without even the implied warranty of
23MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24General Public License for more details.
25
26You should have received a copy of the GNU General Public License
27along with this program; if not, see <https://www.gnu.org/licenses>.
28
29The contents of this file may alternatively be used under the terms
30of the Common Development and Distribution License Version 1.0
31(CDDL), a copy of it is provided in the "COPYING.CDDL" file included
32in the VirtualBox distribution, in which case the provisions of the
33CDDL are applicable instead of those of the GPL.
34
35You may elect to license modified versions of this file under the
36terms and conditions of either the GPL or the CDDL or both.
37
38SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
39"""
40__version__ = "$Revision: 101679 $"
41
42
43# Standard Python imports.
44import os;
45import sys;
46
47# Only the main script needs to modify the path.
48try: __file__ # pylint: disable=used-before-assignment
49except: __file__ = sys.argv[0];
50g_ksValidationKitDir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))));
51sys.path.append(g_ksValidationKitDir);
52
53# Validation Kit imports.
54from testdriver import reporter;
55from testdriver import vbox;
56from testdriver import vboxcon;
57from testdriver import vboxtestvms;
58
59
60class tdBenchmark2(vbox.TestDriver):
61 """
62 Benchmark #2 - Memory.
63 """
64
65 def __init__(self):
66 vbox.TestDriver.__init__(self);
67 oTestVm = vboxtestvms.BootSectorTestVm(self.oTestVmSet, 'tst-bs-memalloc-1',
68 os.path.join(self.sVBoxBootSectors, 'bs3-memalloc-1.img'));
69 self.oTestVmSet.aoTestVms.append(oTestVm);
70
71
72 #
73 # Overridden methods.
74 #
75
76
77 def actionConfig(self):
78 self._detectValidationKit();
79 return self.oTestVmSet.actionConfig(self);
80
81 def actionExecute(self):
82 return self.oTestVmSet.actionExecute(self, self.testOneCfg);
83
84
85
86 #
87 # Test execution helpers.
88 #
89
90 def testOneCfg(self, oVM, oTestVm):
91 """
92 Runs the specified VM thru the tests.
93
94 Returns a success indicator on the general test execution. This is not
95 the actual test result.
96 """
97 fRc = False;
98
99 #
100 # Determin the RAM configurations we want to test.
101 #
102 cMbMaxGuestRam = self.oVBox.systemProperties.maxGuestRAM;
103 cMbHostAvail = self.oVBox.host.memoryAvailable;
104 cMbHostTotal = self.oVBox.host.memorySize;
105 reporter.log('cMbMaxGuestRam=%s cMbHostAvail=%s cMbHostTotal=%s' % (cMbMaxGuestRam, cMbHostAvail, cMbHostTotal,));
106
107 cMbHostAvail -= cMbHostAvail // 7; # Rough 14% safety/overhead margin.
108 if cMbMaxGuestRam < cMbHostAvail:
109 # Currently: 2048 GiB, 1536 GiB, 1024 GiB, 512 GiB, 256 GiB, 128 GiB, 64 GiB, 32 GiB
110 acMbRam = [ cMbMaxGuestRam, cMbMaxGuestRam // 4 * 3, cMbMaxGuestRam // 2, cMbMaxGuestRam // 4,
111 cMbMaxGuestRam // 8, cMbMaxGuestRam // 16 ];
112 if acMbRam[-1] > 64*1024:
113 acMbRam.append(64*1024);
114 if acMbRam[-1] > 32*1024:
115 acMbRam.append(32*1024);
116 elif cMbHostAvail > 8*1024:
117 # First entry is available memory rounded down to the nearest 8 GiB
118 cMbHostAvail = cMbHostAvail & ~(8 * 1024 - 1);
119 acMbRam = [ cMbHostAvail, ];
120
121 # The remaining entries are powers of two below that, up to 6 of these stopping at 16 GiB.
122 cMb = 8*1024;
123 while cMb < cMbHostAvail:
124 cMb *= 2;
125 while len(acMbRam) < 7 and cMb > 16 * 1024:
126 cMb //= 2;
127 acMbRam.append(cMb);
128 elif cMbHostAvail >= 16000 and cMbHostAvail > 7168:
129 # Desperate attempt at getting some darwin testruns too. We've got two
130 # with 16 GiB and they usually end up with just short of 8GiB of free RAM.
131 acMbRam = [7168,];
132 else:
133 reporter.log("Less than 8GB of host RAM available for VMs, skipping test");
134 return None;
135 reporter.log("RAM configurations: %s" % (acMbRam));
136
137 # Large pages only work with nested paging.
138 afLargePages = [False, ];
139 try:
140 fNestedPaging = False;
141 if self.fpApiVer >= 7.1:
142 fNestedPaging = oVM.platform.x86.getHWVirtExProperty(vboxcon.HWVirtExPropertyType_NestedPaging);
143 else:
144 fNestedPaging = oVM.getHWVirtExProperty(vboxcon.HWVirtExPropertyType_NestedPaging);
145
146 if fNestedPaging:
147 afLargePages = [True, False];
148 except:
149 return reporter.errorXcpt("Failed to get HWVirtExPropertyType_NestedPaging");
150
151 #
152 # Test the RAM configurations.
153 #
154 for fLargePages in afLargePages:
155 sLargePages = 'large pages' if fLargePages is True else 'no large pages';
156 for cMbRam in acMbRam:
157 reporter.testStart('%s MiB, %s' % (cMbRam, sLargePages));
158
159 # Reconfigure the VM:
160 fRc = False
161 oSession = self.openSession(oVM);
162 if oSession:
163 fRc = oSession.setRamSize(cMbRam);
164 fRc = oSession.setLargePagesX86(fLargePages) and fRc;
165 if fRc:
166 fRc = oSession.saveSettings();
167 if not fRc:
168 oSession.discardSettings(True);
169 oSession.close();
170 if fRc:
171 # Set up the result file
172 sXmlFile = self.prepareResultFile();
173 asEnv = [ 'IPRT_TEST_FILE=' + sXmlFile, ];
174
175 # Do the test:
176 self.logVmInfo(oVM);
177 oSession = self.startVm(oVM, sName = oTestVm.sVmName, asEnv = asEnv);
178 if oSession is not None:
179 cMsTimeout = 15 * 60000 + cMbRam // 168;
180 if not reporter.isLocal(): ## @todo need to figure a better way of handling timeouts on the testboxes ...
181 cMsTimeout = self.adjustTimeoutMs(180 * 60000 + cMbRam // 168);
182
183 oRc = self.waitForTasks(cMsTimeout);
184 if oRc == oSession:
185 fRc = oSession.assertPoweredOff();
186 else:
187 reporter.error('oRc=%s, expected %s' % (oRc, oSession));
188
189 reporter.addSubXmlFile(sXmlFile);
190 self.terminateVmBySession(oSession);
191 else:
192 reporter.errorXcpt("Failed to set memory size to %s MiB or setting largePages to %s" % (cMbRam, fLargePages));
193 reporter.testDone();
194
195 return fRc;
196
197
198
199if __name__ == '__main__':
200 sys.exit(tdBenchmark2().main(sys.argv));
201
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette