Hi Glyph,
On March 23, 2016 at 1:39:53 PM, Glyph (gl...@twistedmatrix.com) wrote:
On Mar 23, 2016, at 9:22 AM, L. Daniel Burr <ldanielb...@me.com> wrote:
My concern is that, should these classes be converted into hybrids via the
@oldStyle decorator, my service may experience some reduction in the number of
requests per second that it handles
If oldStyle converts the classes into hybrids, then it's broken. Hybrids don't
follow the semantics of old-style classes. So this won't happen.
I should definitely test the results to see if there *is* a performance
regression in my case.
My guess is that this is an insignificant micro-optimization and that pypy has
gotten better at optimizing hybrids since that caution was written. That said,
we're really bad at paying attention to speed.twistedmatrix.com and we really
need a way to see pre-merge performance metrics rather than just a graph over
time.
In the interest of putting my money where my mouth is, I’ve tested a very
simple case, where I create a class inheriting from
twisted.web.resource.Resource, and a subclass which mixes in “object”:
from twisted.application import internet, service
from twisted.internet import endpoints, reactor
from twisted.web import resource, server
class MyResource(resource.Resource):
isLeaf = True
def render_GET(self, request):
return 'Hello, World!'
class FrankenStyle(MyResource, object):
pass
print type(MyResource)
print type(FrankenStyle)
application = service.Application(‘test')
root = FrankenStyle()
s = server.Site(root)
ep = endpoints.serverFromString(reactor, 'tcp:8080')
svc = internet.StreamServerEndpointService(ep, s)
svc.setName(‘hybridtest')
svc.setServiceParent(application)
Running siege --benchmark --concurrent=10 --reps=1000 "http://127.0.0.1:8080/“
against the “MyResource” version gets me 5714.29 requests per second across 3
runs.
Running siege --benchmark --concurrent=10 --reps=1000 "http://127.0.0.1:8080/“
against the “FrankenStyle” version gets me an average of 5671.61 requests per
second across 3 runs.
So, not a huge difference, overall, and it might not even be visible over a
long enough period of time.
Thanks,
Daniel
_______________________________________________
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python