upb VS Protobuf

Compare upb vs Protobuf and see what are their differences.

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
upb Protobuf
6 171
1,503 63,657
0.8% 1.1%
8.3 10.0
25 days ago 1 day ago
C C++
GNU General Public License v3.0 or later GNU General Public License v3.0 or later
The number of mentions indicates the total number of mentions that we've tracked plus the number of user suggested alternatives.
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.

upb

Posts with mentions or reviews of upb. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2023-08-18.
  • C and C++ Prioritize Performance over Correctness
    3 projects | news.ycombinator.com | 18 Aug 2023
    > There are undeniably power users for whom every last bit of performance translates to very large sums of money, and I don’t claim to know how to satisfy them otherwise.

    That is the key, right there.

    In 1970, C may have been considered a general-purpose programming langauge. Today, given the landscape of languages currently available, C and C++ have a much more niche role. They are appropriate for the "power users" described above, who need every last bit of performance, at the cost of more development effort.

    When I'm working in C, I'm frequently watching the assembly language output closely, making sure that I'm getting the optimizations I expect. I frequently find missed optimization bugs in compilers. In these scenarios, undefined behavior is a tool that can actually help achieve my goal. The question I'm always asking myself is: what do I have to write in C to get the assembly language output I expect? Here is an example of such a journey: https://blog.reverberate.org/2021/04/21/musttail-efficient-i...

    I created the https://github.com/protocolbuffers/upb project a long time ago. It's written in C, and over the years I have gotten it to a state where the speed and code size are pretty compelling. Both speed and code size are very important to the use cases where it is being used. It's a relatively small code base also. I think focused, performance-oriented kernels are the area where C makes the most sense.

  • Cap'n Proto 1.0
    10 projects | news.ycombinator.com | 28 Jul 2023
    More and more languages are being built on top of the "upb" C library for protobuf (https://github.com/protocolbuffers/upb) which is designed around arenas to avoid this very problem.

    Currently Ruby, PHP, and Python are backed by upb, but this list may expand in the future.

  • Fast memcpy, A System Design
    4 projects | news.ycombinator.com | 19 Dec 2022
  • Implementing Hash Tables in C
    4 projects | news.ycombinator.com | 16 Oct 2021
    Lua uses "chained scatter" (linked list, but links point to other entries in the same table, to maintain locality): https://github.com/lua/lua/blob/master/ltable.c

    This is a good visual depiction of chained scatter: https://book.huihoo.com/data-structures-and-algorithms-with-...

    Inspired by Lua, I did the same for upb (https://github.com/protocolbuffers/upb). I recently benchmarked upb's table vs SwissTable for a string-keyed table and found I was beating it in both insert and lookup (in insert upb is beating SwissTable by 2x).

  • Asahi Linux progress report, August 2021
    6 projects | news.ycombinator.com | 14 Aug 2021
    > But yes, the serialized dict-of-arrays-of-dicts type stuff can be approached in a few ways, none of which are particularly beautiful.

    For what it's worth, this sounds somewhat similar to protobuf (which also supports dicts, arrays, etc).

    After spending many years trying to figure out the smallest, fastest, and simplest way to implement protobuf in https://github.com/protocolbuffers/upb, the single best improvement I found was to make the entire memory management model arena-based.

    When you parse an incoming request, all the little objects (messages, arrays, maps, etc) are allocated on the arena. When you are done with it, you just free the arena.

    In my experience this results in code that is both simpler and faster than trying to memory-manage all of the sub-objects independently. It also integrates nicely with existing memory-management schemes: I've been able to adapt the arena model to both Ruby (tracing GC) and PHP (refcounting) runtimes. You just have to make sure that the arena itself outlives any reference to any of the objects within.

  • Don't Use Protobuf for Telemetry
    8 projects | news.ycombinator.com | 30 Dec 2020
    > Google's implementations, at least C++ and Java, are a bunch of bloated crap (or maybe they're very good, but for a use case that I haven't yet encountered).

    As someone who has been working on protobuf-related things for >10 years, including creating a size-focused implementation (https://github.com/protocolbuffers/upb), and has been working on the protobuf team for >5 years, I have a few thoughts on this.

    I think it is true that protobuf C++ could be a lot more lean than it currently is. That's why I created upb (above) to begin with. But there's also a bit more to this story.

    The protobuf core runtime is split into two parts, "lite" and "full". Basically the full runtime contains reflection support, while the lite runtime omits it. The full runtime is much larger than the lite runtime. If you don't need runtime reflection for your protos, it's better to use "lite" by using "option optimize_for = LITE_RUNTIME" in your .proto file (https://developers.google.com/protocol-buffers/docs/proto#op...). That will cut out a huge amount of overhead in your binary. On the downside, you won't get functionality that requires reflection, including text format, JSON, or DebugString().

    In addition to this, even the lite runtime can get "lighter" if you compile your binary to statically link the runtime and strip unused symbols with -ffunction-sections/-fdata-sections and gc-sections in the linker. Some parts of the lite runtime are only used in unusual situations, like ExtensionSet which is only used if your protos use proto2 extensions (https://developers.google.com/protocol-buffers/docs/proto#ex...). If you avoid this stuff, the lite runtime is quite light.

    However, there is also the issue of the generated code size. The size of the generated code is generally quite large, even for lite. You are getting a generated parser, serializer, CopyFrom(), MergeFrom(), etc for every message you define. If your schema is of any size, this quickly adds up and can dwarf the size of the actual runtime. For this reason, C++ also supports "option optimize_for = CODE_SIZE" which does everything reflectively instead of generating code. This means you pay the fixed size hit from the full runtime, but the generated code size is much smaller. On the downside, "optimize_for = CODE_SIZE" has a severe speed penalty.

    I have long had the goal of making https://github.com/protocolbuffers/upb competitive with protobuf C++ in speed while achieving much smaller code size. With the benefit of 10 years of hindsight and many wrong turns, upb is meeting and even surpassing these goals. It is an order of magnitude smaller, both in the core runtime and the generated code, and after some recent experiments it is beginning to significantly surpass it in speed also (I want to publish these results soon, but the code is on this branch: https://github.com/protocolbuffers/upb/pull/310).

    upb has downsides that prevent it from being fully "user ready" yet: the API is still not 100% stable, there is no C++ API for the generated code yet (and C APIs for protobuf are relatively verbose and painful), it has a bunch of legacy APIs sitting around that I am just on the verge of being able to finally delete, and it doesn't support proto2 extensions yet. On the upside, it is 100% conformant on every other protobuf feature, it has full binary and JSON support, it supports reflection if you want it but also lets you omit it for code size savings.

    I hope 2021 is a year when I'll be able to publish more about these results, and when upb will be a more viable choice for users who want a smaller protobuf implementation.

Protobuf

Posts with mentions or reviews of Protobuf. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2024-03-09.
  • Reverse Engineering Protobuf Definitions from Compiled Binaries
    5 projects | news.ycombinator.com | 9 Mar 2024
    For at least 4 years protobuf has had decent support for self-describing messages (very similar to avro) as well as reflection

    https://github.com/protocolbuffers/protobuf/blob/main/src/go...

    Xgooglers trying to make do on the cheap will just create a Union of all their messages and include the message def in a self-describing message pattern. Super-sensitive network I/O can elide the message def (empty buffer) and any for RecordIO clone well file compression takes care of the definition.

    Definitely useful to be able to dig out old defs but protobuf maintainers have surprisingly added useful features so you don’t have to.

    Bonus points tho for extracting the protobuf defs that e.g. Apple bakes into their binaries.

  • Show HN: AuthWin – Authenticator App for Windows
    6 projects | news.ycombinator.com | 3 Mar 2024
  • Create Production-Ready SDKs With gRPC Gateway
    5 projects | dev.to | 8 Dec 2023
    gRPC Gateway is a protoc plugin that reads gRPC service definitions and generates a reverse proxy server that translates a RESTful JSON API into gRPC.
  • Create Production-Ready SDKs with Goa
    9 projects | dev.to | 22 Nov 2023
    To use more recent versions of protoc in future applications, you can download them from the Protobuf repository.
  • Roll your own auth with Rust and Protobuf
    5 projects | dev.to | 28 Oct 2023
    Use the Protobuf CLI protoc and the plugin protoc-gen-tonic.
  • Add extra stuff to a “standard” encoding? Sure, why not
    11 projects | news.ycombinator.com | 19 Sep 2023
    > didn’t find any standard for separating protobuf messages

    The fact that protobufs are not self-delimiting is an endless source of frustration, but I know of 2 standards:

    - SerializeDelimited* is part of the protobuf library: https://github.com/protocolbuffers/protobuf/blob/main/src/go...

    - Riegeli is "a file format for storing a sequence of string records, typically serialized protocol buffers. It supports dense compression, fast decoding, seeking, detection and optional skipping of data corruption, filtering of proto message fields for even faster decoding, and parallel encoding": https://github.com/google/riegeli

  • Block YouTube Ads on AppleTV by Decrypting and Stripping Ads from Profobuf
    11 projects | news.ycombinator.com | 26 Aug 2023
    It looks like it is in fact universal. Just glancing at the code here, it looks like the tool searches any arbitrary file for bytes that look like encoded protobuf descriptors, specifically looking for bytes that are plausibly the beginning of a FileDescriptorProto message defined here:

    https://github.com/protocolbuffers/protobuf/blob/main/src/go...

    This takes advantage of the fact that such descriptors are commonly compiled into programs that use protobuf. The descriptors are usually embedded as constant byte arrays. That said, not all protobuf implementations embed the descriptors and those that do often have an option to inhibit such embedding (at the expense of losing some dynamic introspection features).

  • How to learn to use protoc in 21 easily infuriating steps
    1 project | news.ycombinator.com | 12 Aug 2023
  • What's involved in protobuf encoding?
    1 project | /r/grpc | 28 Jul 2023
    Not much. You can check the source code in https://github.com/protocolbuffers/protobuf. For example, for serializing a boolean in C#: https://github.com/protocolbuffers/protobuf/blob/main/csharp/src/Google.Protobuf/WritingPrimitives.cs#L165. Strings and objects are a bit more complicated, but it is all about turning the data into its byte representation.
  • Trying To Solve The Confusion of Choice Between gRPC vs REST🕵
    1 project | dev.to | 22 Jul 2023
    One of the key feature of gRPC is protobuf .proto file(nothing but just a contract for me between two communicator code components) This file and protobuff compiler is so mature, then it generates a direct client implementation using protoccompiler. ref

What are some alternatives?

When comparing upb and Protobuf you can also consider the following projects:

idevicerestore - Restore/upgrade firmware of iOS devices

FlatBuffers - FlatBuffers: Memory Efficient Serialization Library

Protobuf.NET - Protocol Buffers library for idiomatic .NET

SBE - Simple Binary Encoding (SBE) - High Performance Message Codec

mbp-2016-linux - State of Linux on the MacBook Pro 2016 & 2017

MessagePack - MessagePack implementation for C and C++ / msgpack.org[C/C++]

bloaty - Bloaty: a size profiler for binaries

cereal - A C++11 library for serialization

macOS-Simple-KVM - Tools to set up a quick macOS VM in QEMU, accelerated by KVM.

Apache Parquet - Apache Parquet

test-infra - Test infrastructure for the Kubernetes project.

Bond - Bond is a cross-platform framework for working with schematized data. It supports cross-language de/serialization and powerful generic mechanisms for efficiently manipulating data. Bond is broadly used at Microsoft in high scale services.