You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by "yihua (via GitHub)" <gi...@apache.org> on 2026/09/27 23:06:44 UTC

[PR] perf(spark): reuse the row projection across files of a scan [hudi]

yihua opened a new pull request, #20110:
URL: https://github.com/apache/hudi/pull/20110

   ### Describe the issue this Pull Request addresses
   
   closes #20109
   part of #20064
   
   The row-based parquet read path (`Spark3xParquetReader` / `Spark4xParquetReader` through `ParquetSchemaEvolutionUtils`) generates an `UnsafeProjection` for every file, and `HoodieFileGroupReaderBasedFileFormat` generates its output projection per file or file slice. Spark caches the compiled class but regenerates the source and splits the expressions every time. On a 100-column schema nested to depth 6 that is about 9 ms per file and about 25% of the executor CPU of a COW snapshot scan (JFR), although most files of a scan need the same projection.
   
   ### Summary and Changelog
   
   New `UnsafeProjectionPool` (hudi-spark-client) keeps up to 16 idle projections per executor thread, keyed by every input of the generation: requested and partition schemas, the file's type changes, the session time zone and, when there is a type change, the task's registered SQL configs (task local properties such as `spark.sql.execution.id` are left out, so reuse works across queries). A lease takes the projection when the first row needs it and returns it only once its iterator has no more rows, so concurrent iterators and threads never share one. A projection that wrote a row over 1 MB is dropped instead of pooled, and idle projections are held through soft references. The Spark 3.3 to 4.2 parquet readers and the file group reader format's output and `projectIter` projections lease instead of generating; the projection is generated lazily, so a file read as batches generates none.
   
   Tests compare reused and freshly generated projections over type-changed files, schema on read, partition columns, pushed filters and MOR log files, hold uncopied rows of interleaved iterators through the real reader, and run union, joins, cache, sorts and limits over reused rows against runs without the pool.
   
   ### Impact
   
   Lower executor CPU for row-based scans: the per-file projection generation (about 7.6 ms per file in a micro-benchmark, about 9 ms in JFR on the wide schema) is paid once per thread and schema. No API, config or output change.
   
   ### Risk Level
   
   low. The reused projection is what the same inputs would generate, and rows keep the existing contract (valid until the next `hasNext`/`next` on their iterator). Memory per thread is bounded as above.
   
   Conflicts with open PRs, whichever merges second rebases:
   - #20090: in `ParquetSchemaEvolutionUtils` keep both sides (its `canReadVectorized`/`hasTypeChange`, then `leaseRowProjection`); in `HoodieFileGroupReaderBasedFileFormat` lease the output projection and pass `lease.asProjection` as the by-name projection of `FileGroupOutputProjection.create`, releasing the lease when the reader is exhausted.
   - #20077 (and #20078 on it) moves `projectIter`, `projectSchema` and `appendPartitionAndProject` into `HoodieFileGroupReaderFunction`; the leases move with them. #20085 conflicts on one import line.
   - After #20079 or #20102, the `[[getHadoopConfClone]]` scaladoc reference in `ParquetSchemaEvolutionUtils` must become `[[getHadoopAttemptConf]]`.
   
   ### Documentation Update
   
   none
   
   ### Contributor's checklist
   
   - [ ] Read through [contributor's guide](https://hudi.apache.org/contribute/how-to-contribute)
   - [ ] Enough context is provided in the sections above
   - [ ] 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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] perf(spark): reuse the row projection across files of a scan [hudi]

Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #20110:
URL: https://github.com/apache/hudi/pull/20110#issuecomment-5861619468

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "1f3ba80da64e0e3a00aceca6257905d9544c39cb",
       "status" : "SUCCESS",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=17320",
       "triggerID" : "1f3ba80da64e0e3a00aceca6257905d9544c39cb",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 1f3ba80da64e0e3a00aceca6257905d9544c39cb Azure: [SUCCESS](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=17320) 
   
   <details>
   <summary>Bot commands</summary>
     @hudi-bot supports the following commands:
   
    - `@hudi-bot run azure` re-run the last Azure build
   </details>


-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] perf(spark): reuse the row projection across files of a scan [hudi]

Posted by "voonhous (via GitHub) via commits" <co...@hudi.apache.org>.
voonhous closed pull request #20110: perf(spark): reuse the row projection across files of a scan
URL: https://github.com/apache/hudi/pull/20110


