Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which protobuf optimization?

Using google's protocol buffer compiler for c++ its not clear which is faster: optimize for speed:

option optimize_for = SPEED;

or optimize for light runtime:

option optimize_for = LITE_RUNTIME;

if speed is faster, what makes it faster? does anyone have hard data on the subject?

like image 463
Aviad Rozenhek Avatar asked Dec 14 '10 12:12

Aviad Rozenhek


1 Answers

The way I read the documentation,

  • optimize for CODE_SIZE does not generate fast accessor methods for everything, but relies on slow reflection,

  • optimize for SPEED will give you the fast accessors

  • and optimize for LITE_RUNTIME will also give you fast accessors, but does not support the full functionality of protobuf, but only the lighter subset protobuf-lite. Basically, this means descriptors or reflection are not available.

So I guess, LITE_RUNTIME is not slower than SPEED, and you should choose depending on which runtime library you want to require (lite or full).

if speed is faster, what makes it faster?

SPEED is faster compared to CODE_SIZE, because it uses autogenerated code instead of runtime reflection.

like image 184
Thilo Avatar answered Sep 17 '22 22:09

Thilo