Skip to content

perf(data): opening a file looks up its code's shift only for a note that needs it (#1227) - #3008

Merged
Mavrick-F merged 1 commit into
opengeos:mainfrom
Mavrick-F:perf/open-shift-note
Nov 26, 2026
Merged

Mavrick-F merged 1 commit into
opengeos:mainfrom
Mavrick-F:perf/open-shift-note

Conversation

@Mavrick-F

@Mavrick-F Mavrick-F commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

Summary

A profile of the benchmark's render_view task showed that opening the GeoPackage spent about a third of a small run's time on a note it then didn't give. The note says that a WGS 84 shift a definition gives can't be applied, and names the EPSG code whose own shift is used in its place. dropped_note worked that code out (code_with_shift) before it looked for such a shift. The first time it runs, finding a code's shift lists the whole EPSG catalog (epsg_catalog_codes), about 33 ms on a quiet box.

dropped_note_by now takes the code as a closure and calls it only when there is a shift to report. The notes are worded exactly as before.

Output

The PNGs from the cases below are byte-identical to main's.

Timing

Runs alternated main (dde41e0) and this branch, 9 runs each after a warm-up, through the host queue at a load average of about 7. Medians:

Case main wall / CPU This PR wall / CPU
Start-up: add a 300 KB GeoPackage, export it to FlatGeobuf 0.045 s / 0.044 s 0.012 s / 0.011 s
render_view, 19,283 buildings (tier S) 0.201 s / 0.293 s 0.151 s / 0.259 s
render_view, 100,000 buildings (tier GA, loaded) 0.501 s / 0.937 s 0.466 s / 0.903 s
render_view, the same file streamed 0.665 s / 1.033 s 0.638 s / 0.975 s

render_view adds polygons.gpkg, zooms to [-86.82, 36.13, -86.74, 36.19] on a blank basemap and runs share.exportMap at 1600 × 900.

Where the 100,000-building view's time goes now, from a profile:

Step Time
Reading the whole GeoPackage, one thread ~0.12 s
Thinning and projecting the layer ~0.12 s
Recording each feature's path for the bands, one thread ~0.10 s
Rasterising ~0.20 s, on three to eight threads
PNG encoding, one thread ~0.07 s

A layer in a projected system still lists the catalog once, because catalog_proj4 checks a code's membership that way. Opening a UTM GeoPackage went from about 0.07 s to 0.05 s of CPU. That's a separate change.

Surfaces

The change is in rustgis-data, where every definition with a shift is read: GeoPackage, FileGDB, Zarr and LiDAR coordinate systems, and a system typed into a command. So it reaches the desktop app, the browser, the command line, Python and the phone alike. Nothing saved changes, and nothing new is held.

Testing

  • The tests that pin both forms of the note still pass: the GeoPackage notes naming EPSG:23031's own shift (source::tests), FileGDB's with an ESRI code, LiDAR's and Zarr's with no code. That is 281 rustgis-data tests filtered on those modules, and the raster::wkt tests.
  • The fork's CI ran the full gate. cargo fmt --all --check and the private preflight passed.

UI evidence

No visible UI change.

Related issue

Part of #1227.

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of EPSG replacement information for raster shift notes. Replacement details are now resolved only when an unapplied shift is present, avoiding unnecessary lookups when no shift needs to be recorded. This keeps shift-note handling more efficient without changing the behavior users see when a shift is pending.

