perf(python): optimize int64 list/tuple serialization with C++ batch processing#3216
Open
pandalee99 wants to merge 13 commits intoapache:mainfrom
Open
perf(python): optimize int64 list/tuple serialization with C++ batch processing#3216pandalee99 wants to merge 13 commits intoapache:mainfrom
pandalee99 wants to merge 13 commits intoapache:mainfrom
Conversation
…processing Signed-off-by: lipan02 <pandali.kk@qq.com>
…processing Signed-off-by: lipan02 <pandali.kk@qq.com>
Signed-off-by: lipan02 <pandali.kk@qq.com>
chaokunyang
reviewed
Jan 27, 2026
chaokunyang
reviewed
Jan 27, 2026
chaokunyang
reviewed
Jan 27, 2026
|
|
||
| // Write varint64 with ZigZag encoding inline | ||
| // Returns number of bytes written | ||
| static inline uint32_t WriteVarint64ZigZag(uint8_t *arr, int64_t value) { |
Collaborator
There was a problem hiding this comment.
I'm refactoring fory cython Buffer to forward numeric read/write into c++ Buffer, you can use c++ Buffer.write_varint64 directly after I finsihed the refactor later
Collaborator
There was a problem hiding this comment.
WriteVarint64ZigZag should be removed now, python use same C++ Buffer for write/read ints
Contributor
Author
There was a problem hiding this comment.
let me take a look.
2 tasks
chaokunyang
added a commit
that referenced
this pull request
Jan 27, 2026
## Why? - Python Cython buffer implementation duplicated C++ buffer logic and error handling. - Centralizing buffer reads/writes in the C++ buffer reduces duplication and keeps behavior aligned. ## What does this PR do? - Refactors `python/pyfory/buffer.pyx` to delegate reads/writes, varint/tagged encoding, and bounds checks to `fory::Buffer`. - Adds C++ `Buffer` int24 helpers and exposes missing buffer APIs/errors to Cython via `libutil.pxd`. - Introduces Python error mapping helpers and updates row/collection code to pass C++ buffer pointers correctly. ## Related issues Closes #3218 #3216 #1017 ## 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
Signed-off-by: lipan02 <pandali.kk@qq.com>
Signed-off-by: lipan02 <pandali.kk@qq.com>
chaokunyang
reviewed
Jan 27, 2026
chaokunyang
reviewed
Jan 27, 2026
Signed-off-by: lipan02 <pandali.kk@qq.com>
Signed-off-by: Pan Li <pandalee@ustc.edu>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add C++ batch processing functions for int64 sequence serialization/deserialization to improve performance.
Changes:
Fory_PyInt64SequenceWriteToBufferandFory_PyInt64SequenceReadFromBufferin C++ layer_write_intand_read_intinCollectionSerializerfor list/tuple typesPerformance
Benchmark results on 1M integers:
Run benchmark:
Test plan