[CalendarServer-changes] [6199] CalendarServer/trunk/contrib/performance
source_changes at macosforge.org
source_changes at macosforge.org
Fri Aug 27 10:45:53 PDT 2010
Revision: 6199
http://trac.macosforge.org/projects/calendarserver/changeset/6199
Author: exarkun at twistedmatrix.com
Date: 2010-08-27 10:45:52 -0700 (Fri, 27 Aug 2010)
Log Message:
-----------
Add a facility for collecting dtrace results per-sample instead of per-benchmark
Modified Paths:
--------------
CalendarServer/trunk/contrib/performance/benchmark.py
CalendarServer/trunk/contrib/performance/io_measure.d
Modified: CalendarServer/trunk/contrib/performance/benchmark.py
===================================================================
--- CalendarServer/trunk/contrib/performance/benchmark.py 2010-08-27 17:32:15 UTC (rev 6198)
+++ CalendarServer/trunk/contrib/performance/benchmark.py 2010-08-27 17:45:52 UTC (rev 6199)
@@ -1,4 +1,4 @@
-import sys
+import sys, os
from os.path import dirname
from signal import SIGINT
@@ -37,7 +37,11 @@
self._out = ''
self._err = ''
+
+ def mark(self):
+ return self.parser.mark()
+
def errReceived(self, bytes):
self._err += bytes
if 'Interrupted system call' in self._err:
@@ -81,6 +85,7 @@
sql = None
start = None
+ _marked = None
def __init__(self, collector):
self.collector = collector
@@ -94,6 +99,18 @@
getattr(self, '_op_' + op)(op, rest)
+ def mark(self):
+ self._marked = Deferred()
+ return self._marked
+
+
+ def _op_MARK(self, cmd, rest):
+ marked = self._marked
+ self._marked = None
+ if marked is not None:
+ marked.callback(None)
+
+
def _op_EXECUTE(self, cmd, rest):
which, when = rest.split(None, 1)
if which == 'SQL':
@@ -134,6 +151,10 @@
def __init__(self, script, pids):
self._dScript = script
self.pids = pids
+ self._init_stats()
+
+
+ def _init_stats(self):
self._read = []
self._write = []
self._execute = []
@@ -141,12 +162,14 @@
def stats(self):
- return {
+ results = {
Bytes('read'): self._read,
Bytes('write'): self._write,
SQLDuration('execute'): self._execute,
SQLDuration('iternext'): self._iternext,
}
+ self._init_stats()
+ return results
def start(self):
@@ -163,8 +186,9 @@
def _startDTrace(self, pid):
started = Deferred()
stopped = Deferred()
+ proto = IOMeasureConsumer(started, stopped, _DTraceParser(self))
process = reactor.spawnProcess(
- IOMeasureConsumer(started, stopped, _DTraceParser(self)),
+ proto,
"/usr/sbin/dtrace",
["/usr/sbin/dtrace",
# process preprocessor macros
@@ -186,7 +210,7 @@
# have the stopped Deferred deal with the results. We
# don't want to do either of these for failed dtrace
# processes.
- self.dtraces[pid] = process
+ self.dtraces[pid] = (process, proto)
stopped.addCallback(self._cleanup, pid)
return passthrough
started.addCallbacks(ready, eintr)
@@ -198,9 +222,24 @@
return passthrough
+ def mark(self):
+ marks = []
+ for (process, protocol) in self.dtraces.itervalues():
+ marks.append(protocol.mark())
+ d = gatherResults(marks)
+ d.addCallback(lambda ign: self.stats())
+ try:
+ os.execve(
+ "CalendarServer dtrace benchmarking signal", [], {})
+ except OSError:
+ pass
+ return d
+
+
+
def stop(self):
- for proc in self.dtraces.itervalues():
- proc.signalProcess(SIGINT)
+ for (process, protocol) in self.dtraces.itervalues():
+ process.signalProcess(SIGINT)
d = gatherResults(self.finished)
d.addCallback(lambda ign: self.stats())
return d
Modified: CalendarServer/trunk/contrib/performance/io_measure.d
===================================================================
--- CalendarServer/trunk/contrib/performance/io_measure.d 2010-08-27 17:32:15 UTC (rev 6198)
+++ CalendarServer/trunk/contrib/performance/io_measure.d 2010-08-27 17:45:52 UTC (rev 6199)
@@ -22,3 +22,9 @@
{
printf("B_WRITE %d\n\1", args[0]->b_bcount);
}
+
+syscall::execve:entry
+/copyinstr(arg0) == "CalendarServer dtrace benchmarking signal"/
+{
+ printf("MARK x\n\1");
+}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100827/a25f8b72/attachment.html>
More information about the calendarserver-changes
mailing list