…that needs it (opengeos#1227)

The note on a WGS 84 shift a definition gives but RustGIS can't apply named the
EPSG code whose own shift is used in its place. That code was worked out before
looking for such a shift, and finding a code's shift lists the whole EPSG
catalog the first time: about 60 ms, most of what opening a small GeoPackage
took. It is now worked out only when there is a shift to say.
@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The note-generation path now defers resolving the EPSG replacement name until an unapplied-shift mark is found. The helper now returns an owned string for that name.

Changes: EPSG replacement notes

Layer / File(s) Summary
Defer replacement-name lookup
crates/data/src/raster/wkt.rs
dropped_note_by now accepts a closure and invokes it only when an unapplied-shift mark exists. unapplied_note_beside returns an owned String for the deferred name.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Refactor

Suggested reviewers: pawelkra, giswqs

Merge Risk: Minimal · up to 2f30c

This change avoids an unnecessary EPSG catalog lookup when generating unapplied-shift notes, with the note wording unchanged. No actionable merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: opening a file now looks up a code's shift only when a note needs it. It is specific, follows the conventional commit form, and matches the raw summary's deferred clos…
Description check Passed The description follows the template's main sections: Summary, Testing, UI evidence, and Related issue. The Summary explains the change and the reason for it, with benchmark context. Testing lists the…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: opening a file now looks up a code's shift only when a note needs it. It is specific, follows the conventional commit form, and matches the raw summary's deferred closure change in dropped_note and dropped_note_by. The author's description and objectives also describe this same change as the primary focus.

Full details: Description check

Explanation

The description follows the template's main sections: Summary, Testing, UI evidence, and Related issue. The Summary explains the change and the reason for it, with benchmark context. Testing lists the tests run and the CI gate. UI evidence states 'No visible UI change.', which the template allows when there is no visible change. Related issue says 'Part of #1227.' The template's placeholder comments were removed, which is acceptable. The description is thorough and specific.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit watched the shift marks glow
And saved the name until needed so
A note now waits for marks to appear
Then writes the name in owned strings clear
The rabbit hops through WKT with cheer

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 1c93c4a0-a721-48a0-a152-6275ca5dc2ca
Commits

Reviewing files that changed from the base of the PR and between 336a178 and 2f30c1d.

Files selected for processing: 1

  • crates/data/src/raster/wkt.rs

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 2 remain after this review.

@Mavrick-F

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@github-actions

Copy link
Copy Markdown
Contributor

Code review

Bugs: None found. Confidence: high (about 90%). I could not compile or run the tests here, so this rests on reading the code.

  • The closure form returns the same value as the old eager argument. In dropped_note, code_with_shift(crs) is the same call. In unapplied_note_beside, then(|| name.to_owned()) yields the same Some(name) that then_some(name) gave.
  • by() runs at most once, and only inside the branch that already needed it. Nothing else in dropped_note_by depended on the eager value.
  • code_with_shift, epsg_proj4 and bundled_shift have no output side effects, so evaluating them later changes nothing a caller can see.
  • All three callers still type-check. unapplied_note keeps its signature, and unapplied_note_beside (crates/data/src/filegdb.rs:243) passes a &str name and def as before.

Security: None found. Confidence: high. The change is pure computation with no input handling added.

Performance: The change does what it claims: the EPSG catalog lookup is skipped when no unapplied shift needs a note. Confidence: medium-high. I could not run the timings. A note that does need a code still pays for epsg_catalog_codes on the first call, which the PR body says. set_aside_shift_note (wkt.rs:509) also calls code_with_shift eagerly, but only after a nonzero files_shift check, so it is not a regression.

Quality: One nit, left for the release quality pass. The existing tests pin the note text in both forms, but nothing asserts that the code lookup is skipped on clean input. A test could check that. Confidence: high that this is a nit, not a defect. Formatting is within max_width = 140.

AGENTS.md: No rule break found. Confidence: high. There are no unwrap, expect or panic calls, no unsafe, and no change to notices, saved files, commands, schema or the cfg(wasm32) split. The change is in rustgis-data, so the browser and phone builds get it through the same code path. No new command, surface or memory is involved.

Prior concerns: 0 threads existed on this PR, so none were left alone.

Inline comments: None posted. The only item is the nit above, which belongs in the release quality pass.

Change size

Compared with main (merge base dde41e0 to PR head 2f30c1d). Sizes are file sizes, not line counts.

Files changed Added Modified Removed Renamed Size before Size after Size change
1 0 1 0 0 356.3 KB 356.5 KB +181 B
Path Size before Size after Size change
crates/data/src/raster/wkt.rs 356.3 KB 356.5 KB +181 B

@github-actions

Copy link
Copy Markdown
Contributor

📖 Docs preview

Item Value
Preview https://preview.rustgis.app/pr-3008/
Web app https://preview.rustgis.app/pr-3008/app/
Commit 2f30c1d

GitHub Pages takes a minute or two to publish a new commit. Newer commits from the fork aren't published until a maintainer adds the preview label (once per commit).

@Mavrick-F

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Mavrick-F

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Mavrick-F
Mavrick-F added this pull request to the merge queue Nov 26, 2026
Merged via the queue into opengeos:main with commit 309ff9d Nov 26, 2026
28 checks passed
@Mavrick-F
Mavrick-F deleted the perf/open-shift-note branch November 26, 2026 06:24
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