[
https://issues.apache.org/jira/browse/THRIFT-1088?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13005061#comment-13005061
]
Will Pierce commented on THRIFT-1088:
-------------------------------------
Here's the test results from my first stab at some performance testing. I'll
attach two more files, perftest.py and runtest.sh that generates the following
output:
h2. Test of unpatched source
Starting test, python=sys.version_info(major=2, minor=7, micro=0,
releaselevel='final', serial=0), iterations=100000, tests: ('test_newgen',
'test_oldgen', 'test_newgen_accel', 'test_oldgen_accel')
| test_newgen | 119.4833302 usec/iteration | 11.948333 total time
| test_oldgen | 118.4334683 usec/iteration | 11.843347 total time
| test_newgen_accel | 22.4877405 usec/iteration | 2.248774 total time
| test_oldgen_accel | 22.5729895 usec/iteration | 2.257299 total time
h3. Running test with python2.4 (no accelerated protocol, not built for this
python)
Starting test, python=(2, 4, 6, 'final', 0), iterations=100000, tests:
('test_newgen', 'test_oldgen', 'test_newgen_accel', 'test_oldgen_accel')
| test_newgen | 130.6353498 usec/iteration | 13.063535 total time
| test_oldgen | 128.4458494 usec/iteration | 12.844585 total time
| test_newgen_accel | 134.2011499 usec/iteration | 13.420115 total time
| test_oldgen_accel | 133.1284285 usec/iteration | 13.312843 total time
h2. Test of patched code
bq.
patching file lib/py/src/protocol/TBinaryProtocol.py
patching file lib/py/src/protocol/TCompactProtocol.py
patching file lib/py/src/protocol/TProtocol.py
patching file lib/py/src/server/TServer.py
patching file lib/py/src/server/TNonblockingServer.py
patching file lib/py/src/Thrift.py
patching file lib/py/src/transport/TTransport.py
Starting test, python=sys.version_info(major=2, minor=7, micro=0,
releaselevel='final', serial=0), iterations=100000, tests: ('test_newgen',
'test_oldgen', 'test_newgen_accel', 'test_oldgen_accel')
| test_newgen | 119.9114180 usec/iteration | 11.991142 total time
| test_oldgen | 118.4970808 usec/iteration | 11.849708 total time
| test_newgen_accel | 21.5028381 usec/iteration | 2.150284 total time
| test_oldgen_accel | 21.6538477 usec/iteration | 2.165385 total time
h3. Running test with python2.4 (no accelerated protocol, not built for this
python)
Starting test, python=(2, 4, 6, 'final', 0), iterations=100000, tests:
('test_newgen', 'test_oldgen', 'test_newgen_accel', 'test_oldgen_accel')
| test_newgen | 131.5409899 usec/iteration | 13.154099 total time
| test_oldgen | 129.8144007 usec/iteration | 12.981440 total time
| test_newgen_accel | 136.0489106 usec/iteration | 13.604891 total time
| test_oldgen_accel | 135.2320910 usec/iteration | 13.523209 total time
Backing out patch (-R for reverse)
patching file lib/py/src/protocol/TBinaryProtocol.py
patching file lib/py/src/protocol/TCompactProtocol.py
patching file lib/py/src/protocol/TProtocol.py
patching file lib/py/src/server/TServer.py
patching file lib/py/src/server/TNonblockingServer.py
patching file lib/py/src/Thrift.py
patching file lib/py/src/transport/TTransport.py
Done
> Thrift library python classes should be new-style classes
> ---------------------------------------------------------
>
> Key: THRIFT-1088
> URL: https://issues.apache.org/jira/browse/THRIFT-1088
> Project: Thrift
> Issue Type: Improvement
> Components: Python - Library
> Affects Versions: 0.6
> Reporter: Will Pierce
> Priority: Minor
> Attachments: THRIFT-1088_pthon_new_style_classes.patch, perftest.py,
> runtest.sh
>
>
> The included python thrift library classes (TType, TProtocolBase, etc...) are
> all defined using old-style python class definitions. This makes it somewhat
> more difficult to dynamically deal with instances of those classes at
> runtime, since the type() builtin doesn't return the class name. I don't
> think there's really any good reason for avoiding using new style classes.
> The typical fear/uncertainty/doubt with new-style classes (since 2001 when
> they were made available in python 2.2) is that they are thought to be slower
> than old-style classes. I personally haven't ever found the performance
> difference between old and new style classes to
> Unless there's a compelling reason that Thrift developers want to use
> old-style classes, I think it's a more programmer-friendly choice to switch
> these to new-style classes. Not to mention the benefits that new style
> classes provide, see:
> http://realmike.org/blog/2010/07/18/introduction-to-new-style-classes-in-python/
>
> The following thrift classes don't inherit from the 'object' class, so are
> old-style classes:
> {noformat}
> % find . -name \*py | xargs grep class | grep -v [.]svn | grep '[a-zA-Z0-9]:$'
> ./src/protocol/TCompactProtocol.py:class CompactType:
> ./src/protocol/TCompactProtocol.py:class TCompactProtocolFactory:
> ./src/protocol/TProtocol.py:class TProtocolBase:
> ./src/protocol/TProtocol.py:class TProtocolFactory:
> ./src/protocol/TBinaryProtocol.py:class TBinaryProtocolFactory:
> ./src/protocol/TBinaryProtocol.py:class TBinaryProtocolAcceleratedFactory:
> ./src/Thrift.py:class TType:
> ./src/Thrift.py:class TMessageType:
> ./src/Thrift.py:class TProcessor:
> ./src/server/TServer.py:class TServer:
> ./src/server/TNonblockingServer.py:class Connection:
> ./src/server/TNonblockingServer.py:class TNonblockingServer:
> ./src/transport/TTransport.py:class TTransportBase:
> ./src/transport/TTransport.py:class CReadableTransport:
> ./src/transport/TTransport.py:class TServerTransportBase:
> ./src/transport/TTransport.py:class TTransportFactoryBase:
> ./src/transport/TTransport.py:class TBufferedTransportFactory:
> ./src/transport/TTransport.py:class TFramedTransportFactory:
> {noformat}
> I'll make changes to my local copy of trunk, run the tests and then attach a
> patch to this ticket for evaluation.
> Unless anyone has objections or concerns about switching to new style classes?
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira