[CalendarServer-changes] [6921] CalendarServer/trunk/contrib/performance

source_changes at macosforge.org source_changes at macosforge.org
Mon Feb 14 09:27:46 PST 2011


Revision: 6921
          http://trac.macosforge.org/projects/calendarserver/changeset/6921
Author:   exarkun at twistedmatrix.com
Date:     2011-02-14 09:27:44 -0800 (Mon, 14 Feb 2011)
Log Message:
-----------
Switch to a time-based sampling limit, to accomodate both really fast and really slow benchmarks.

Modified Paths:
--------------
    CalendarServer/trunk/contrib/performance/benchlib.py
    CalendarServer/trunk/contrib/performance/benchmark.py

Modified: CalendarServer/trunk/contrib/performance/benchlib.py
===================================================================
--- CalendarServer/trunk/contrib/performance/benchlib.py	2011-02-14 17:18:59 UTC (rev 6920)
+++ CalendarServer/trunk/contrib/performance/benchlib.py	2011-02-14 17:27:44 UTC (rev 6921)
@@ -18,7 +18,8 @@
 from time import time
 
 from twisted.internet.defer import (
-    DeferredSemaphore, inlineCallbacks, returnValue, gatherResults)
+    DeferredSemaphore, DeferredList, inlineCallbacks, returnValue,
+    gatherResults)
 # from twisted.internet.task import deferLater
 from twisted.web.http_headers import Headers
 # from twisted.internet import reactor
@@ -81,10 +82,20 @@
     return d
 
 
+
+def firstResult(deferreds):
+    """
+    Return a L{Deferred} which fires when the first L{Deferred} from
+    C{deferreds} fires.
+
+    @param deferreds: A sequence of Deferreds to wait on.
+    """
+    
+    
+
+
 @inlineCallbacks
-def sample(dtrace, samples, agent, paramgen, responseCode, concurrency=1):
-    sem = DeferredSemaphore(concurrency)
-
+def sample(dtrace, sampleTime, agent, paramgen, responseCode, concurrency=1):
     urlopen = Duration('HTTP')
     data = {urlopen: []}
 
@@ -134,11 +145,36 @@
     msg('starting dtrace')
     yield dtrace.start()
     msg('dtrace started')
+
+    start = time()
     l = []
-    for i in range(samples):
-        l.append(sem.run(once))
-    yield gatherResults(l)
+    for i in range(concurrency):
+        l.append(once())
+    print 'Start', concurrency
 
+    while True:
+        try:
+            print 'Waiting...',
+            result, index = yield DeferredList(l, fireOnOneCallback=True, fireOnOneErrback=True)
+            print 'Success result at index', index
+        except FirstError, e:
+            print 'Failure result, re-raising'
+            e.subFailure.raiseException()
+
+        if time() > start + sampleTime:
+            print 'Alloted time expired, waiting for remaining...',
+            # Wait for the rest of the outstanding requests to keep things tidy
+            yield DeferredList(l)
+            print 'Complete.'
+            # And then move on
+            break
+        else:
+            print 'Starting replacement operation'
+            # Get rid of the completed Deferred
+            del l[index]
+            # And start a new operation to replace it
+            l.append(once())
+    
     msg('stopping dtrace')
     leftOver = yield dtrace.stop()
     msg('dtrace stopped')

Modified: CalendarServer/trunk/contrib/performance/benchmark.py
===================================================================
--- CalendarServer/trunk/contrib/performance/benchmark.py	2011-02-14 17:18:59 UTC (rev 6920)
+++ CalendarServer/trunk/contrib/performance/benchmark.py	2011-02-14 17:27:44 UTC (rev 6921)
@@ -322,7 +322,12 @@
 
 @inlineCallbacks
 def benchmark(host, port, pids, label, scalingParameters, benchmarks):
-    samples = 200
+    # Collect samples for 2 minutes.  This should give plenty of data
+    # for quick benchmarks.  It will leave lots of error (due to small
+    # sample size) for very slow benchmarks, but the error isn't as
+    # interesting as the fact that a single operation takes
+    # double-digit seconds or longer to complete.
+    sampleTime = 60 / 2
 
     statistics = {}
 
@@ -332,7 +337,7 @@
         for p in parameters:
             print '%s, parameter=%s' % (name, p)
             dtrace = DTraceCollector("io_measure.d", pids)
-            data = yield measure(host, port, dtrace, p, samples)
+            data = yield measure(host, port, dtrace, p, sampleTime)
             statistics[name][p] = data
 
     fObj = file(
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110214/7c0baf7b/attachment.html>


More information about the calendarserver-changes mailing list