Repository navigation
Conversation
smounir
force-pushed
the
bugfix/fix-extract-from-large-source-file
branch
from
October 6, 2026 15:30
de22fa9 to
39bcb45
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fix OOM in
extractwhen the source is a local fileProblem
FileBucket.NewRangeReaderEtagallocated a[]byteof the full requested range length and filled it withReadAt. This makesextractallocate the entire merged range in memory.With
--overfetch=0on a contiguous zoom level,mergeRangescoalesces adjacent tiles into very large ranges. On a 2.9 TB source (--minzoom=18 --maxzoom=18), one of the 254 requests was ~218 GB, somakeslicefailed:GOMEMLIMITdoesn't help, because this is a single allocation. The HTTP and cloud bucket implementations already stream the response body, so onlyFileBucketwas affected.Fix
FileBucket.NewRangeReaderEtagnow returns anio.SectionReaderover the open file, wrapped in aReadCloserwhoseClose()closes the file. Memory use no longer depends on the range size.defer file.Close(). It was registered before the error check and would have closed the file before any streaming read.416branch ("Expected to read N bytes...") was unreachable, sinceReadAtalways returns an error when it reads fewer bytes than requested. It's removed.Tests
Added
TestFileBucketRangeReader, which covers: