Speed up Python GraphBinary deserialization#3493
Open
kirill-stepanishin wants to merge 2 commits into
Open
Conversation
Assisted-by: Claude Code:claude-opus-4-8
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3493 +/- ##
============================================
- Coverage 76.35% 76.11% -0.25%
- Complexity 13424 13861 +437
============================================
Files 1012 1030 +18
Lines 60341 62712 +2371
Branches 7075 7338 +263
============================================
+ Hits 46076 47731 +1655
- Misses 11548 12018 +470
- Partials 2717 2963 +246 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
kenhuuu
reviewed
Jun 30, 2026
Contributor
|
VOTE +1 |
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.
The GraphBinary reader built a
DataTypeenum member from the type byte for every object it decoded. That per-object enum construction heavily degrades deserialization performance on large result sets.The reader now builds a
{type code: deserializer}lookup table once up front and dispatches on the raw integer instead, avoiding per-object enum construction. Behavior is unchanged: an unknown type code still raisesValueError("... is not a valid DataType").Performance
Benchmarked on two cross-region EC2 instances (server in US-EAST-2, client in US-WEST-2) to capture realistic network latency, against the Modern graph over GraphBinary V4 on Python 3.11. Each query was run with and without this change, alternating back to back across 3 sweeps, reporting the median.
g.V().repeat(both()).times(12)(~200k results)g.V()(6 results)The improvement is significant on large result sets, where per-object deserialization cost dominates, and scales with the number of objects returned.