GTiff: improve performance of internal overview creation (fixes #1442) #1516
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Or multiple level external overview.
This was a long standing problem. The issue was that each overview level (this
also applies to mask) within a same TIFF file shared the same TIFF* handle.
When switching between overviews, the handle had to be reset to point to a
new TIFF IFD, and reloading of the StripOffset/StripByteCount/TileOffset/TileByteCount
was done. For really big files, those can be several ten to hundred of MB large.
Now, each overview (mask) owns its own TIFF handle, sharing the underlying file
pointer though. Some care is needed in the tifvsi layer regarding some write
optimizations, as well when creating overviews, we must take care of forcing
a reload of the main TIFF handle so that the in-memory TIFF structure points
correctly to the next IFD.
Test case:
With this improvement:
$ cp large.tif input.tif; time gdaladdo input.tif 2 4 8 --debug on
real 0m54.913s
Without:
real 3m0.175s