<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[15351] CalendarServer/trunk/contrib/performance</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.calendarserver.org//changeset/15351">15351</a></dd>
<dt>Author</dt> <dd>cdaboo@apple.com</dd>
<dt>Date</dt> <dd>2015-12-01 13:38:14 -0800 (Tue, 01 Dec 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Fix old sim configs. Add a tool to run the sim against a range of server revisions.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServertrunkcontribperformanceloadtestclientsoldplist">CalendarServer/trunk/contrib/performance/loadtest/clients-old.plist</a></li>
<li><a href="#CalendarServertrunkcontribperformanceloadtestconfigoldplist">CalendarServer/trunk/contrib/performance/loadtest/config-old.plist</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li>CalendarServer/trunk/contrib/performance/simanalysis/</li>
<li><a href="#CalendarServertrunkcontribperformancesimanalysis__init__py">CalendarServer/trunk/contrib/performance/simanalysis/__init__.py</a></li>
<li><a href="#CalendarServertrunkcontribperformancesimanalysissim_regresspy">CalendarServer/trunk/contrib/performance/simanalysis/sim_regress.py</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServertrunkcontribperformanceloadtestclientsoldplist"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/contrib/performance/loadtest/clients-old.plist (15350 => 15351)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/contrib/performance/loadtest/clients-old.plist        2015-12-01 16:53:48 UTC (rev 15350)
+++ CalendarServer/trunk/contrib/performance/loadtest/clients-old.plist        2015-12-01 21:38:14 UTC (rev 15351)
</span><span class="lines">@@ -55,8 +55,10 @@
</span><span class="cx">
</span><span class="cx">                                         <key>supportAmpPush</key>
</span><span class="cx">                                         <true/>
</span><del>-                                        <key>ampPushHost</key>
-                                        <string>localhost</string>
</del><ins>+                                        <key>ampPushHosts</key>
+                                        <array>
+                                                <string>localhost</string>
+                                 </array>
</ins><span class="cx">                                         <key>ampPushPort</key>
</span><span class="cx">                                         <integer>62311</integer>
</span><span class="cx">                                 </dict>
</span></span></pre></div>
<a id="CalendarServertrunkcontribperformanceloadtestconfigoldplist"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/contrib/performance/loadtest/config-old.plist (15350 => 15351)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/contrib/performance/loadtest/config-old.plist        2015-12-01 16:53:48 UTC (rev 15350)
+++ CalendarServer/trunk/contrib/performance/loadtest/config-old.plist        2015-12-01 21:38:14 UTC (rev 15351)
</span><span class="lines">@@ -20,9 +20,47 @@
</span><span class="cx"> <plist version="1.0">
</span><span class="cx">         <dict>
</span><span class="cx">                 <!-- Identify the server to be load tested. -->
</span><del>-                <key>server</key>
-                <string>https://localhost:8443</string>
</del><ins>+                <key>servers</key>
+                <dict>
+                        <key>PodA</key>
+                        <dict>
+                                <key>enabled</key>
+                                <true/>
</ins><span class="cx">
</span><ins>+                                <!-- Identify the server to be load tested. -->
+                                <key>uri</key>
+                                <string>https://localhost:8443</string>
+
+                                <!-- Define whether server supports stats socket. -->
+                                <key>stats</key>
+                                <dict>
+                                        <key>enabled</key>
+                                        <true/>
+                                        <key>Port</key>
+                                        <integer>8100</integer>
+                                </dict>
+                        </dict>
+                        <key>PodB</key>
+                        <dict>
+                                <key>enabled</key>
+                                <false/>
+
+                                <!-- Identify the server to be load tested. -->
+                                <key>uri</key>
+                                <string>https://localhost:8543</string>
+
+                                <!-- Define whether server supports stats socket. -->
+                                <key>stats</key>
+                                <dict>
+                                        <key>enabled</key>
+                                        <true/>
+                                        <key>Port</key>
+                                        <integer>8101</integer>
+                                </dict>
+                        </dict>
+                </dict>
+
+
</ins><span class="cx">                 <!-- The template URI for doing initial principal lookup on. -->
</span><span class="cx">                 <key>principalPathTemplate</key>
</span><span class="cx">                 <string>/principals/users/%s/</string>
</span><span class="lines">@@ -37,15 +75,6 @@
</span><span class="cx">                         <integer>8080</integer>
</span><span class="cx">                 </dict>
</span><span class="cx">
</span><del>-                <!-- Define whether server supports stats socket. -->
-                <key>serverStats</key>
-                <dict>
-                        <key>enabled</key>
-                        <true/>
-                        <key>Port</key>
-                        <integer>8100</integer>
-                </dict>
-
</del><span class="cx">                 <!-- Define whether client data should be re-used. It will always be saved to the specified path.-->
</span><span class="cx">                 <key>clientDataSerialization</key>
</span><span class="cx">                 <dict>
</span><span class="lines">@@ -75,6 +104,11 @@
</span><span class="cx">                                         a relative path. This isn't a great solution. -->
</span><span class="cx">                                 <key>path</key>
</span><span class="cx">                                 <string>contrib/performance/loadtest/accounts.csv</string>
</span><ins>+
+                                <!-- When there are accounts for multiple pods, interleave the accounts for each
+                                        pod so that the arrival mechanism will cycle clients between each pod. -->
+                                <key>interleavePods</key>
+                                <true/>
</ins><span class="cx">                         </dict>
</span><span class="cx">                 </dict>
</span><span class="cx">
</span></span></pre></div>
<a id="CalendarServertrunkcontribperformancesimanalysis__init__py"></a>
<div class="addfile"><h4>Added: CalendarServer/trunk/contrib/performance/simanalysis/__init__.py (0 => 15351)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/contrib/performance/simanalysis/__init__.py         (rev 0)
+++ CalendarServer/trunk/contrib/performance/simanalysis/__init__.py        2015-12-01 21:38:14 UTC (rev 15351)
</span><span class="lines">@@ -0,0 +1,19 @@
</span><ins>+##
+# Copyright (c) 2015 Apple Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##
+
+"""
+Tools to manage sim runs and associated data.
+"""
</ins></span></pre></div>
<a id="CalendarServertrunkcontribperformancesimanalysissim_regresspy"></a>
<div class="addfile"><h4>Added: CalendarServer/trunk/contrib/performance/simanalysis/sim_regress.py (0 => 15351)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/contrib/performance/simanalysis/sim_regress.py         (rev 0)
+++ CalendarServer/trunk/contrib/performance/simanalysis/sim_regress.py        2015-12-01 21:38:14 UTC (rev 15351)
</span><span class="lines">@@ -0,0 +1,179 @@
</span><ins>+##
+# Copyright (c) 2015 Apple Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##
+
+import argparse
+import os
+import plistlib
+import shutil
+import subprocess
+import sys
+import time
+
+
+class SimRegress(object):
+ """
+ Class that manages running the sim against a range of SVN revisions.
+ """
+
+ TMP_DIR = "/tmp/CalendarServer-SimRegress"
+
+ def __init__(self, startRev, stopRev, stepRev):
+ self.startRev = startRev
+ self.currentRev = startRev
+ self.stopRev = stopRev
+ self.stepRev = stepRev
+ self.cwd = os.getcwd()
+ self.results = []
+
+
+ def run(self):
+
+ # Get the actual SVN revisions we want to use
+ svn_revs = self.getRevisions()
+ print("SVN Revisions to analyze: {}".format(svn_revs))
+
+ # Create the tmp dir and do initial checkout
+ for revision in svn_revs:
+ self.currentRev = revision
+ logfile = os.path.join(self.cwd, "Log-rev-{}.txt".format(self.currentRev))
+ with open(logfile, "w") as f:
+ self.log = f
+ self.checkRevision()
+ self.buildServer()
+ self.runServer()
+ qos = self.runSim()
+ self.stopServer()
+ with open(logfile) as f:
+ qos = filter(lambda line: line.strip().startswith("Qos : "), f.read().splitlines())
+ qos = float(qos[0].strip()[len("Qos : "):]) if qos else None
+ print("Revision: {} Qos: {}".format(self.currentRev, qos))
+ self.results.append((self.currentRev, qos))
+
+ print("All revisions complete")
+
+ print("\n*** Results:")
+ print("Rev\tQos")
+ for result in self.results:
+ print("{}\t{:.4f}".format(*result))
+
+
+ def getRevisions(self):
+
+ if self.stopRev is None:
+ print("Determining HEAD revision")
+ out = subprocess.check_output("svn info -r HEAD".split())
+ rev = filter(lambda line: line.startswith("Revision: "), out.splitlines())
+ if rev:
+ self.stopRev = int(rev[0][len("Revision: "):])
+ print("Using HEAD revision: {}".format(self.stopRev))
+
+ return range(self.startRev, self.stopRev, self.stepRev) + [self.stopRev]
+
+
+ def checkRevision(self):
+ # Create the tmp dir and do initial checkout
+ if not os.path.exists(SimRegress.TMP_DIR):
+ os.makedirs(SimRegress.TMP_DIR)
+ os.chdir(SimRegress.TMP_DIR)
+ self.checkoutInitialRevision()
+ else:
+ os.chdir(SimRegress.TMP_DIR)
+ actualRevision = self.currentRevision()
+ if actualRevision > self.currentRev:
+ # If actualRevision code is newer than what we want, always wipe it
+ # and start from scratch
+ shutil.rmtree(SimRegress.TMP_DIR)
+ self.checkRevision()
+ elif actualRevision < self.currentRev:
+ # Upgrade from older revision to what we want
+ self.updateRevision()
+
+
+ def checkoutInitialRevision(self):
+ print("Checking out revision: {}".format(self.startRev))
+ subprocess.call(
+ "svn checkout http://svn.calendarserver.org/repository/calendarserver/CalendarServer/trunk -r {start} .".format(start=self.startRev).split(),
+ stdout=self.log, stderr=self.log,
+ )
+
+
+ def currentRevision(self):
+ print("Checking current revision")
+ out = subprocess.check_output("svn info".split())
+ rev = filter(lambda line: line.startswith("Revision: "), out.splitlines())
+ return int(rev[0][len("Revision: "):]) if rev else None
+
+
+ def updateRevision(self):
+ print("Updating to revision: {}".format(self.currentRev))
+ subprocess.call("svn up -r {rev} .".format(rev=self.currentRev).split())
+
+
+ def patchConfig(self, configPath):
+ """
+ Patch the plist config file to use settings that make sense for the sim.
+
+ @param configPath: path to plist file to patch
+ @type configPath: L{str}
+ """
+
+ f = plistlib.readPlist(configPath)
+ f['Authentication']['Kerberos']['Enabled'] = False
+ plistlib.writePlist(f, configPath)
+
+
+ def buildServer(self):
+ print("Building revision: {}".format(self.currentRev))
+ subprocess.call("./bin/develop".split(), stdout=self.log, stderr=self.log)
+
+
+ def runServer(self):
+ print("Running revision: {}".format(self.currentRev))
+ shutil.copyfile("conf/caldavd-test.plist", "conf/caldavd-dev.plist")
+ self.patchConfig("conf/caldavd-dev.plist")
+ if os.path.exists("data"):
+ shutil.rmtree("data")
+ subprocess.call("./bin/run -nd".split(), stdout=self.log, stderr=self.log)
+ time.sleep(10)
+
+
+ def stopServer(self):
+ print("Stopping revision: {}".format(self.currentRev))
+ subprocess.call("./bin/run -k".split(), stdout=self.log, stderr=self.log)
+
+
+ def runSim(self):
+ print("Running sim")
+ if os.path.exists("/tmp/sim"):
+ shutil.rmtree("/tmp/sim")
+ subprocess.call("{exe} {sim} --config {config} --clients {clients} --runtime 300".format(
+ exe=sys.executable,
+ sim=os.path.join(self.cwd, "contrib/performance/loadtest/sim.py"),
+ config=os.path.join(self.cwd, "contrib/performance/loadtest/config-old.plist"),
+ clients=os.path.join(self.cwd, "contrib/performance/loadtest/clients-old.plist"),
+ ).split(), stdout=self.log, stderr=self.log)
+
+
+
+if __name__ == '__main__':
+ parser = argparse.ArgumentParser(description="Run the sim tool against a specific range of server revisions.")
+ parser.add_argument("--start", type=int, required=True, help="Revision number to start at")
+ parser.add_argument("--stop", type=int, help="Revision number to stop at")
+ parser.add_argument("--step", default=100, type=int, help="Revision number steps")
+
+ args = parser.parse_args()
+
+ SimRegress(args.start, args.stop, args.step).run()
</ins></span></pre>
</div>
</div>
</body>
</html>