Speed up Python GraphBinary deserialization (3.7)#3504
Open
kirill-stepanishin wants to merge 1 commit into
Open
Speed up Python GraphBinary deserialization (3.7)#3504kirill-stepanishin wants to merge 1 commit into
kirill-stepanishin wants to merge 1 commit into
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 @@
## 3.7-dev #3504 +/- ##
=============================================
+ Coverage 75.49% 75.52% +0.02%
- Complexity 13161 13175 +14
=============================================
Files 1092 1093 +1
Lines 67208 67226 +18
Branches 7391 7396 +5
=============================================
+ Hits 50742 50770 +28
+ Misses 13837 13833 -4
+ Partials 2629 2623 -6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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 WebSocket 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.