Skip to content

Repository files navigation

SerializeBenchmark

This project benchmarks the performance of various Java serialization frameworks:

  • SimpleBuffer (simple write, read string, varInt)
  • Google FlatBuffers
  • Google ProtoBuf
  • Kryo
  • Apache Fory

It measures serialization time, deserialization time, combined serialize+deserialize time, and serialized size.

Test Model

All benchmarks were performed using the following PlayerModel instance:

PlayerModelbaseModel = newPlayerModel(
UUID.randomUUID().toString(),
"Awake",
230,
newArrayList<>(List.of(1, 2, 3, 4, 5, 7, 8))
); 

Benchmark Results (100 Million Iterations)

FrameworkSerialize Time (ms)Deserialize Time (ms)Serialize + Deserialize Time (ms)Serialized Size (bytes)LOC
SimpleBuffer14,5179,37223,3045933
FlatBuffers33,1419,87044,26912436
ProtoBuf22,72511,34928,9955721
Kryo59,88553,198117,3505521
Apache Fory7,42010,12918,7796315

LOC = line of code

Initial Observations

  • Apache Fory has the fastest serialization but slightly slower deserialization.
  • SimpleBuffer and ProtoBuf show balanced performance with small serialized sizes.
  • Kryo slows down significantly on high iteration counts, likely due to reflection overhead and dynamic class handling.
  • FlatBuffers produces larger serialized data but deserializes efficiently.

Recommendations for More Accurate Benchmarking

  1. Track memory usage with Runtime.getRuntime().
  2. Measure throughput (operations/sec) and average latency.
  3. Perform a JVM warm-up before the main benchmark to allow JIT compilation.
  4. Test with smaller batches (e.g., 1M iterations) to analyze scalability.

About Each Framework

  • SimpleBuffer – Lightweight and fast for basic models.
  • FlatBuffers – Zero-copy deserialization, slightly larger data.
  • ProtoBuf – Well-known, efficient, moderate speed.
  • Kryo – Flexible but slower for massive iterations.
  • Apache Fory – Code-generated serialization, extremely fast serialization speed.

About

Java serialization benchmark comparing SimpleBuffer, FlatBuffers, ProtoBuf, Kryo, and Apache Fory for speed, size, and complexity.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages