tree: a393588a5639ab646bd299fb8cfc4684e27bfd1f
  1. benches/
  2. src/
  3. benchmark_report.py
  4. build.rs
  5. Cargo.toml
  6. README.md
  7. run.sh
benchmarks/rust/README.md

Fory Rust Benchmark

This benchmark compares Rust serialization and deserialization throughput for Apache Fory and Protocol Buffers using the shared benchmark dataset defined in benchmarks/proto/bench.proto.

Quick Start

Run the complete Rust benchmark pipeline:

cd benchmarks/rust
./run.sh

Run Options

./run.sh --help

Options:
  --data <struct|sample|mediacontent|structlist|samplelist|mediacontentlist>
                               Filter benchmark by data type
  --serializer <fory|protobuf>
                               Filter benchmark by serializer
  --filter <regex>             Custom criterion filter
  --no-report                  Skip Python report generation

Examples:

# Run only NumericStruct benchmarks
./run.sh --data struct

# Run only Protobuf benchmarks
./run.sh --serializer protobuf

# Run only Sample and MediaContent benchmarks for Protobuf
./run.sh --data sample,mediacontent --serializer protobuf

Schema Mismatch Mode

Set FORY_BENCH_SCHEMA_MISMATCH=1 to run the Fory-only compatible-read schema-mismatch mode. This mode is off by default. When enabled, run with --serializer fory; protobuf and MessagePack benchmark modes fail with a configuration error. Fory serialization uses the normal v1 benchmark structs, and Fory deserialization uses v2 structs registered with the same Fory type IDs where one int32 field is widened to int64.

Benchmark Cases

Benchmark caseDescription
NumericStructNumeric struct with 12 int32 fields
SampleMixed primitive and array payload matching the shared benchmark schema
MediaContentMedia and image payload matching the Java/C++ benchmark data
NumericStructListList of shared NumericStruct payloads
SampleListList of shared Sample payloads
MediaContentListList of shared MediaContent payloads

Shared Proto Schema

The Rust benchmark uses the shared protobuf definition at benchmarks/proto/bench.proto, the same benchmark schema used by the C++ benchmark suite.

Manual Commands

Run Criterion benchmarks:

cd benchmarks/rust
cargo bench --bench serialization_bench

Print serialized sizes:

cd benchmarks/rust
cargo run --release --bin fory_profiler -- --print-all-serialized-sizes

Generate the markdown report manually:

cd benchmarks/rust
cargo bench --bench serialization_bench 2>&1 | tee results/cargo_bench.log
cargo run --release --bin fory_profiler -- --print-all-serialized-sizes | tee results/serialized_sizes.txt
python benchmark_report.py --log-file results/cargo_bench.log --size-file results/serialized_sizes.txt --output-dir results

Report Output

The report generator writes:

  • results/README.md
  • results/throughput.png