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

source_changes at macosforge.org source_changes at macosforge.org
Thu Feb 24 08:42:51 PST 2011


Revision: 7077
          http://trac.macosforge.org/projects/calendarserver/changeset/7077
Author:   exarkun at twistedmatrix.com
Date:     2011-02-24 08:42:50 -0800 (Thu, 24 Feb 2011)
Log Message:
-----------
Add an event creation benchmark that uses a bounded recurrence.

Modified Paths:
--------------
    CalendarServer/trunk/contrib/performance/benchlib.py
    CalendarServer/trunk/contrib/performance/benchlib.sh
    CalendarServer/trunk/contrib/performance/benchmarks/event.py

Added Paths:
-----------
    CalendarServer/trunk/contrib/performance/_event_create.py
    CalendarServer/trunk/contrib/performance/benchmarks/bounded_recurrence.py

Added: CalendarServer/trunk/contrib/performance/_event_create.py
===================================================================
--- CalendarServer/trunk/contrib/performance/_event_create.py	                        (rev 0)
+++ CalendarServer/trunk/contrib/performance/_event_create.py	2011-02-24 16:42:50 UTC (rev 7077)
@@ -0,0 +1,69 @@
+##
+# Copyright (c) 2011 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.
+##
+
+"""
+Various helpers for event-creation benchmarks.
+"""
+
+from urllib2 import HTTPDigestAuthHandler
+
+from twisted.internet.defer import inlineCallbacks, returnValue
+from twisted.web.http_headers import Headers
+from twisted.web.http import CREATED
+from twisted.web.client import Agent
+from twisted.internet import reactor
+
+from httpauth import AuthHandlerAgent
+from benchlib import initialize, sample
+from httpclient import StringProducer
+
+def formatDate(d):
+    return ''.join(filter(str.isalnum, d.isoformat()))
+
+
+ at inlineCallbacks
+def measure(calendar, organizerSequence, events, host, port, dtrace, samples):
+    """
+    Benchmark event creation.
+    """
+    user = password = "user%02d" % (organizerSequence,)
+    root = "/"
+    principal = "/"
+
+    authinfo = HTTPDigestAuthHandler()
+    authinfo.add_password(
+        realm="Test Realm",
+        uri="http://%s:%d/" % (host, port),
+        user=user,
+        passwd=password)
+    agent = AuthHandlerAgent(Agent(reactor), authinfo)
+
+    # First set things up
+    yield initialize(agent, host, port, user, password, root, principal, calendar)
+
+    method = 'PUT'
+    uri = 'http://%s:%d/calendars/__uids__/%s/%s/foo-%%d.ics' % (
+        host, port, user, calendar)
+    headers = Headers({"content-type": ["text/calendar"]})
+
+    # Sample it a bunch of times
+    samples = yield sample(
+        dtrace, samples, 
+        agent, ((method, uri % (i,), headers, StringProducer(body))
+                for (i, body)
+                in events).next,
+        CREATED)
+    returnValue(samples)

Modified: CalendarServer/trunk/contrib/performance/benchlib.py
===================================================================
--- CalendarServer/trunk/contrib/performance/benchlib.py	2011-02-24 06:13:50 UTC (rev 7076)
+++ CalendarServer/trunk/contrib/performance/benchlib.py	2011-02-24 16:42:50 UTC (rev 7077)
@@ -18,8 +18,7 @@
 from time import time
 
 from twisted.internet.defer import (
-    DeferredSemaphore, DeferredList, inlineCallbacks, returnValue,
-    gatherResults)
+    FirstError, DeferredList, inlineCallbacks, returnValue)
 # from twisted.internet.task import deferLater
 from twisted.web.http_headers import Headers
 # from twisted.internet import reactor

Modified: CalendarServer/trunk/contrib/performance/benchlib.sh
===================================================================
--- CalendarServer/trunk/contrib/performance/benchlib.sh	2011-02-24 06:13:50 UTC (rev 7076)
+++ CalendarServer/trunk/contrib/performance/benchlib.sh	2011-02-24 16:42:50 UTC (rev 7077)
@@ -29,12 +29,12 @@
 CONF=$SOURCE/conf/caldavd-dev.plist
 
 # Names of benchmarks we can run.
-BENCHMARKS="find_calendars find_events event_move event_delete_attendee event_add_attendee event_change_date event_change_summary event_delete vfreebusy event"
+BENCHMARKS="find_calendars find_events event_move event_delete_attendee event_add_attendee event_change_date event_change_summary event_delete vfreebusy event bounded_recurrence"
 
 # Custom scaling parameters for benchmarks that merit it.  Be careful
 # not to exceed the 99 user limit for benchmarks where the scaling
 # parameter represents a number of users!
-SCALE_PARAMETERS="--parameters find_events:1,10,100,1000,10000"
+SCALE_PARAMETERS="--parameters find_events:1,10,100,1000,10000 --parameters bounded_recurrence:1"
 
 # Names of metrics we can collect.
 STATISTICS=(HTTP SQL read write pagein pageout)

