Skip to content

Publish path densifies GeoGrid values() every cycle — sparse iteration follow-up to #21 #65

Description

@rolker

Context

Part of #21 (live GeoMapSheet draft-tile persistence + Cartesian→geographic migration).

The migrated publish path (geoMapSheetToGridMap in grid_projection.cpp)
iterates each grid's cells via GeoGrid::values(), which returns a dense
std::vector<DepthAndUncertainty> in CellAreaIterator order (up to
960×960 ≈ 920k entries per grid), NaN-filled for empty cells.

Problem

On each publish cycle the node:

  1. allocates a dense values() vector per grid (most cells typically NaN for a
    sparse survey patch), and
  2. walks the full dense set, running residual per-cell lat/lon→ECEF trig only on
    the finite cells but still paying the allocation + full-length scan.

At GGGS scale on the live publish cadence this is heavier than necessary. The
per-cell ECEF conversion is also the residual cost the plan-review flagged once
the per-cell TF lookup was removed.

Proposed fix

  • Provide / use a sparse accessor that yields only populated (CellIndex, DepthAndUncertainty) pairs, avoiding the dense allocation and full scan.
  • Optionally hoist the ECEF conversion or precompute per-row factors where the
    longitudinal span is constant within a grid.

Acceptance

  • Publish-path allocation no longer scales with total cell count, only with
    populated cells.
  • A micro-benchmark or timed test showing reduced per-publish cost on a
    representative survey patch; published grid output unchanged (equivalence test
    still green).

Authored-By: Claude Code Agent
Model: Claude Opus 4.8

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions