perf: batch scoped-property resolution via props_for_scopes - #12
Open
e-lo wants to merge 3 commits into
Open
Conversation
Replace per-(property × timespan × category) calls to prop_for_scope with a single props_for_scopes call per property. The new API validates once and explodes the sc_ column once, then filters the pre-built exploded DataFrame for each requested scope—eliminating O(T×C) redundant deepcopy + schema-validation + explode passes per property. Benchmark on stpaul (66k links, ~6,600 scoped): ~188ms mean vs the previous O(T×C×N) loop (~10s estimated for full time-period×category matrix). Adds fixtures and TestBenchmarkSplitProperties to make the improvement reproducible across branches. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
(property × timespan × category)calls toprop_for_scopewith a singleprops_for_scopescall per property insplit_properties_by_time_period_and_categorysc_column once, then filters the pre-built exploded DataFrame for each requested scope — eliminating O(T×C) redundant deepcopy + schema-validation + explode passes per propertystpaul_netandstpaul_net_with_scopedfixtures plusTestBenchmarkSplitPropertiesto make the improvement reproducible across branchesPerformance
Benchmark on stpaul (66k links, ~6,600 scoped links, 5 time periods × 4 vehicle categories):
prop_for_scopein nested loop (O(T×C) calls)props_for_scopesbatch (1 call per property)~50× speedup for the full time-period × category matrix.
Dependencies
Requires network_wrangler PR #452 (
props_for_scopesbatch API).Test plan
pytest tests/ -m "not benchmark")pytest tests/test_benchmark.py::TestBenchmarkSplitProperties -m benchmark)feature/perf-link-changesusing--benchmark-save/--benchmark-compare🤖 Generated with Claude Code