fix(table): AddFiles: close file after usage and parallelize#799
Open
starpact wants to merge 1 commit intoapache:mainfrom
Open
fix(table): AddFiles: close file after usage and parallelize#799starpact wants to merge 1 commit intoapache:mainfrom
starpact wants to merge 1 commit intoapache:mainfrom
Conversation
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.
Previously files are closed only after the whole iteration finishes:
iceberg-go/table/arrow_utils.go
Line 1372 in 55bdfbf
causing resource leak within a single
filesToDataFilesinvocation as the file holds an open S3 read stream:iceberg-go/io/gocloud/blob.go
Line 39 in 55bdfbf
A sample trace can demonstrate it clearly:

Besides, I also added parallelism to
AddFiles.Future improvements:
Parallelism partially "fixes" the performance issue of
AddFilesbut a more fundamental improvement is related to IO, currently for extracting Parquet metadata, the IO layer needs to:Seek, but the reader is never used(but still consumes quite some memory due to underlying buffering)A common trick is optimistically prefetching the footer(e.g. 512KB) to coleasce the above 3 requests. However, this requires leaking the IO abstraction, e.g. by determining the file format from the path and returning different implementations accordingly, which may require more discussions.