Skip to content

perf(ogc): faster page parsing and chunk combination#345

Open
thodson-usgs wants to merge 3 commits into
DOI-USGS:mainfrom
thodson-usgs:perf/chunk-client-side
Open

perf(ogc): faster page parsing and chunk combination#345
thodson-usgs wants to merge 3 commits into
DOI-USGS:mainfrom
thodson-usgs:perf/chunk-client-side

Conversation

@thodson-usgs

Copy link
Copy Markdown
Collaborator

Summary

Two client-side performance improvements to the OGC page-parsing and chunk-combination paths, identified through profiling the parallel_chunks fan-out code.

Changes

  1. Replace pd.json_normalize with pd.DataFrame in _get_resp_data (shaping.py)

    OGC API feature properties are flat dictionaries — json_normalize's recursive nesting support is unnecessary overhead. Direct pd.DataFrame construction is 2.4× faster per page (3.2 ms → 1.35 ms on 2500-feature pages).

  2. Skip drop_duplicates when the plan has no filter axis (planning.py, chunking.py)

    List-axis chunks (the common parallel_chunks case — splitting on monitoring_location_id, parameter_code, etc.) produce non-overlapping partitions by construction. Only filter-axis chunks (splitting on CQL OR clauses) can overlap. _combine_chunk_frames now accepts a dedup flag and ChunkedCall._combine_raw passes dedup=self.plan.has_filter_axis2.7× faster combine (3.4 ms → 1.25 ms on 52k-row results) for the common case.

Impact

For a typical 32-chunk query fetching 32 pages (~52k rows):

  • Page parse savings: ~1.85 ms × 32 pages = ~59 ms saved
  • Combine savings: ~2.2 ms saved
  • Total: ~61 ms less client-side overhead per query

These are additive to the network-latency savings parallel_chunks already provides.

Testing

All 574 tests pass. No behavioral change — list-axis chunks were never producing duplicates (the dedup was a no-op); filter-axis chunks still dedup as before.

Add parallel_chunks(n) so large Water Data and NGWMN queries can split
into more independently paginated sub-requests while preserving the
conservative byte-limit-only default.

Cap optional fan-out across all chunk axes, validate positive integer
inputs, export the helper publicly, and document usage, tradeoffs, and
benchmark results. Add planner, context, and integration coverage.
- Replace pd.json_normalize with pd.DataFrame in _get_resp_data.
  OGC API properties are flat dicts; json_normalize's recursive
  flattening is unnecessary overhead (~2.4× faster per page:
  3.2 ms → 1.35 ms on 2500-feature pages).

- Skip drop_duplicates in _combine_chunk_frames when the plan has
  no filter axis. List-axis chunks produce non-overlapping
  partitions, so dedup is pure overhead in the common
  parallel_chunks case (~2.7× faster combine: 3.4 ms → 1.25 ms
  on 52k-row results).

- Add ChunkPlan.has_filter_axis property to distinguish plans that
  need dedup (filter-axis overlap possible) from those that don't
  (list-axis only).
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