Single-pass pickle decode and memoize schema-override dict#299
Draft
yfukai wants to merge 1 commit into
Draft
Conversation
unpickle_bytes_columns now accepts schema_overrides and produces typed columns in one row-pass. _cast_array_columns is removed and the redundant second/third rebuilds at SQLGraph callsites disappear. _polars_schema_override and the new _attr_dtype_overrides helper are memoized per table-class and invalidated alongside the existing _node_attr_schemas_cache / _edge_attr_schemas_cache. Benchmark (benchmarks/perf_pickle_and_overrides.py, 200 frames x 100 nodes x 32x32 masks, 100 filtered node_attrs(50 ids each) calls): metric baseline after schema-override recomputes (100 calls) 101 1 pl.Series Object/Binary builds (Scenario A) 202 101 wall ms (Scenario A) ~382 ~333 (Note: pl.Series counter excludes the map_elements FFI row-pass that goes through Polars internals and never enters pl.Series.__init__; that pass is also eliminated in the patched code.) Public API: unpickle_bytes_columns kwarg is backwards-compatible (schema_overrides defaults to None). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #299 +/- ##
==========================================
+ Coverage 87.75% 87.82% +0.07%
==========================================
Files 57 57
Lines 4947 4961 +14
Branches 872 874 +2
==========================================
+ Hits 4341 4357 +16
+ Misses 381 379 -2
Partials 225 225 ☔ View full report in Codecov by Sentry. 🚀 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.
Human summary
Another performance improvement in SQL fetch. I'll reivise this before making it open.
Claude summary
unpickle_bytes_columns now accepts schema_overrides and produces typed columns in one row-pass. _cast_array_columns is removed and the redundant second/third rebuilds at SQLGraph callsites disappear. _polars_schema_override and the new _attr_dtype_overrides helper are memoized per table-class and invalidated alongside the existing _node_attr_schemas_cache / _edge_attr_schemas_cache.
Benchmark (benchmarks/perf_pickle_and_overrides.py, 200 frames x 100 nodes x 32x32 masks, 100 filtered node_attrs(50 ids each) calls):
metric baseline after
schema-override recomputes (100 calls) 101 1
pl.Series Object/Binary builds (Scenario A) 202 101
wall ms (Scenario A) ~382 ~333
(Note: pl.Series counter excludes the map_elements FFI row-pass that goes through Polars internals and never enters pl.Series.init; that pass is also eliminated in the patched code.)
Public API: unpickle_bytes_columns kwarg is backwards-compatible (schema_overrides defaults to None).