-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] perf(spark): reuse the row projection across files of a scan [hudi]

Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #20110:
URL: https://github.com/apache/hudi/pull/20110#issuecomment-5860796076

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "1f3ba80da64e0e3a00aceca6257905d9544c39cb",
       "status" : "UNKNOWN",
       "url" : "TBD",
       "triggerID" : "1f3ba80da64e0e3a00aceca6257905d9544c39cb",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 1f3ba80da64e0e3a00aceca6257905d9544c39cb UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     @hudi-bot supports the following commands:
   
    - `@hudi-bot run azure` re-run the last Azure build
   </details>


-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] perf(spark): reuse the row projection across files of a scan [hudi]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #20110:
URL: https://github.com/apache/hudi/pull/20110#issuecomment-5860786100

   ## [Codecov](https://app.codecov.io/gh/apache/hudi/pull/20110?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 80.40%. Comparing base ([`ead194c`](https://app.codecov.io/gh/apache/hudi/commit/ead194cce54829fae9113689a2f28772d0d76045?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`1f3ba80`](https://app.codecov.io/gh/apache/hudi/commit/1f3ba80da64e0e3a00aceca6257905d9544c39cb?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@             Coverage Diff              @@
   ##             master   #20110      +/-   ##
   ============================================
   - Coverage     80.40%   80.40%   -0.01%     
   + Complexity    34874    34868       -6     
   ============================================
     Files          2546     2546              
     Lines        142889   142871      -18     
     Branches      17374    17372       -2     
   ============================================
   - Hits         114895   114877      -18     
     Misses        20082    20082              
     Partials       7912     7912              
   ```
   
   | [Components](https://app.codecov.io/gh/apache/hudi/pull/20110/components?src=pr&el=components&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [hudi-common](https://app.codecov.io/gh/apache/hudi/pull/20110/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `83.97% <ø> (ø)` | |
   | [hudi-client](https://app.codecov.io/gh/apache/hudi/pull/20110/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `83.45% <ø> (ø)` | |
   | [hudi-flink](https://app.codecov.io/gh/apache/hudi/pull/20110/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `85.74% <ø> (ø)` | |
   | [hudi-spark-datasource](https://app.codecov.io/gh/apache/hudi/pull/20110/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `73.83% <ø> (-0.03%)` | :arrow_down: |
   | [hudi-utilities](https://app.codecov.io/gh/apache/hudi/pull/20110/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `78.17% <ø> (ø)` | |
   | [hudi-cli](https://app.codecov.io/gh/apache/hudi/pull/20110/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `70.05% <ø> (ø)` | |
   | [hudi-hadoop](https://app.codecov.io/gh/apache/hudi/pull/20110/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `70.99% <ø> (ø)` | |
   | [hudi-sync](https://app.codecov.io/gh/apache/hudi/pull/20110/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `76.02% <ø> (ø)` | |
   | [hudi-io](https://app.codecov.io/gh/apache/hudi/pull/20110/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `81.50% <ø> (ø)` | |
   | [hudi-timeline-service](https://app.codecov.io/gh/apache/hudi/pull/20110/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `83.06% <ø> (ø)` | |
   | [hudi-cloud](https://app.codecov.io/gh/apache/hudi/pull/20110/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `81.00% <ø> (ø)` | |
   | [hudi-kafka-connect](https://app.codecov.io/gh/apache/hudi/pull/20110/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `53.20% <ø> (ø)` | |
   
   | [Flag](https://app.codecov.io/gh/apache/hudi/pull/20110/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [hadoop-mr-java-client](https://app.codecov.io/gh/apache/hudi/pull/20110/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `43.99% <ø> (+<0.01%)` | :arrow_up: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Files with missing lines](https://app.codecov.io/gh/apache/hudi/pull/20110?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [...parquet/HoodieFileGroupReaderBasedFileFormat.scala](https://app.codecov.io/gh/apache/hudi/pull/20110?src=pr&el=tree&filepath=hudi-spark-datasource%2Fhudi-spark-common%2Fsrc%2Fmain%2Fscala%2Forg%2Fapache%2Fspark%2Fsql%2Fexecution%2Fdatasources%2Fparquet%2FHoodieFileGroupReaderBasedFileFormat.scala&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-aHVkaS1zcGFyay1kYXRhc291cmNlL2h1ZGktc3BhcmstY29tbW9uL3NyYy9tYWluL3NjYWxhL29yZy9hcGFjaGUvc3Bhcmsvc3FsL2V4ZWN1dGlvbi9kYXRhc291cmNlcy9wYXJxdWV0L0hvb2RpZUZpbGVHcm91cFJlYWRlckJhc2VkRmlsZUZvcm1hdC5zY2FsYQ==) | `83.80% <ø> (-0.56%)` | :arrow_down: |
   | [...asources/parquet/ParquetSchemaEvolutionUtils.scala](https://app.codecov.io/gh/apache/hudi/pull/20110?src=pr&el=tree&filepath=hudi-spark-datasource%2Fhudi-spark-common%2Fsrc%2Fmain%2Fscala%2Forg%2Fapache%2Fspark%2Fsql%2Fexecution%2Fdatasources%2Fparquet%2FParquetSchemaEvolutionUtils.scala&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-aHVkaS1zcGFyay1kYXRhc291cmNlL2h1ZGktc3BhcmstY29tbW9uL3NyYy9tYWluL3NjYWxhL29yZy9hcGFjaGUvc3Bhcmsvc3FsL2V4ZWN1dGlvbi9kYXRhc291cmNlcy9wYXJxdWV0L1BhcnF1ZXRTY2hlbWFFdm9sdXRpb25VdGlscy5zY2FsYQ==) | `87.09% <ø> (ø)` | |
   | [...ion/datasources/parquet/Spark35ParquetReader.scala](https://app.codecov.io/gh/apache/hudi/pull/20110?src=pr&el=tree&filepath=hudi-spark-datasource%2Fhudi-spark3.5.x%2Fsrc%2Fmain%2Fscala%2Forg%2Fapache%2Fspark%2Fsql%2Fexecution%2Fdatasources%2Fparquet%2FSpark35ParquetReader.scala&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-aHVkaS1zcGFyay1kYXRhc291cmNlL2h1ZGktc3BhcmszLjUueC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL3NwYXJrL3NxbC9leGVjdXRpb24vZGF0YXNvdXJjZXMvcGFycXVldC9TcGFyazM1UGFycXVldFJlYWRlci5zY2FsYQ==) | `94.26% <ø> (-0.15%)` | :arrow_down: |
   | [...ion/datasources/parquet/Spark42ParquetReader.scala](https://app.codecov.io/gh/apache/hudi/pull/20110?src=pr&el=tree&filepath=hudi-spark-datasource%2Fhudi-spark4.2.x%2Fsrc%2Fmain%2Fscala%2Forg%2Fapache%2Fspark%2Fsql%2Fexecution%2Fdatasources%2Fparquet%2FSpark42ParquetReader.scala&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-aHVkaS1zcGFyay1kYXRhc291cmNlL2h1ZGktc3Bhcms0LjIueC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL3NwYXJrL3NxbC9leGVjdXRpb24vZGF0YXNvdXJjZXMvcGFycXVldC9TcGFyazQyUGFycXVldFJlYWRlci5zY2FsYQ==) | `94.73% <ø> (-0.13%)` | :arrow_down: |
   </details>
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] perf(spark): reuse the row projection across files of a scan [hudi]

Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #20110:
URL: https://github.com/apache/hudi/pull/20110#issuecomment-5860832873

   <!--
   Meta data
   {
     "version" : 1,
     "metaDataEntries" : [ {
       "hash" : "1f3ba80da64e0e3a00aceca6257905d9544c39cb",
       "status" : "PENDING",
       "url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=17320",
       "triggerID" : "1f3ba80da64e0e3a00aceca6257905d9544c39cb",
       "triggerType" : "PUSH"
     } ]
   }-->
   ## CI report:
   
   * 1f3ba80da64e0e3a00aceca6257905d9544c39cb Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=17320) 
   
   <details>
   <summary>Bot commands</summary>
     @hudi-bot supports the following commands:
   
    - `@hudi-bot run azure` re-run the last Azure build
   </details>


-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] perf(spark): reuse the row projection across files of a scan [hudi]

Posted by "voonhous (via GitHub) via commits" <co...@hudi.apache.org>.
voonhous commented on PR #20110:
URL: https://github.com/apache/hudi/pull/20110#issuecomment-6701555039

   Temporarily closing this PR while we debug a GitHub settings error on master (#20471); it will be reopened shortly, no action needed.


-- 
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: commits-unsubscribe@hudi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org