Protox - A 100% conformant protobuf library

Hi everyone,

I’ve been working on this protobuf library for 3 years. We use it in the company I work for, EasyMile, to communicate with our autonomous vehicles.

As you can imagine, reliability is very important! Therefore, a lot of efforts have been put into making sure that the library is reliable. To this end, I committed to make it pass all the 1302 conformance tests that Google provides for binary serialization. This is on top of having a 100% code coverage, plus property based testing and dialyzer.

In order to assess the performance of protox, I benchmarked it with random and handmade inputs against the other available libraries, exprotobuf and protobuf-elixir. You can find these benchmarks here (zip archive of a benchee HTML export). They show that protox is always faster than exprotobuf and most of the time on par or faster than protobuf-elixir. Of course, the result might be different with another computer/OS and with different inputs, I’ll be happy to include new ones.

Also, I think that protox is easier to use as it let you work directly with Elixir structures (for instance, there’s no need to use a new function to create a protobuf message, which means that you’ll have a nice error if you use a wrong field name). Furthermore, there’s no need to generate any file.
But of course, I may be a little biased here :wink:.
[Edit] It seems that file generation is important for some users, so I guess I should find a way to make it possible after all!

You can find it here: https://github.com/ahamez/protox. Let me know what you think!

46 Likes

This is very cool!
I have not had the chance to use Protobuf myself so far, but I am super stoked about the huge amount of work that clearly went into this library. :green_heart:

2 Likes

First of all, my utmost thanks for creating this library.

Just some extra information: I’m using your implementation in order to (try) to create a gherkin parser and the underlying message protocol is defined according to the ProtoBuf protocol.

And to be clear, your library works great. Just a double check regarding the compile time dependencies:
Does this mean that every person who wishes to use this library that uses your lib as a depency, have to install protoc? Similar to Argon2 (which causes a lot of problems on Windows, according to my students).

Is there a way to overcome this? I’ve tried using exprotobuf (I don’t mind it being slower if it compiles without the need for external applications), but too bad that there’s a small issue there (going to create a topic later on about that).

Hence I’m using your library. Just wanted to say thanks again!

Yes, protox requires protoc to be available at compile-time. It seems you need a library that generates code as you could just add the generated code to yours. I have some ideas to implement this, but I don’t know when I’ll be able to try those.
In the meantime, if you’re in a hurry, you can use https://github.com/tony612/protobuf-elixir. It’s not 100% compliant with protobuf specifications, but it will certainly help you to move faster.

1 Like

Thank you for the information ahamez. I’m watching this topic and am eagerly waiting for that code generation feature!

P.S. : if you need ever anyone to test an experimental feature, feel free to contact me!

Best of luck and keep up the awesome work!

So, I decided to give it a try, and it works :wink:. It’s a little crude as it’s performed via a mix task (thus you need to download the repository to generate files).
It’s now possible to generate Elixir files from protobuf messages:

MIX_ENV=prod mix protox.generate --output-path=/path/to/messages.ex foo.proto bar.proto

Thus, protoc is only required when generating files and project including those files just need to add protox as a dependancy.

Let me know if it works for you!

4 Likes

After trying this out, it works perfectly, thank you!

ElixirLs does take a lot to format these, but with enough RAM this all works out :wink:

Once again thanks for implementing this!

:speaking_head: protox 1.0.0 has been released! As no new features have been added and the API has been stable for a long time, I thought it was finally the time to mark it stable.

So, as a recall: why would you want to use protox rather than the others libraries like protobuf-elixir which has more features (and users :wink:)? Well, It really depends on how much do you need a reliable implementation. As protox has been written for the case of autonomous vehicles, reliability was more important than features. Thus, it has been has been thoroughly tested using the conformance checker provided by Google, has a 100% test coverage and uses property based testing.

Don’t hesitate to give it a try :slightly_smiling_face:.

9 Likes

I don’t need this at the moment but thanks for continuing to contribute to the ecosystem.

1 Like

:speaking_head: protox 1.2.1 is now available!
The main changes since 1.0.0 are:

And of course, it’s still 100% compliant with the Google conformance checker :wink: .

7 Likes