Skip to content

perf: fewer pixel copies when translating a GeoTIFF read by window - #597

Merged
giswqs merged 3 commits into
opengeos:mainfrom
nkarasiak:perf/translate-read-copies-squashed
Nov 6, 2026
Merged

giswqs merged 3 commits into
opengeos:mainfrom
nkarasiak:perf/translate-read-copies-squashed

Conversation

@nkarasiak

@nkarasiak nkarasiak commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

terrio translate of a large tiled GeoTIFF to a GeoTIFF copied each strip of pixels four more times than it needed, and wrote each copy into freshly mapped memory. This PR removes those copies in the shared read, translate and GeoTIFF row-writing code. Outputs are byte-for-byte the same as main's. It also fixes two error paths of GeoTiffWriter::write_rows: a refused call's mask rows were queued, and after a block row failed to be written, finish could still write a file missing it.

On one CPU, copying a 14412 x 14412 float32 Deflate GeoTIFF (256 x 256 tiles) to an uncompressed GeoTIFF takes 2.82 s instead of 4.63 s, with 438,000 minor page faults instead of 1.31 million. Peak memory goes down from 179 MB to 126 MB.

This PR is one squashed commit. The commit hashes cited below are from the reviewed history on nkarasiak/terrio:perf/translate-read-copies.

What changed

Each strip of a lazy translate went through these buffers (strips of 512 rows, 29.5 MB here):

Step Before After
Window read (LazyRaster::read_resampled) tiles placed into a window buffer, then copied into a second zeroed buffer the window buffer is returned when one part of the read holds every band
translate built a validity mask of the band (rayon), allocated a zeroed output, filled it with nodata, then copied pixel by pixel through BandView::get the mask is built only for rescaling or resampling; a strip copied whole (every band in order, same type, nearest, no scaling) is converted in its own buffer
GeoTiffWriter::write_rows (GeoTIFFs other than COGs) copied the given rows into a new pending buffer, then copied the block rows to encode into another encodes the rows given without copying them when none are pending and they end a block row or the raster; otherwise copies them as often as before or once less, never more

The commits:

  1. perf(translate): build the nodata mask only when rescaling or resampling uses it.

  2. perf(read): keep a read made in one part instead of copying it (resample_bands, read_resampled_by_band).

  3. perf(translate): convert the pixels of a dataset it owns where they are (translate_owned, used by translate_lazy and translate_lazy_to_file). The in-place pass applies the same conversion as the copy (convert_value(x as f64, type)), so a float32 signaling NaN is still quieted and UInt64 values still go through f64, as on main.

  4. perf(gtiff): write the rows given to a GeoTIFF where they are, as the COG writer already does (append_rows, slice_rows).

  5. fix(gtiff): refuse rows of another type before queueing their mask rows. On main, a refused call left its mask rows in front of the next call's, so the next rows were written with the wrong mask. The same commit keeps the writer's peak memory at main's when rows are pending and only some of them are written.

  6. fix(gtiff): an intermediate fix of commit 5's failure path, superseded by 7; it also documents that only a COG refuses a mask it has no room for.

  7. fix(gtiff): after a failed write, every row given so far stays pending with its mask rows, as on main (commit 5 had left pending_rows counting rows the emptied buffer no longer held, so the next call panicked). An empty write of another type is refused, as the COG writer refuses it.

  8. fix(gtiff) (899842c, with the test b2d29aa): once a block row of a GeoTIFF other than a COG fails to be written, the writer refuses more rows and finish. On main, finish counted the failed row's pending rows as written and wrote the directories, so the file could miss that row, and a retry could add the row's chunks after part of it. When rows of an earlier call are left pending (strips not aligned on the output's block rows), write_rows makes at most as many copies as main.

Other commits add the CHANGELOG entry and say which checks write_rows makes when rows is zero (# Errors). Two merges bring in main at e058043 (35f8271: fdeflate decoding, #577) and at 2518f3a (cf9e045: libdeflate writes and in-place raster writes, #589), and two update the CHANGELOG's fault figure measured after each.

The public translate(&RasterDataset, …) is unchanged; only callers that own the dataset take the in-place path. No public API changes. COGs written through GeoTiffWriter still copy their rows (RowWriter::Cog clones them); the COG outputs translate streams use CogWriter directly, which already took its rows as they are.

Measurements

terrio translate dem16.tif out.tif: 14412 x 14412, Float32, Deflate, 256 x 256 tiles, nodata -999999; output uncompressed, striped. One warm-up per tool, then 7 (11 on all cores) rounds in rotated order. Wall time is the median and range; user, sys, minor faults and peak RSS are medians. main is 2518f3a, the main this branch merges, for the one-CPU table; the all-core and per-case tables were measured against e058043, before #589, and were not rerun. Both builds use the default release profile. GDAL is gdal_translate 3.13.3.

One CPU (taskset -c 11, RAYON_NUM_THREADS=1, GDAL_NUM_THREADS=1), load average 0.99 (0.50–1.62, from background services; 32 cores):

Tool Wall (median, range) User Sys Minor faults Peak RSS
main@2518f3a 4.63 s (4.60–4.68) 3.20 s 1.44 s 1,310,619 179 MB
this branch 2.82 s (2.77–2.87) 2.24 s 0.55 s 437,602 126 MB
gdal_translate 3.13.3 2.14 s (2.13–2.16) 1.62 s 0.52 s 215,642 872 MB

All 32 cores (GDAL_NUM_THREADS=ALL_CPUS), against e058043, load average 2.88 (1.51–3.23):

Tool Wall (median, range) User Sys Minor faults Peak RSS
main@e058043 1.51 s (1.27–3.71) 6.03 s 2.77 s 1,477,762 216 MB
this branch 1.12 s (0.67–1.99) 3.91 s 1.63 s 616,186 158 MB
gdal_translate 3.13.3 0.53 s (0.49–0.57) 2.35 s 0.78 s 216,578 865 MB

All-core wall times spread widely for both terrio builds (the 830 MB output is written through the page cache).

Peak RSS (MB) and minor faults of other cases against main@e058043, all cores, median of 3 runs (10 alternating runs for the two Deflate outputs, whose peak varies most from run to run):

Case main RSS MB branch RSS MB main faults branch faults
translate dem16 215 156 1,476,476 616,478
translate --ot Float64 dem16 526 225 2,300,551 1,226,020
translate --srcwin 1000 2000 5000 3000 dem16 223 126 119,184 57,680
translate --outsize 50% 50% dem16 213 144 894,507 676,940
translate --outsize 3000 3000 -r bilinear dem16 343 323 876,967 848,820
translate --scale 0 4000 0 255 --ot Byte dem16 1224 1227 436,967 464,030
translate --compress DEFLATE dem16 228 (227–255) 201 (182–246) 1,563,549 704,744
translate --co TILED=YES --compress DEFLATE dem16 268 (232–315) 259 (254–262) 1,582,760 732,231
translate -f COG dem16 496 488 2,978,050 2,521,988
dem slope dem16 587 415 1,232,973 829,673
dem hillshade dem16 309 273 827,743 719,931
warp --t-srs EPSG:3857 USGS_1_n39w105.tif 240 219 158,537 146,061

The --scale case reads the whole raster and goes through the unchanged translate; its 3 MB is within the 0–3 MB more that the branch's binary uses for terrio info, which reaches none of the changed code, and its fault counts vary by about as much between runs (428,000–466,000).

Before the merge, with zlib-rs decoding, Deflate went from about 40% to about 61% of the single-CPU cycles; BandView::valid, BandView::get, SourceRead::read and fallible::filled zero-fills no longer appear in the profile's top entries.

Validation

  • Byte identity with main@2518f3a (cmp, with .aux.xml sidecars): 87 cases, also run against e058043 and 55963cc before the earlier merges; 5 more cases fail identically on both builds ("band 3 does not exist"). They cover translate of dem16 (default, --ot Float64, -b 1, integer and fractional --srcwin, --a-nodata, --a-ullr, --outsize 50%, bilinear --outsize, --scale, Deflate, tiled Deflate, COG), dem slope, dem hillshade and a warp to EPSG:3857, which use the same GeoTIFF row writer. They also cover the float-read test files in every sample type (UInt64, Int64 and NaN included, whole and windowed), the resampled-read test files (RGB with mask, RGBA, paletted, external overviews, sidecar mask; whole, --overview 0, average to half size, reordered bands), a VRT of mixed types, PNG output and input, and a COG.
  • New regression translate_in_place_converts_as_a_copy: the in-place path gives the bits the copy gives, for float32 with signaling and negative NaNs and a nodata pixel, and UInt64 past 2^53, with new nodata, bounds, explicit bands, type and window; it also checks which options keep the pixels' buffer. Red-checked: with the in-place conversion removed the signaling NaN differs, and with the in-place path disabled the buffer check fails.
  • failed_row_writes_stop_the_writer (gtiff_write tests): after a flush refused by the 4 GiB check, every row given so far is pending, and a later write and finish are refused even once the file is back within the limit. Red-checked: without the refusal, the later write succeeds. A failed last block row, whose rows are all given, makes finish fail (b2d29aa).
  • internal_masks_and_rows_written_in_order (georeferencing tests) now also checks that rows of another type are refused and that a refused call's mask rows are not kept: a refused call is made before every row write, with and without rows pending, and the files' masks are read back. Red-checked: it fails with main's writer (wrong mask).
  • cargo test -p terrio -p terrio-cli at the merge of 2518f3a: 2,953 passed, 0 failed, 54 ignored (146 test binaries). cargo fmt --check, workspace Clippy with -D warnings, the unsafe allowlist check, NOTICE and cargo check --target wasm32-unknown-unknown pass.
  • Python suite with bindings built from this branch (maturin develop, imported from this worktree): 5,892 passed, 736 skipped, 1 failed. The failure is test_compat_nodata_warnings_match_rasterios, a known false positive in this environment.
  • No unsafe code is added. No I/O code changes: window planning, chunk lists, prefetching and decoding are as on main, so the files opened and the bytes read are the same; only what happens to the pixels after decoding changed.

Limitations

  • Each strip is still read into a freshly allocated window buffer, which is first filled with nodata and then overwritten by the tiles. Reusing it across strips would remove most of the remaining read-side page faults, but it needs the buffer passed back from the writer thread.
  • Each 256 x 256 tile is still decoded into its own zeroed buffer before being copied into the window.
  • The GeoTIFF writer still turns each strip into per-chunk byte buffers before writing, even uncompressed.
  • On all cores, wall times vary widely from run to run for both builds, so the all-core medians are less precise than the user, sys and fault counts.
  • translate still converts UInt64 and Int64 values through f64, as main does, so values past 2^53 are rounded even by an identity translate; the in-place path keeps that, to stay byte-identical with main.
  • GDAL remains faster on one CPU (2.14 s).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Performance

    • Reduced pixel-buffer copying during eligible translations and resampled window reads.
  • Bug Fixes

    • Non-COG GeoTIFF row writes now reject mismatched pixel types before consuming mask data and require mask rows when the raster has a mask.
    • After a block-row write fails, further row writes and attempts to finish the raster now return errors.

A lazy translate to a GeoTIFF copied each strip of pixels several more
times than it needed, each copy into freshly mapped memory:

- translate builds the nodata mask only when rescaling or resampling
  uses it; a nearest-neighbour copy never read it.
- A resampled read made in one part (a window copy) keeps that part's
  buffer instead of placing it into a second zeroed one
  (resample_bands, read_resampled_by_band).
- translate converts the pixels of a dataset it owns where they are
  when the output copies all of it, every band in order, in its type,
  by nearest neighbour and not rescaled (translate_owned, used by
  translate_lazy and translate_lazy_to_file), with the conversion the
  copy applies: a float32 signaling NaN is still quieted and UInt64
  values still go through f64.
- GeoTiffWriter::write_rows encodes the rows given where they are when
  none are pending, and all of the pending rows without a further copy
  into a slab, as the COG writer does; it never copies more than
  before, and its peak memory stays at or below main's.

Two error paths of GeoTiffWriter::write_rows (GeoTIFFs other than COGs)
change: rows of another type, even none, are refused before their mask
rows are queued (a refused call left them in front of the next call's),
and once a block row fails to be written the writer refuses more rows
and finish, which could write a file missing it.

Outputs are byte-identical to main's: 87 translate, dem and warp cases
compared with cmp, over every sample type, masks, overviews, VRT, PNG
and COG. Translating a 14412 x 14412 float32 Deflate GeoTIFF to an
uncompressed GeoTIFF on one CPU takes 67% fewer page faults.
@coderabbitai

coderabbitai Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Explain Change →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 4 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

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: 9401e241-ccdc-4bd7-8edb-0e1870649e77
Commits

Reviewing files that changed from the base of the PR and between 917a244 and 504c04b.

Files selected for processing: 5

  • CHANGELOG.md
  • crates/terrio/src/drivers/gtiff_write.rs
  • crates/terrio/src/ops/translate.rs
  • crates/terrio/src/resampled_read.rs
  • crates/terrio/tests/georeferencing.rs

No actionable comments were generated in the recent review.

Walkthrough

Translation and resampled reads reuse pixel buffers in qualifying cases. GeoTIFF row writes validate row types and masks, preserve pending data after block-row write failures, and reject further writes and finish calls after such failures.

Changes: Raster read paths

Layer / File(s) Summary
Owned translation reuse
crates/terrio/src/ops/translate.rs, CHANGELOG.md
translate_owned reuses the source buffer when its options meet the specified conditions. Lazy reads use the owned path for resized datasets and whole reads. Tests compare its output with translate, including pixel bit patterns, nodata, and geotransform results.
Resampled read buffer reuse
crates/terrio/src/resampled_read.rs
The read paths keep the first buffer when it already contains all requested output pixels and bands. Otherwise, they continue assembling output buffers.

GeoTIFF row writes

Layer / File(s) Summary
Row validation and failed-write handling
crates/terrio/src/drivers/gtiff_write.rs, crates/terrio/tests/georeferencing.rs, CHANGELOG.md
write_rows checks the sample type before accepting zero rows and validates required mask rows. A block-row write failure retains supplied rows and makes later writes and finish fail. Tests cover type mismatches and failed partial and final block-row writes.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Refactor

Possibly related issues

  • opengeos/terrio#429: The issue covers lazy translation and resampled window reads, which are among the read paths changed here.

Possibly related PRs

  • opengeos/terrio#589: Adds streamed GeoTIFF completion; this PR changes when finish rejects a failed row write.
  • opengeos/terrio#437: Streams pixel and mask rows through GeoTIFF writers; this PR updates row and mask validation.

Suggested reviewers: giswqs

Merge Risk: Minimal · previous review 917a2

No actionable merge-blocking issue is established by the supplied evidence. The change is mergeable subject to normal checks.

Pre-merge checks: Passed 5

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title describes the reduction in pixel copies during window-based GeoTIFF translation. This is a main objective of the changes.
Docstring Coverage Passed Docstring coverage is 92.86% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentati…
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: Docstring Coverage

Explanation

Docstring coverage is 92.86% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 14 functions across 4 files. (1 skipped: 1 unsupported.)

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 checks the rows in flight,
And keeps the buffers tucked in tight.
It hops through reads with fewer copies,
Then guards failed writes from further choppies.
The raster rests, its pixels right.

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: 3b0af424-ba5b-4022-a1f6-5802714c66ce
Commits

Reviewing files that changed from the base of the PR and between 2518f3a and 917a244.

Files selected for processing: 5

  • CHANGELOG.md
  • crates/terrio/src/drivers/gtiff_write.rs
  • crates/terrio/src/ops/translate.rs
  • crates/terrio/src/resampled_read.rs
  • crates/terrio/tests/georeferencing.rs

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

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Code review

Bugs

  • No correctness defects found. I traced the in-place translate_owned path, the write_rows buffer handling (including the failure path and mask bookkeeping), and the resample_bands and read_resampled_by_band buffer reuse. The in-place path only applies when the output is a whole-raster, nearest, unscaled copy in the same type, so the pixels are the same as a copy would produce. (confidence: high)
  • Behaviour note, low confidence (~40%): TiffRows::write_rows sets failed on any error from flush_block_rows, including a compression error raised before any bytes are written. That refuses retries that would be safe. Inline comment posted at crates/terrio/src/drivers/gtiff_write.rs:2189.

Security

  • None found. The change adds no unsafe, and it does not touch I/O or input parsing.

Performance

  • The copy reduction is real. The in-place conversion adds one parallel read-modify-write pass per band, which is cheaper than an allocation plus a copy. Converting identity types still costs that pass, but it is needed to keep signaling-NaN and UInt64 results byte-identical. (confidence: medium)
  • translate_owned computes geometry() once for the eligibility check, and translate_pixels computes it again. The cost is negligible. (confidence: high)

Quality

  • The read_resampled_by_band condition band.len() == read.bands.len() * n is equivalent to read.bands.len() == 1. It mirrors the check in resample_bands, so it is acceptable as written. (confidence: high)
  • The write_rows doc now says a zero-row call still checks the data type. That is intended and is covered by the georeferencing test.
  • The failed flag returns InvalidData, while a type mismatch returns InvalidArgument. That split is reasonable.
  • The PR description lists commits 1 to 8 and their hashes, but the PR is a single squashed commit. Those hashes are not on this branch, so reviewers cannot check the history it describes. The description should say where that history lives or drop the list.
  • The CHANGELOG entry is a long paragraph that mixes a perf change with a bug fix. Splitting it into a Performance bullet and a Fixed bullet would be easier to scan.

CLAUDE.md (AGENTS.md)

  • Regressions cover the behaviour changes: translate_in_place_converts_as_a_copy, failed_row_writes_stop_the_writer, and the extended internal_masks_and_rows_written_in_order. Identifiers are named after behaviour. No GDAL reference or SPDX/NOTICE change is needed, since no code was ported. The PR does not state whether scripts/conformance.py needs a new case; the byte-identity checks against main cover the behaviour, but the PR should say so.

Change size

Compared: the whole PR against main (merge base 2518f3a to PR head 917a244).

Measure Value
Files changed 5 (added 0, modified 5, removed 0, renamed 0)
Size before 381 KB
Size after 389 KB
Total size change +8.4 KB
Path Before After Change
crates/terrio/src/ops/translate.rs 45.1 KB 49.5 KB +4.4 KB
crates/terrio/src/drivers/gtiff_write.rs 200 KB 203 KB +2.4 KB
CHANGELOG.md 60.3 KB 61.0 KB +776 B
crates/terrio/src/resampled_read.rs 64.0 KB 64.5 KB +446 B
crates/terrio/tests/georeferencing.rs 11.2 KB 11.6 KB +389 B

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Code review

I found no correctness, security or performance problems in the changed code. I read the full diff and the surrounding code in gtiff_write.rs, translate.rs, resampled_read.rs and par.rs. I could not build or run the tests in this environment, so the findings below rest on reading the code.

Checked and found correct:

  • Failure paths in TiffRows::write_rows: on a failed block-row write, the pending rows and their mask rows are restored with consistent counts, and failed blocks later writes and finish.
  • Mask queueing: mask rows are queued only after the type and size checks pass, which fixes the wrong-mask bug the PR describes.
  • In-place translate: it is taken only when the output copies the whole dataset with the same type, nearest resampling and no scaling. Band metadata, nodata and GCPs do not read the pixel buffer, so emptying ds.raster.data is safe.
  • Shortcut in resample_bands: parts are band partitions (Part { bands: Range }), so a part that covers every band is the only part and skipping place is safe.
  • chunk_len / chunks_mut: the minimum chunk size is at least 1, so an empty output cannot panic.
  • Tests: the in-place test's expected buffer-reuse pattern matches the translate_owned predicate for the 2-band fixture.

Quality (nits):

  • gtiff_write.rs:2152: the final (Some(_), m) => m arm reads as if m could be None. Inline comment posted with a suggestion. Confidence: high.
  • translate.rs (translate_owned): geometry() is evaluated once to decide whether to copy and again inside translate_pixels. The cost is negligible, but the eligibility check duplicates some of translate_pixels' geometry logic. Confidence: medium.
  • CHANGELOG.md: the new entry is long for a changelog and repeats measurements that belong in the PR description. Confidence: medium.

Performance: no regression found. On the failure path, write_rows clones borrowed data into pending, as main did. That is not a regression.

Security: no issues found. The change adds no unsafe code and no input-handling surface.

CLAUDE.md (AGENTS.md): I checked identifier naming, the regression test, CHANGELOG placement, and that no ported code needs SPDX or NOTICE entries. No public API changed, so Python and JS bindings are unaffected. Not verified here: cargo fmt, Clippy, and the test suite. The PR reports these as passing.

Change size

Compared: the whole PR against main (merge base 6628390 to PR head 781a6c1).

Measure Value
Files changed 5 (added 0, modified 5, removed 0, renamed 0)
Size before 382.3 KB (391,509 B)
Size after 390.7 KB (400,060 B)
Total size change +8.4 KB
Path Before After Change
crates/terrio/src/ops/translate.rs 45.1 KB 49.5 KB +4.4 KB
crates/terrio/src/drivers/gtiff_write.rs 200.4 KB 202.8 KB +2.4 KB
CHANGELOG.md 61.6 KB 62.4 KB +0.8 KB
crates/terrio/src/resampled_read.rs 64.0 KB 64.5 KB +0.4 KB
crates/terrio/tests/georeferencing.rs 11.2 KB 11.6 KB +389 B

Comment thread crates/terrio/src/resampled_read.rs Resolved
Comment thread crates/terrio/src/ops/translate.rs Resolved
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Code review

I read the full diff and the surrounding code for the translate in-place path, the resampled read buffers, and the GeoTIFF write_rows state machine. I found no correctness, security, or performance defects. The points below are minor, and I posted the two that map to specific lines as inline comments.

Bugs

  • None found. I checked the in-place conversion against the copy path (convert_value(to_f64(x), type)), the copy-only guard in translate_owned (scale, exponent, resampling, bands, and whole-raster geometry), the write_rows error path (pending state, mask rows, and failed stickiness), and the pending_mask drain offsets. They are consistent.

Security

  • None found.

Performance

  • None significant. The copy elimination is sound. The only extra work is the duplicate geometry() call noted below.

Quality

  • Nit, high confidence (inline, translate.rs:209): translate_owned computes geometry() for the copy check, and translate_pixels recomputes it. With proj_win_srs set, transform_bounds runs twice. Passing the computed Geometry through would avoid this.
  • Nit, high confidence (inline, resampled_read.rs:380): the "keep the first part's buffer if it covers every band" logic duplicates read_resampled_by_band (line 276). It is correct, since a part whose length is bands * n must cover all bands. A shared helper would keep the two in step.
  • Nit, medium confidence: GeoTiffWriter::write_rows (gtiff_write.rs) now has several states (failed, pending, Cow joins). It is about 70 lines. Splitting out the flush-and-recover step would make it easier to maintain. The comments are accurate.
  • Nit, medium confidence: the CHANGELOG bullet is about nine lines and mixes a performance change with two fixes. Splitting it, or shortening it, would read better.

CLAUDE.md / AGENTS.md

  • Regression tests are present for each behavior change (translate_in_place_converts_as_a_copy, failed_row_writes_stop_the_writer, and the extended internal_masks_and_rows_written_in_order). Test names describe behavior. No new files, so no SPDX or NOTICE changes are needed. No public API change. The PR body states the validation evidence and limitations.
  • I did not run the test suite or the benchmarks. The validation claims in the PR body are the author's, and I have not re-verified them.

One inline comment I tried to place on translate.rs:224 was rejected because that line is outside the diff. I moved it to line 209.

Change size

Compared: the whole PR against main (merge base 6cf73c7 to PR head 504c04b).

Measure Value
Files changed 5 (added 0, modified 5, removed 0, renamed 0)
Size before 384 KB (393,056 B)
Size after 392 KB (401,607 B)
Total size change +8.4 KB
Path Before After Change
crates/terrio/src/ops/translate.rs 45.1 KB 49.5 KB +4.4 KB
crates/terrio/src/drivers/gtiff_write.rs 200.3 KB 202.7 KB +2.4 KB
CHANGELOG.md 63.2 KB 63.9 KB +776 B
crates/terrio/src/resampled_read.rs 64.0 KB 64.5 KB +446 B
crates/terrio/tests/georeferencing.rs 11.2 KB 11.6 KB +389 B

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.

2 participants