kidok / protobuf

Automatically exported from code.google.com/p/protobuf
0 stars 0 forks source link

Python proto optimization #611

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
(original thread) https://groups.google.com/forum/#!topic/protobuf/RDAKafkfXYM

I wrote a patch which optimize python proto performance.  Feng Xiao asked me to 
repost the diff in the issue tracker.

Patch: https://www.dropbox.com/s/q0y44ypti0by779/protobuf-2.5.0.patch1

Changes:
- precompute various varint tables
- don't use proto's ByteSize function for serialization
- got rid of StringIO

Internal benchmark:
- random repeated int32s - ~18% faster
- random repeated int64s - ~20% faster
- random repeated strings - 27% faster
- random repeated bytes - 27% faster
- repeated message with each with a single random string - ~20% faster

NOTE:
- predefined_varints.py is generated by generate_predefined_varints.py

Original issue reported on code.google.com by patr...@dropbox.com on 3 Mar 2014 at 6:40