Hi Glyph,
On March 23, 2016 at 1:39:53 PM, Glyph (***@twistedmatrix.com) wrote:
On Mar 23, 2016, at 9:22 AM, L. Daniel Burr <***@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