Liking cljdoc? Tell your friends :D

Serialization Benchmarks - Baseline (Before Optimizations)

Benchmark Date

2025-10-24 22:43:11 UTC

Test Configuration

  • Rust: Release build with optimizations
  • RUSTFLAGS: -C target-cpu=native
  • Features: protobuf
  • Criterion: 100 samples per benchmark

Baseline Results Summary (1000 terms dictionary)

Serialization Performance

FormatTime (µs)Throughput (Melem/s)
Bincode893.531.1192
JSON909.691.0993
Protobuf V1815.911.2256
Protobuf V2803.031.2453

Deserialization Performance

FormatTime (µs)Throughput (Melem/s)
Bincode257.963.8765
JSON281.253.5555
Protobuf V1485.182.0611
Protobuf V2448.792.2282

Detailed Results

Bincode Serialization

SizeTimeThroughput
10094.053 µs1.0632 Melem/s
500451.39 µs1.1077 Melem/s
1000893.53 µs1.1192 Melem/s
50004.2358 ms1.1804 Melem/s

Bincode Deserialization

SizeTimeThroughput
10023.980 µs4.1701 Melem/s
500128.68 µs3.8855 Melem/s
1000257.96 µs3.8765 Melem/s
50001.2818 ms3.9007 Melem/s

JSON Serialization

SizeTimeThroughput
100100.76 µs992.47 Kelem/s
500450.95 µs1.1088 Melem/s
1000909.69 µs1.0993 Melem/s
50004.5181 ms1.1067 Melem/s

JSON Deserialization

SizeTimeThroughput
10031.388 µs3.1859 Melem/s
500143.81 µs3.4767 Melem/s
1000281.25 µs3.5555 Melem/s
50001.5638 ms3.1974 Melem/s

Protobuf V1 Serialization

SizeTimeThroughput
10090.777 µs1.1016 Melem/s
500414.08 µs1.2075 Melem/s
1000815.91 µs1.2256 Melem/s
50004.0106 ms1.2467 Melem/s

Protobuf V1 Deserialization

SizeTimeThroughput
10051.156 µs1.9548 Melem/s
500243.06 µs2.0571 Melem/s
1000485.18 µs2.0611 Melem/s
50002.3385 ms2.1382 Melem/s

Protobuf V2 Serialization

SizeTimeThroughput
10088.560 µs1.1292 Melem/s
500404.51 µs1.2361 Melem/s
1000803.03 µs1.2453 Melem/s
50003.8532 ms1.2976 Melem/s

Protobuf V2 Deserialization

SizeTimeThroughput
10046.997 µs2.1278 Melem/s
500230.85 µs2.1659 Melem/s
1000448.79 µs2.2282 Melem/s
50002.2097 ms2.2627 Melem/s

Format Comparison (1000 terms)

Serialization Speed Ranking

  1. Protobuf V2: 803.03 µs (fastest)
  2. Protobuf V1: 815.91 µs
  3. Bincode: 893.53 µs
  4. JSON: 909.69 µs (slowest)

Deserialization Speed Ranking

  1. Bincode: 257.96 µs (fastest)
  2. JSON: 281.25 µs
  3. Protobuf V2: 448.79 µs
  4. Protobuf V1: 485.18 µs (slowest)

Observations

  1. Protobuf V2 is fastest for serialization but slower for deserialization

    • V2's packed format reduces encoding overhead
    • Delta encoding and flat arrays are efficient to write
    • But reconstruction requires more computation
  2. Bincode is fastest for deserialization

    • Direct memory representation
    • Minimal transformation needed
  3. Performance scales well with dictionary size

    • All formats maintain consistent throughput as size increases
    • No significant degradation at 5000 terms
  4. Protobuf V1 vs V2

    • V2 is ~1.6% faster at serialization
    • V2 is ~7.5% faster at deserialization
    • V2 also achieves 60% smaller file sizes

Next Steps

Run optimized benchmarks with:

  • Vector pre-allocation
  • HashMap pre-sizing
  • Reduced allocation overhead

Expected improvements: 20-40% faster serialization/deserialization.

Can you improve this documentation?Edit on GitHub

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close