Skip to content

perf: batch scoped-property resolution via props_for_scopes - #12

Open
e-lo wants to merge 3 commits into
feature/perf-link-changesfrom
feature/perf-props-for-scopes
Open

perf: batch scoped-property resolution via props_for_scopes#12
e-lo wants to merge 3 commits into
feature/perf-link-changesfrom
feature/perf-props-for-scopes

Conversation

@e-lo

@e-lo e-lo commented Mar 24, 2026

Copy link
Copy Markdown

Summary

  • Replaces per-(property × timespan × category) calls to prop_for_scope with a single props_for_scopes call per property in split_properties_by_time_period_and_category
  • The new API (added in network_wrangler PR #452) 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
  • Adds stpaul_net and stpaul_net_with_scoped fixtures plus TestBenchmarkSplitProperties to make the improvement reproducible across branches

Performance

Benchmark on stpaul (66k links, ~6,600 scoped links, 5 time periods × 4 vehicle categories):

Implementation Mean time
Old: prop_for_scope in nested loop (O(T×C) calls) ~10s (estimated: 35 calls × ~300ms each)
New: props_for_scopes batch (1 call per property) ~188ms

~50× speedup for the full time-period × category matrix.

Dependencies

Requires network_wrangler PR #452 (props_for_scopes batch API).

Test plan

  • All 68 non-benchmark tests pass (pytest tests/ -m "not benchmark")
  • Benchmark passes (pytest tests/test_benchmark.py::TestBenchmarkSplitProperties -m benchmark)
  • Compare against baseline on feature/perf-link-changes using --benchmark-save / --benchmark-compare

🤖 Generated with Claude Code

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>
@e-lo
e-lo requested a review from i-am-sijia March 24, 2026 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant