Skip to content

Size for real data: whole-file reads, copies and extra full passes (2026-11 sweep) #2640

Open

Description

@giswqs

These came out of the 2026-11 release quality sweep, which went through review points deferred to the release quality pass (style, design or follow-up comments on merged pull requests). Points that were real but needed a design decision, a measurement or more than a small fix were grouped here instead of being fixed in place. Each section states the problem, where it lives on main, and the review comments it came from; tick the boxes as parts land, and split a section into its own issue when someone picks it up.

Related open issues: #1111 (large data tracking), #2431 (Undo steps holding full copies), #2482 (PDF memory), #2344 (network analysis tracking).

Avoidable whole-file reads and copies on the Add Data paths

layer.addData with crs/layer, and info.fileLayers even without them, read any .json up to io::MAX_BYTES (256 MB) whole to check for CityJSON before GeoJSON goes down the in-place streaming path, so a large GeoJSON is held whole and then streamed a second time. On the desktop, a GeoPackage upload is written to a temporary file only to count gpkg_contents, and then GpkgSource::open_bytes writes it again. The fix is a sniff-the-head check for CityJSON and counting on the connection open_bytes already opens.

Main paths: crates/engine/src/cmd/layer.rs (layer.addData), info.fileLayers, crates/data/src/source/gpkg.rs (open_bytes)

  • Sniff the head of a .json for CityJSON instead of reading it whole
  • Count GeoPackage contents on the open_bytes connection

From: #1300, #1300, #1300, #1665

Whole-file copies on Publish to Source and PDF reads

Publishing a Shapefile keeps several whole copies alive (the original, the step-2 rewrite, the staged bytes cloned into back, and the as_read/raw/read_back datasets), builds a geometry index keyed by each geometry's full JSON twice, and kept_column scans text columns twice. GeoJSON publish holds the whole source as serde_json::Value trees next to the datasets and allocates a String per number in canonical_numbers. A PDF raster read copies the whole file (up to 1 GiB) with bytes.to_vec() while the caller and the layer already hold it. Fixing these needs a design (drop or move buffers, a hash-keyed geometry index, Arc sharing through RasterLayer) and cargo xtask memory measurements.

Main paths: crates/data/src/publish.rs (~232, ~268, ~285, ~408), crates/data/src/io.rs (kept_column, ~3388), the PDF raster reader

  • Shapefile publish: drop buffers as soon as they are done, hash-keyed geometry index
  • GeoJSON publish: no whole Value tree beside the datasets
  • PDF raster read: share the bytes instead of to_vec()
  • Measure before and after with cargo xtask memory

From: #1958, #1958, #1958, #1958, #2036, #2352

Readers and writers that make a second full pass or copy

Shapefile export counts its losses (dbf_decimals, shapefile_keeps, the rounding check) in a separate full pass before the writer runs; that pass repeats the writer's keep and formatting rules (which can drift apart) and allocates a string for every Text cell, so the writer should count drops and rounding in its own loop. The XLS preflight check_compound copies the whole BIFF Workbook stream, up to 256 MiB, into a new Vec on every entry point; a random-access sector adapter would remove it.

Main paths: crates/data/src/io.rs (Shapefile export loss counting), crates/data/src/sheets.rs (check_compound, ~237)

  • Count Shapefile drops and rounding inside the writer loop
  • XLS preflight without a whole-stream copy

From: #1362, #1362, #1362, #1362, #1664

Render performance and memory follow-ups that need a measurement first

Several render paths were left as they are because the cost wasn't measured: the diagram anchor is recomputed per feature per frame; a translucent extruded (or flat see-through) layer is drawn on a full-viewport pixmap rather than one sized to its screen box; each zoom step over elevation tiles re-reads every water shore on the UI thread; the block wall unit search stays quadratic on a cache miss and doesn't check Cancel; MGRS square names are placed again on every redraw; grouped layout charts keep one entry per distinct value with no memory::planned bound. Time each on real-size data and fix those that show.

Main paths: crates/render/src/ (diagrams, extrusions, terrain water, block walls, MGRS grid), layout charts

  • Diagram anchor per feature per frame
  • Translucent layer pixmap sized to its screen box
  • Water shores re-read per zoom step on the UI thread
  • Block wall unit search: quadratic on a miss, no Cancel
  • MGRS square names placed on every redraw
  • Grouped layout charts: memory::planned bound

From: #1048, #1685, #1685, #2085, #2173, #2321, #2489

Overlay tools size their threads without the scratch-memory budget

Split and Clip size threads by memory::thread_scratch (threads_for_scratch), but outside_each (Erase/Identity/Union) and the other overlays still use plain parallel::threads_for (six call sites). With large polygons on many cores this can exceed the budget. Each overlay needs a per-item work estimate, as Clip's feature_work gives.

Main paths: crates/analysis/src/tools.rs (e.g. ~2156), crates/analysis/src/parallel.rs

  • Per-item work estimate and threads_for_scratch for each overlay

From: #1744

Network analysis at real-data scale

Route, Service Area and OD Cost Matrix share a cached graph; each route clones the whole nodes/adj (up to 256 MiB transiently, not counted against scratch), the cache stays process-wide after its project closes, the over-cap rebuild path has no test, and analysis.route still runs on the UI thread. Placing points scans every segment per point (no segment index), OD searches don't stop early for count or unreachable destinations, Service Area's segment pass runs on one thread, and the 10M-row OD cap bounds rows, not memory. Results are correct; this needs one design pass, probably with phase 2/3 of #2344.

Main paths: crates/analysis/src/network.rs

  • Endpoint overlay instead of cloning the graph per route
  • Drop the cache with its project; test the over-cap rebuild
  • Segment index cached with the graph
  • Early stop for OD count and unreachable destinations (component labels)
  • Service Area segment pass on several threads; memory-based OD cap
  • analysis.route off the UI thread

From: #2247, #2247, #2247, #2247, #2247, #2351, #2351, #2351, #2351, #2351, #2351, #2351, #2351, #2351

Lower priority

  • When a view can't be bounded in a local GeoJSON's coordinate system, each read parses every feature again (crates/data/src/source/geojson.rs ~274-282); it is documented and can be cancelled, but a byte/feature budget or a cached index would help large files. From: #1948, #1948

Activity

  1. added
    enhancement
    on Nov 22, 2026
  2. self-assigned this
    on Nov 22, 2026
  3. Mavrick-F commented on Nov 22, 2026

    @Mavrick-F
    Member

    I'll work through this in separate PRs so the import, publishing, reader/writer, rendering, overlay and network changes can be reviewed independently. I'll start with the Add Data paths, measure the render cases before choosing fixes, and tick the items as the PRs land. Larger network changes will be split along the graph/query and command-lifecycle boundaries as needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions