Status: New
Owner: ken...@google.com
Labels: Type-Defect Priority-Medium
New issue 251 by kleptog: Suggestion for performance improvement with Python
http://code.google.com/p/protobuf/issues/detail?id=251
What steps will reproduce the problem?
1. Run the Python code
What is the expected output? What do you see instead?
About 10% of the runtime is spent in the methods DecodeVarint and ReadTag,
each. With loop unrolling and some cleverness the runtime for these methods
can be cut by 30%, leading to a 10% overall increase in performance.
What version of the product are you using? On what operating system?
protobuf-2.3.0 on a Debian Lenny amd64.
Please provide any additional information below.
I think that the performance improvement in the general case might be a bit
less, since we use lots of repeated fields, which means these methods get
called dozens of times per message.
Using the attached file effected the speed increase for us.
Note: I also played with moving these to external C modules but that did
not help as much as I had hoped. The time for a 1-byte tag was about the
same in C and in Python. The time for C was unaffected by the length of the
tag but since single byte tags are by far the most common any performance
increase was difficult to measure.
Using PyPy does make a huge difference, which means that any use of
external modules is counter productive in our case.
I also briefly tried the extension code in 2.4.0 but that just threw an
exception. Since it's marked as experimental I haven't filed a bug yet, but
I can if it would help.
Attachments:
protobufopt.py 2.5 KB
--
You received this message because you are subscribed to the Google Groups "Protocol
Buffers" group.
To post to this group, send email to protobuf@googlegroups.com.
To unsubscribe from this group, send email to
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/protobuf?hl=en.