Skip to content

Conversation

@chaokunyang
Copy link
Collaborator

@chaokunyang chaokunyang commented Dec 2, 2025

Why?

The previouse benchmark is not fair:

  • Protobuf encode negative varint use 5 bytes, but fory may only use one bytes. And for small varint, fory has zigzag cost. this is not a fair compare
  • When serialize Sample, Fory allocate a vector every time, but protobuf serialize to a buffer instead.

What does this PR do?

  • Make NumericStruct contains int32 of all kinds size, and positive and negative
  • Make fory serialize to a buffer to for sample

With this fair compare, fory is similair performance as protobuf

Related issues

#2958
#2960

Does this PR introduce any user-facing change?

  • Does this PR introduce any public API change?
  • Does this PR introduce any binary protocol compatibility change?

Benchmark

Datatype Operation Fory (ns) Protobuf (ns) Faster
Sample Serialize 345.6 316.4 Protobuf (1.1x)
Sample Deserialize 1376.4 1374.6 Protobuf (1.0x)
Struct Serialize 129.4 157.0 Fory (1.2x)
Struct Deserialize 207.5 154.4 Protobuf (1.3x)

@pandalee99 pandalee99 merged commit 313fc71 into apache:main Dec 2, 2025
55 checks passed
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.

2 participants