Davis-Zhang-Onehouse opened a new pull request, #20797: URL: https://github.com/apache/hudi/pull/20797
### Describe the issue this Pull Request addresses issue: #20796 Part of #20683, RFC-118 (#20684). Stacked on #20733: review only the last commit. Until the PRs below it merge, this PR also shows their commits. Data prep reads each source object from object storage, and each task waits for the download of a file before preparing it. On object stores the download is a large part of a small file's prep time, so a task spends much of its time idle. This PR overlaps the download of the next file with the preparation of the current one, without changing any output row. ### Summary and Changelog Prep tasks download the next source file while they prepare the current one, with the same output rows. - `SourcePrefetcher` (`prep`): one background thread per task reads the next whole OUT_OF_LINE object (no range, listed size within the bound) while the current file is prepared. A task holds at most two such buffers. A read ahead is only a cache: a skipped row, a failed read, or an object whose bytes do not match its listed size is opened by the task itself with the same failure classification; a JVM error on the read-ahead thread fails the task, and a confirmed source-version change is reported for that file. Closing cancels the read in flight; the thread ends when idle. - `PreprocessingIterator`: takes the next row early to start its read ahead, only for a row that names a preprocessor and a blob, and serves the current file from the cached bytes when present. - `FilePreprocessor#prefetchLimit`: an object is not read ahead when its preprocessor would refuse it by size (`ImageInputPreprocessor` also bounds images by `hoodie.unstructured.embedding.prep.image.header.max.bytes`; `VideoFramePreprocessor` and `PdfFilePreprocessor` by their input limits). - `BlobBytesSource#checkedVersionCheck`: a cached object keeps the source-version check of the read that fetched it, so the task still sends the status request that confirms the object did not change. - `PrepRound`: passes each task the read-ahead bound, which for a job that preps video is what `VideoFrameHeapCheck#admittedPrefetchBytes` admits beside the frame decodes, and opens sources with `BlobBytesSource.PREP_SOURCE_READAHEAD_BYTES`. `EmbeddingTableTransformer` validates `hoodie.unstructured.embedding.prep.prefetch.max.bytes` at start, and that key's documentation describes the whole-object cache. - Tests: `TestPreprocessingIteratorPrefetch`, `TestSourcePrefetcherLifecycle`, and additions to `TestReadOptimizationFailures`, `TestPrepRoundOutputRows`, `TestPreprocessingIteratorLifecycle` and `TestReturnedIteratorOwnership`. 6 test files. Existing files touched: none; all changes are in the unstructured packages and their tests. No code was copied from other projects. ### Impact Performance: the next file's download overlaps the current file's preparation. Output rows are unchanged. Memory per prep task grows by up to two read-ahead buffers (8 MiB each by default), bounded for video jobs by the heap check. No new config keys. ### Risk Level medium: the diff adds a background read thread per prep task and hands cached bytes to the preprocessors. Covered by `TestPreprocessingIteratorPrefetch`, `TestSourcePrefetcherLifecycle` and `TestReadOptimizationFailures`; module compile, checkstyle and RAT on JDK 11 / Spark 3.5 / Scala 2.12; GitHub Java CI runs on the stack tip. ### Documentation Update The documentation of `hoodie.unstructured.embedding.prep.prefetch.max.bytes` (`.withDocumentation`) describes the read ahead. ### Contributor's checklist - [x] Read through [contributor's guide](https://hudi.apache.org/contribute/how-to-contribute) - [x] Enough context is provided in the sections above - [x] Adequate tests were added if applicable -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
