python performance

91 views
Skip to first unread message

dvirsky

unread,
Mar 20, 2009, 9:02:00 AM3/20/09
to Protocol Buffers
Hi
I'm considering using protobuf for a client-server project where the
client is c++, and the server is php or python running on apache.

I did a comparison of the unofficial and incomplete php library of
protobuf, and the official python implementation.
I expected them to be pretty much the same, perhaps with the python
version being faster. I tested only serialization of very long
messages (4-8kB), since this is what the server will do mostly.

the results were that the php version is roughly 10 times faster than
the python version (which was compiled optimized for speed). On my
test, php managed to serialize about 150 messages per second, and
python about 15. running with psyco i got it up to 25 but it's still
very slow.

Is this reasonable? could I be doing something wrong? It just doesn't
make sense.

Both, btw, compared badly to serializing a similar message with the
PHP JSON library, which managed to do roughly 1500 serializations per
second. Which I would expect, as it's compiled into PHP and not
native.

Kenton Varda

unread,
Mar 20, 2009, 2:35:19 PM3/20/09
to dvirsky, Petar Petrov, Protocol Buffers
The Python implementation is pretty slow right now.  I'm not familiar with the PHP implementation so couldn't say exactly why it is faster, but it's not terribly surprising.

Petar is working on making the Python implementation use native C++ code for a lot of operations, which should make it much faster.

dvirsky

unread,
Mar 20, 2009, 2:59:27 PM3/20/09
to Protocol Buffers
Thanks,
It seems as though the serialization is the slowest part, as i would
expect.
My earlier test was composing one message and serializing it over and
over again.

Just composing the message over and over again is much faster - about
10 times faster.

Anyway, I think I'll pass on protobuf for this project, although it
looks very cool and would definitely be my choice if both ends were
cpp.

On Mar 20, 8:35 pm, Kenton Varda <ken...@google.com> wrote:
> The Python implementation is pretty slow right now.  I'm not familiar with
> the PHP implementation so couldn't say exactly why it is faster, but it's
> not terribly surprising.
> Petar is working on making the Python implementation use native C++ code for
> a lot of operations, which should make it much faster.
>

Dave Bailey

unread,
Mar 20, 2009, 3:31:04 PM3/20/09
to Protocol Buffers
If you are able to use the other "P" (Perl) instead of Python or PHP,
http://code.google.com/p/protobuf-perlxs will give performance
comparable to PHP JSON, I would bet.

-dave

kordi

unread,
Mar 24, 2009, 6:02:45 AM3/24/09
to Protocol Buffers
if you need anything which is yet not supported by the php version,
please let me know, i will add it for you

regards
Nikolai

On 20 Mrz., 14:02, dvirsky <dvir...@gmail.com> wrote:
> Hi
> I'm considering using protobuf for a client-server project where the
> client is c++, and the server isphpor python running on apache.
>
> I did a comparison of the unofficial and incompletephplibrary of
> protobuf, and the official python implementation.
> I expected them to be pretty much the same, perhaps with the python
> version being faster. I tested only serialization of very long
> messages (4-8kB), since this is what the server will do mostly.
>
> the results were that thephpversion is roughly 10 times faster than
> the python version (which was compiled optimized for speed). On my
> test,phpmanaged to serialize about 150 messages per second, and
> python about 15. running with psyco i got it up to 25 but it's still
> very slow.
>
> Is this reasonable? could I be doing something wrong? It just doesn't
> make sense.
>
> Both, btw, compared badly to serializing a similar message with thePHPJSON library, which managed to do roughly 1500 serializations per
Reply all
Reply to author
Forward
0 new messages