Added: CalendarServer/trunk/contrib/performance/benchmarks/bounded_recurrence.py
===================================================================
--- CalendarServer/trunk/contrib/performance/benchmarks/bounded_recurrence.py	                        (rev 0)
+++ CalendarServer/trunk/contrib/performance/benchmarks/bounded_recurrence.py	2011-02-24 16:42:50 UTC (rev 7077)
@@ -0,0 +1,89 @@
+##
+# Copyright (c) 2011 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.
+##
+
+"""
+Benchmark a server's handling of events with a bounded recurrence.
+"""
+
+from uuid import uuid4
+from itertools import count
+from datetime import datetime, timedelta
+
+from _event_create import formatDate, measure as _measure
+
+DAILY_EVENT = """\
+BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//Apple Inc.//iCal 4.0.3//EN
+CALSCALE:GREGORIAN
+BEGIN:VTIMEZONE
+TZID:America/New_York
+BEGIN:DAYLIGHT
+TZOFFSETFROM:-0500
+RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
+DTSTART:20070311T020000
+TZNAME:EDT
+TZOFFSETTO:-0400
+END:DAYLIGHT
+BEGIN:STANDARD
+TZOFFSETFROM:-0400
+RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
+DTSTART:20071104T020000
+TZNAME:EST
+TZOFFSETTO:-0500
+END:STANDARD
+END:VTIMEZONE
+BEGIN:VEVENT
+CREATED:20110223T184640Z
+UID:%(UID)s
+DTEND;TZID=America/New_York:%(DTEND)s
+RRULE:FREQ=DAILY;INTERVAL=1;UNTIL=%(UNTIL)s
+TRANSP:OPAQUE
+SUMMARY:A meeting which occurs daily for several days.
+DTSTART;TZID=America/New_York:%(DTSTART)s
+DTSTAMP:20110223T184658Z
+SEQUENCE:5
+END:VEVENT
+END:VCALENDAR
+"""
+
+def makeEvent(i):
+    """
+    Create a new half-hour long event that starts soon and recurs
+    daily for the next five days.
+    """
+    now = datetime.now()
+    start = now.replace(minute=15, second=0, microsecond=0) + timedelta(hours=i)
+    end = start + timedelta(minutes=30)
+    until = start + timedelta(days=5)
+    return DAILY_EVENT % {
+        'DTSTART': formatDate(start),
+        'DTEND': formatDate(end),
+        'UNTIL': formatDate(until),
+        'UID': uuid4(),
+        }
+
+
+def measure(host, port, dtrace, attendeeCount, samples):
+    calendar = "bounded-recurrence"
+    organizerSequence = 1
+
+    # An infinite stream of recurring VEVENTS to PUT to the server.
+    events = ((i, makeEvent(i)) for i in count(2))
+
+    return _measure(
+        calendar, organizerSequence, events,
+        host, port, dtrace, samples)

Modified: CalendarServer/trunk/contrib/performance/benchmarks/event.py
===================================================================
--- CalendarServer/trunk/contrib/performance/benchmarks/event.py	2011-02-24 06:13:50 UTC (rev 7076)
+++ CalendarServer/trunk/contrib/performance/benchmarks/event.py	2011-02-24 16:42:50 UTC (rev 7077)
@@ -19,20 +19,11 @@
 """
 
 from itertools import count
-from urllib2 import HTTPDigestAuthHandler
 from uuid import uuid4
 from datetime import datetime, timedelta
 
-from twisted.internet.defer import inlineCallbacks, returnValue
-from twisted.internet import reactor
-from twisted.web.client import Agent
-from twisted.web.http_headers import Headers
-from twisted.web.http import CREATED
+from _event_create import formatDate, measure as _measure
 
-from httpauth import AuthHandlerAgent
-from httpclient import StringProducer
-from benchlib import initialize, sample
-
 # XXX Represent these as vobjects?  Would make it easier to add more vevents.
 event = """\
 BEGIN:VCALENDAR
@@ -79,10 +70,6 @@
             attendee % {'SEQUENCE': n} for n in range(2, count + 2)])
 
 
-def formatDate(d):
-    return ''.join(filter(str.isalnum, d.isoformat()))
-
-
 SUMMARY = "STUFF IS THINGS"
 
 def makeEvent(i, organizerSequence, attendeeCount):
@@ -115,39 +102,13 @@
         }
 
 
- at inlineCallbacks
 def measure(host, port, dtrace, attendeeCount, samples):
-    organizerSequence = 1
-    user = password = "user%02d" % (organizerSequence,)
-    root = "/"
-    principal = "/"
     calendar = "event-creation-benchmark"
+    organizerSequence = 1
 
-    authinfo = HTTPDigestAuthHandler()
-    authinfo.add_password(
-        realm="Test Realm",
-        uri="http://%s:%d/" % (host, port),
-        user=user,
-        passwd=password)
-    agent = AuthHandlerAgent(Agent(reactor), authinfo)
-
-    # First set things up
-    yield initialize(agent, host, port, user, password, root, principal, calendar)
-
-    method = 'PUT'
-    uri = 'http://%s:%d/calendars/__uids__/%s/%s/foo-%%d.ics' % (
-        host, port, user, calendar)
-    headers = Headers({"content-type": ["text/calendar"]})
-
     # An infinite stream of VEVENTs to PUT to the server.
     events = ((i, makeEvent(i, organizerSequence, attendeeCount)) for i in count(2))
 
-    # Sample it a bunch of times
-    samples = yield sample(
-        dtrace, samples, 
-        agent, ((method, uri % (i,), headers, StringProducer(body))
-                for (i, body)
-                in events).next,
-        CREATED)
-    returnValue(samples)
-
+    return _measure(
+        calendar, organizerSequence, events,
+        host, port, dtrace, samples)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20110224/87f070c2/attachment-0001.html>


More information about the calendarserver-changes mailing list