chaokunyang opened a new pull request, #2960:
URL: https://github.com/apache/fory/pull/2960
## Why?
<!-- Describe the purpose of this PR. -->
## What does this PR do?
1. Type-based encoding detection: Added compile-time helpers to correctly
distinguish signed (varint) vs unsigned (fixed) integers:
- field_is_fixed_primitive<Index>() - bool, int8, uint8, int16, uint16,
uint32, uint64, float, double
- field_is_varint_primitive<Index>() - int32_t, int, int64_t, long long
(zigzag varint)
2. Optimized fixed field reading:
- Compute field offsets at compile time with
compute_fixed_field_offset<T, I>()
- Read all fixed fields at absolute offsets without per-field
reader_index updates
- Single reader_index update after all fixed fields
3. Optimized varint field reading:
- Track offset locally during batch reading
- Removed overly conservative max-varint-bytes pre-check (varints are
variable-length)
- Single reader_index update after all varints
4. Three-phase deserialization:
- Phase 1: Batch read leading fixed-size primitives
- Phase 2: Batch read consecutive varint primitives
- Phase 3: Read remaining fields normally
## Related issues
#2958
#2906
## Does this PR introduce any user-facing change?
<!--
If any user-facing interface changes, please [open an
issue](https://github.com/apache/fory/issues/new/choose) describing the need to
do so and update the document if necessary.
Delete section if not applicable.
-->
- [ ] Does this PR introduce any public API change?
- [ ] Does this PR introduce any binary protocol compatibility change?
## Benchmark
Performance Results
| Metric | Before | After | Improvement |
|-------------------------|-------------|--------------|---------------|
| Fory Struct Deserialize | 32.8 ns | 19.0 ns | 1.73x faster |
| Gap vs Protobuf | 1.9x slower | 1.23x slower | 35% reduction |
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]