Thrift and Protocol Buffers performance in Java Round 2

In my last test Thrift and Protocol Buffers performance in Java, Some comments told me that there are some tuning parameter for Protocol Buffer which can improve performance magically. The parameter was not turn on by default. I added
option optimize_for = SPEED
to the proto file, and re-generated the Java class, and the result:

Thrift Loop    : 10,000,000
Get object     : 14,394msec
Serdes thrift  : 37,671msec
Objs per second: 265,456
Total bytes    : 1,130,000,000

ProtoBuf Loop  : 10,000,000
Get object     : 8,170msec
Serdes protobuf: 33,054msec
Objs per second: 302,535
Total bytes    : 829,997,866

From the result, Protocol Buffers is 1.1 times faster than Thrift!

And from the Google Protocol Buffers group, why the optimize for speed was not turn on by default.

When using C++ or Java protocol buffers, for best performance you need to add a line to your .proto files:

option optimize_for = SPEED;

Otherwise, by default, the compiler optimizes for code size.  Optimizing for code size results in generated code that around a half to a third of the size, but runs an order of magnitude slower…

Here is the original post

如想及时阅读 Tim Yang 的文章,可通过页面右上方扫码订阅最新更新。

« | »

Comments

3 Comments

  1. […] Thrift and Protocol Buffers performance in Java Round 2 […]

  2. What’s up, the whole thing is going perfectly here and ofcourse every one is sharing information, that’s actually good,
    keep up writing.

  3. Which soft are you using for coding? I use Atom and I find it very useful and helpful, I love the colors of the tags.

Leave a Comment

Your email address will not be published. Required fields are marked *