Skip to content

Conversation

@ripatel-fd
Copy link
Contributor

This patch adds a fast embedded dependency-free Protobuf encoder.

The encoder operates at the wire-format level and can serialize
any proto3 message (excluding the deprecated groups feature).

The encoder's design incorporates a few features that sets it apart
from alternatives (Protobuf-C++, nanopb), and more useful to
Firedancer:

  • Simple: does not require protoc, absl, etc.
  • Serializes in two passes (encode, fixup length prefixes)
  • Does not require allocations
  • Allows user to serialize existing handwritten structs (instead of
    having to indirect through a Protobuf-generated struct)
  • Structured to benefit from compiler's CFG optimizations (bounds
    check elision): consists of a single header library containing
    pure functions
  • Various encoding tricks (tail clobbering) to reduce branches and
    code footprint

@ripatel-fd ripatel-fd marked this pull request as ready for review December 21, 2025 00:54
@github-actions
Copy link

Performance Measurements ⏳

Suite Baseline New Change
backtest mainnet-368528500-perf per slot 0.050445 s 0.050508 s 0.125%
backtest mainnet-368528500-perf snapshot load 1.639 s 1.641 s 0.122%
backtest mainnet-368528500-perf total elapsed 50.44536 s 50.507635 s 0.123%
firedancer mem usage with mainnet.toml 1005.23 GiB 1005.23 GiB 0.000%

@github-actions
Copy link

Performance Measurements ⏳

Suite Baseline New Change
backtest mainnet-368528500-perf per slot 0.050613 s 0.050657 s 0.087%
backtest mainnet-368528500-perf snapshot load 1.647 s 1.645 s -0.121%
backtest mainnet-368528500-perf total elapsed 50.613135 s 50.657368 s 0.087%
firedancer mem usage with mainnet.toml 1005.23 GiB 1005.23 GiB 0.000%

This patch adds a fast embedded dependency-free Protobuf encoder.

The encoder operates at the wire-format level and can serialize
any proto3 message (excluding the deprecated groups feature).

The encoder's design incorporates a few features that sets it apart
from alternatives (Protobuf-C++, nanopb), and more useful to
Firedancer:
- Simple: does not require protoc, absl, etc.
- Serializes in two passes (encode, fixup length prefixes)
- Does not require allocations
- Allows user to serialize existing handwritten structs (instead of
  having to indirect through a Protobuf-generated struct)
- Structured to benefit from compiler's CFG optimizations (bounds
  check elision): consists of a single header library containing
  pure functions
- Various encoding tricks (tail clobbering) to reduce branches and
  code footprint
@github-actions
Copy link

Performance Measurements ⏳

Suite Baseline New Change
backtest mainnet-368528500-perf per slot 0.050517 s 0.050398 s -0.236%
backtest mainnet-368528500-perf snapshot load 1.636 s 1.627 s -0.550%
backtest mainnet-368528500-perf total elapsed 50.517487 s 50.39826 s -0.236%
firedancer mem usage with mainnet.toml 1005.23 GiB 1005.23 GiB 0.000%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants