Skip to content

geotiff: eager BigTIFF auto-detection uses exact IFD overhead#1906

Merged
brendancol merged 1 commit into
mainfrom
issue-1905
May 15, 2026
Merged

geotiff: eager BigTIFF auto-detection uses exact IFD overhead#1906
brendancol merged 1 commit into
mainfrom
issue-1905

Conversation

@brendancol
Copy link
Copy Markdown
Contributor

Summary

Closes #1905.

Test plan

  • pytest xrspatial/geotiff/tests/test_eager_bigtiff_overhead_exact_1905.py — 7 new tests pass (estimate exactness, overflow heap accounting, BigTIFF promotion path, classic-fits-comfortably path)
  • pytest xrspatial/geotiff/tests/ -k "writer or to_geotiff or bigtiff or streaming or assemble" — 453 passed, no regressions
  • Full xrspatial/geotiff/tests/ suite passes (2869 tests; 2 pre-existing failures on main are unrelated)

Replace the fixed 1 KB-per-IFD fudge in ``_assemble_tiff`` with
``_compute_classic_ifd_overhead``, the same helper the streaming
writer uses. The previous estimate under-promoted to BigTIFF near
the 4 GiB boundary when ``gdal_metadata_xml`` or ``extra_tags``
pushed the overflow heap past 1 KB.

Closes #1905.
Copilot AI review requested due to automatic review settings May 15, 2026 05:26
@github-actions github-actions Bot added the performance PR touches performance-sensitive code label May 15, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Replaces the eager writer's fixed 1 KB-per-IFD fudge overhead with an exact computation via _compute_classic_ifd_overhead, the same helper used by the streaming writer. This eliminates a late struct.error failure mode near the 4 GiB classic-TIFF boundary when large gdal_metadata_xml or extra_tags push the overflow heap past 1 KB, and harmonizes BigTIFF promotion across eager and streaming paths.

Changes:

  • In _assemble_tiff, replace the num_levels * (2 + 12 * max_tags_per_ifd + 4 + 1024) estimate with sum(_compute_classic_ifd_overhead(tags) for tags in ifd_specs).
  • Add regression tests covering overhead exactness, strip-offset accounting, promotion under monkey-patched overhead, classic-fits sanity, and round-trip with large gdal_metadata_xml.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
xrspatial/geotiff/_writer.py Use exact IFD overhead from _compute_classic_ifd_overhead for BigTIFF auto-detection.
xrspatial/geotiff/tests/test_eager_bigtiff_overhead_exact_1905.py New tests verifying exact overhead and BigTIFF promotion behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@brendancol brendancol merged commit 1d65f9c into main May 15, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance PR touches performance-sensitive code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

geotiff: eager BigTIFF auto-detection uses rough 1 KB-per-IFD overflow fudge

2 participants