Re: [PR] perf(spark): optimize COW incremental read by enabling file splitting, vectorized reading, and stock reader bypass [hudi]
yihua commented on code in PR #19914:
URL: https://github.com/apache/hudi/pull/19914#discussion_r4203449099
##
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/HoodieFileGroupReaderFunction.scala:
##
@@ -250,7 +260,7 @@ private[parquet] class
HoodieFileGroupReaderFunction(baseFileReader: Broadcast[S
//and we pass an empty schema for the partition schema
val iter = parquetFileReader.read(modifiedFile, readSchema, new
StructType(), state.internalSchemaOpt, filters, conf,
state.tableSchemaAsMessageType)
- projectIfNeeded(iter, readSchema, schemas.outputSchema)
+ projectIfNeeded(applyRequiredFilters(iter, readSchema, requiredFilters),
readSchema, schemas.outputSchema)
Review Comment:
non-blocking: The predicate is now evaluated in all three branches here, but
the incremental suites only reach the first one on COW; the tests that read
partition columns from the file (timestamp/custom key generators,
extract.partition.values.from.path=false) are all MOR, where the reader is
still row-based. Could we add a COW incremental case with a timestamp-based key
generator, so the vectorized path is covered where the read schema carries
mandatory partition fields and the predicate has to resolve against it?
##
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/HoodieFileGroupReaderBasedFileFormat.scala:
##
@@ -207,10 +210,18 @@ class HoodieFileGroupReaderBasedFileFormat(tablePath:
String,
} else {
throw new HoodieNotSupportedException("Unsupported file format: " +
hoodieFileFormat)
}
- supportVectorizedRead = !isIncremental && !isBootstrap && supportBatch
- supportReturningBatch = !isMOR && supportVectorizedRead
+ // MOR incremental embeds file slices that may contain log files
requiring row-level
+ // merging, and CDC rows are built by a row-based iterator that reads
base files through
+ // the same reader, so vectorized reading must be disabled for both. All
other combinations
+ // (COW snapshot, COW incremental, MOR snapshot) either have no log
merging or handle it via
+ // a separate non-vectorized fileGroupBaseFileReader while the base file
reader stays vectorized.
+ supportVectorizedRead = !(isIncremental && (isMOR || isCDC)) &&
!isBootstrap && supportBatch
Review Comment:
non-blocking: This also makes COW incremental reads vectorized and
splittable for ORC and multi-format tables, and I could not find an incremental
query over ORC base files anywhere in the suites (the ORC scenarios in
TestHoodieSparkSqlWriter are snapshot only). Could we add an ORC variant of the
incremental ranges test, or parameterize the existing one by base file format,
so that cell is covered as well?
--
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]
Re: [PR] perf(spark): optimize COW incremental read by enabling file splitting, vectorized reading, and stock reader bypass [hudi]
yihua commented on code in PR #19914:
URL: https://github.com/apache/hudi/pull/19914#discussion_r4203390343
##
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/HoodieFileGroupReaderFunction.scala:
##
@@ -349,6 +360,34 @@ private[parquet] object HoodieFileGroupReaderFunction {
iter.map(mapper.apply(_))
}
+ /**
+ * Evaluates `requiredFilters` on every row. Pushed-down filters only prune
row groups in the vectorized reader,
+ * and the plan-level filter for them is only added when the Hudi session
extension is registered, so the
+ * commit-time range of an incremental query is enforced here. The scan
returns rows rather than batches
+ * whenever required filters are present.
+ */
+ private def applyRequiredFilters(iter: Iterator[InternalRow],
Review Comment:
non-blocking: With the session extension registered,
`maybeApplyForNewFileFormat` already wraps the scan in a plan-level Filter on
these same required filters, so on that path every COW incremental row is now
evaluated twice, and the `requiredFilters.isEmpty` gate also gives up batch
output where the plan Filter would have handled it vectorized. Could the format
skip the predicate (and keep returning batches) when the plan-side filter is in
place, e.g. a flag set alongside `isProjected` in `applyNewFileFormatChanges`
and `createStreamingDataFrame`, rather than detecting the extension via conf,
which misses programmatic registration? Separately, if the predicate stays, the
V2 `In` over all included commit times should go through `InSet` (or an
equivalent set lookup), since `Predicate.create` on a raw `In` generates a
linear chain of string compares per row.
--
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]
Re: [PR] perf(spark): optimize COW incremental read by enabling file splitting, vectorized reading, and stock reader bypass [hudi]
yihua commented on code in PR #19914:
URL: https://github.com/apache/hudi/pull/19914#discussion_r4203338542
##
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/HoodieFileGroupReaderBasedFileFormat.scala:
##
@@ -366,6 +387,12 @@ class HoodieFileGroupReaderBasedFileFormat(tablePath:
String,
.getSparkPartitionedFileUtils.getPathFromPartitionedFile(file))
fileSliceMapping.getSlice(fileGroupName) match {
case Some(fileSlice) if !isCount && (requiredSchema.nonEmpty ||
fileSlice.getLogFiles.findAny().isPresent) =>
+ if (!fileSlice.getLogFiles.findAny().isPresent && !isBootstrap
&& broadcastStockReader.isDefined) {
Review Comment:
Thanks, the stock reader is gone now so the main concern here is addressed.
Leaving this open for the benchmark re-run on the final shape; the routing part
is picked up in the comment on HoodieFileGroupReaderFunction.scala line 151.
--
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]
Re: [PR] perf(spark): optimize COW incremental read by enabling file splitting, vectorized reading, and stock reader bypass [hudi]
yihua commented on code in PR #19914: URL: https://github.com/apache/hudi/pull/19914#discussion_r4203311468 ## hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/HoodieFileGroupReaderBasedFileFormat.scala: ## @@ -262,8 +273,11 @@ class HoodieFileGroupReaderBasedFileFormat(tablePath: String, // For overly large single files, we can use multiple concurrent tasks to read them, thereby reducing the overall job reading time consumption val superSplitable = super.isSplitable(sparkSession, options, path) val isLance = hoodieFileFormat == HoodieFileFormat.LANCE -val splitable = !isMOR && !isIncremental && !isBootstrap && !isLance && superSplitable -logDebug(s"isSplitable: $splitable, super.isSplitable: $superSplitable, isMOR: $isMOR, isIncremental: $isIncremental, isBootstrap: $isBootstrap") +// COW incremental reads have no log files to merge, so file splitting is safe. +// MOR, CDC and bootstrap reads need to disable splitting. +val splitable = !isMOR && !isCDC && !isBootstrap && !isLance && superSplitable Review Comment: non-blocking: Now that COW incremental reads can be split, could we add a case that actually produces more than one split per base file (small parquet block size plus a low `spark.sql.files.maxPartitionBytes`) and asserts the incremental range result against the unsplit read? The existing ranges test only has single-split files, so the splitting change itself is currently unguarded. -- 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]
Re: [PR] perf(spark): optimize COW incremental read by enabling file splitting, vectorized reading, and stock reader bypass [hudi]
yihua commented on code in PR #19914:
URL: https://github.com/apache/hudi/pull/19914#discussion_r4203264897
##
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/HoodieFileGroupReaderFunction.scala:
##
@@ -145,6 +148,11 @@ private[parquet] class
HoodieFileGroupReaderFunction(baseFileReader: Broadcast[S
val fileGroupName = FSUtils.getFileIdFromFilePath(sparkAdapter
.getSparkPartitionedFileUtils.getPathFromPartitionedFile(file))
fileSliceMapping.getSlice(fileGroupName) match {
+ case Some(fileSlice) if state.readBaseOnlySlicesDirectly &&
!fileSlice.getLogFiles.findAny().isPresent =>
Review Comment:
I don't think this case can be reached: the only place a
`HoodiePartitionFileSliceMapping` is built is
`PartitionDirectoryConverter.convertFileSliceToPartitionDirectory`, which
embeds a slice only when it has log files or a bootstrap base, so a
base-file-only COW slice already lands in `case _` -> `readBaseFile` on master.
Could you drop this branch and the `readBaseOnlySlicesDirectly` state, and
update the title/description so the change is described as vectorized reading +
splitting for COW incremental? Since the measured path has changed twice since
the numbers were taken, it would also be good to re-run the benchmark on the
current commit.
--
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]
Re: [PR] perf(spark): optimize COW incremental read by enabling file splitting, vectorized reading, and stock reader bypass [hudi]
yihua commented on code in PR #19914:
URL: https://github.com/apache/hudi/pull/19914#discussion_r4203264897
##
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/HoodieFileGroupReaderFunction.scala:
##
@@ -145,6 +148,11 @@ private[parquet] class
HoodieFileGroupReaderFunction(baseFileReader: Broadcast[S
val fileGroupName = FSUtils.getFileIdFromFilePath(sparkAdapter
.getSparkPartitionedFileUtils.getPathFromPartitionedFile(file))
fileSliceMapping.getSlice(fileGroupName) match {
+ case Some(fileSlice) if state.readBaseOnlySlicesDirectly &&
!fileSlice.getLogFiles.findAny().isPresent =>
Review Comment:
I don't think this case can be reached: the only place a
`HoodiePartitionFileSliceMapping` is built is
`PartitionDirectoryConverter.convertFileSliceToPartitionDirectory`, which
embeds a slice only when it has log files or a bootstrap base, so a
base-file-only COW slice already lands in `case _` -> `readBaseFile` on master.
#20115 (merged yesterday, already in this PR's base) reworked that converter
into `convertFileSlicesToPartitionDirectories` and documents exactly this:
base-file-only slices get no mapping and share one directory per partition,
while only slices read as a whole carry the mapping. Could you drop this branch
and the `readBaseOnlySlicesDirectly` state, and update the title/description so
the change is described as vectorized reading + splitting for COW incremental?
Since the measured path has changed twice since the numbers were taken, it
would also be good to re-run the benchmark on the current commit.
--
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]
Re: [PR] perf(spark): optimize COW incremental read by enabling file splitting, vectorized reading, and stock reader bypass [hudi]
yihua commented on code in PR #19914:
URL: https://github.com/apache/hudi/pull/19914#discussion_r4077752473
##
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/HoodieFileGroupReaderBasedFileFormat.scala:
##
@@ -366,6 +387,12 @@ class HoodieFileGroupReaderBasedFileFormat(tablePath:
String,
.getSparkPartitionedFileUtils.getPathFromPartitionedFile(file))
fileSliceMapping.getSlice(fileGroupName) match {
case Some(fileSlice) if !isCount && (requiredSchema.nonEmpty ||
fileSlice.getLogFiles.findAny().isPresent) =>
+ if (!fileSlice.getLogFiles.findAny().isPresent && !isBootstrap
&& broadcastStockReader.isDefined) {
Review Comment:
Stepping back on the approach: I would rather we speed up the existing file
group reader path than add a second reader here, since the stock
`ParquetFileFormat` bypass has to re-implement every Hudi read semantic
(schema-on-read, type promotion, mandatory partition fields, vector columns,
required filters, ORC/multi-format) and the CI failures show how easy it is to
miss one. The `case _` branch below already skips `HoodieFileGroupReader` for a
base-only slice via `readBaseFile(file, baseFileReader.value, ...)` while
keeping the Hudi reader, so routing no-log COW slices there with the vectorized
`baseFileReader` should capture most of the win. Could you re-run the benchmark
through that path first, and only if a material gap remains, profile where it
is inside the Hudi reader and fix it there?
--
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]
Re: [PR] perf(spark): optimize COW incremental read by enabling file splitting, vectorized reading, and stock reader bypass [hudi]
yihua commented on code in PR #19914:
URL: https://github.com/apache/hudi/pull/19914#discussion_r4077740886
##
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/HoodieFileGroupReaderBasedFileFormat.scala:
##
@@ -218,7 +218,11 @@ class HoodieFileGroupReaderBasedFileFormat(tablePath:
String,
} else {
throw new HoodieNotSupportedException("Unsupported file format: " +
hoodieFileFormat)
}
- supportVectorizedRead = !isIncremental && !isBootstrap && supportBatch
+ // MOR incremental embeds file slices that may contain log files
requiring row-level
+ // merging, so vectorized reading must be disabled. All other
combinations (COW snapshot,
+ // COW incremental, MOR snapshot) either have no log merging or handle
it via a separate
+ // non-vectorized fileGroupBaseFileReader while the base file reader
stays vectorized.
+ supportVectorizedRead = !(isMOR && isIncremental) && !isBootstrap &&
supportBatch
Review Comment:
Confirming this: CI has
`TestIncrementalReadWithFileGroupReader.testIncrementalReadRanges` failing for
all COW rows with records from earlier commits leaking into the range
(`expected Set((k3,2),(k4,2)) but was Set((k1,1),(k2,1),(k3,2),(k4,2))`), and
that suite deliberately runs without the extension, where the plan-level
commit-time Filter is never added. The vectorized/stock path only uses
`requiredFilters` for row-group and page pruning, so the row-level guarantee
the previous non-vectorized path gave is gone; note the stock reader is also
handed `requiredSchema` rather than `readRequiredSchema`, so
`_hoodie_commit_time` is not even guaranteed to be in the projection. Routing
this case through `readBaseFile(file, baseFileReader.value, ...)` as suggested
above, or wrapping the bypass output with the `requiredFilters` predicate,
would keep the semantics.
##
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/HoodieFileGroupReaderBasedFileFormat.scala:
##
@@ -218,7 +218,11 @@ class HoodieFileGroupReaderBasedFileFormat(tablePath:
String,
} else {
throw new HoodieNotSupportedException("Unsupported file format: " +
hoodieFileFormat)
}
- supportVectorizedRead = !isIncremental && !isBootstrap && supportBatch
+ // MOR incremental embeds file slices that may contain log files
requiring row-level
+ // merging, so vectorized reading must be disabled. All other
combinations (COW snapshot,
+ // COW incremental, MOR snapshot) either have no log merging or handle
it via a separate
+ // non-vectorized fileGroupBaseFileReader while the base file reader
stays vectorized.
+ supportVectorizedRead = !(isMOR && isIncremental) && !isBootstrap &&
supportBatch
Review Comment:
The COW CDC relation comes through here with `isMOR = false, isIncremental =
true` (its factory extends the COW incremental base factory), so this change
also turns on vectorized reading and batch output for CDC, whose
`CDCFileGroupIterator` reads base and native CDC files row by row. That looks
like what is behind the CDC failures in CI
(`TestCDCDataFrameSuite.testCOWDataSourceWrite` returns 0 of 100 rows, plus
`TestCDCStreamingSuite`, `TestCDCForSparkSQL` and the CDC variant tests), all
of which pass on master. Could the vectorized/splittable gates exclude the CDC
path explicitly, e.g. by keying off the CDC file index or a dedicated flag from
the factory, rather than inferring "COW incremental" from `!isMOR &&
isIncremental`?
--
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]
Re: [PR] perf(spark): optimize COW incremental read by enabling file splitting, vectorized reading, and stock reader bypass [hudi]
hudi-bot commented on PR #19914: URL: https://github.com/apache/hudi/pull/19914#issuecomment-5639434574 ## CI report: * bb940a452ed43b0c0b40733a35e732bde088a965 UNKNOWN * 7aae831f5827002a3e10e59d52739f2f29c69790 Azure: [FAILURE](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=17025) Bot commands @hudi-bot supports the following commands: - `@hudi-bot run azure` re-run the last Azure build -- 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]
Re: [PR] perf(spark): optimize COW incremental read by enabling file splitting, vectorized reading, and stock reader bypass [hudi]
codecov-commenter commented on PR #19914: URL: https://github.com/apache/hudi/pull/19914#issuecomment-5639060225 ## [Codecov](https://app.codecov.io/gh/apache/hudi/pull/19914?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report :x: Patch coverage is `0%` with `11 lines` in your changes missing coverage. Please review. :white_check_mark: Project coverage is 79.94%. Comparing base ([`1d3a0af`](https://app.codecov.io/gh/apache/hudi/commit/1d3a0affad873868e74df7207013ae8eeb4dbb8c?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`7aae831`](https://app.codecov.io/gh/apache/hudi/commit/7aae831f5827002a3e10e59d52739f2f29c69790?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)). | [Files with missing lines](https://app.codecov.io/gh/apache/hudi/pull/19914?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines | |---|---|---| | [...parquet/HoodieFileGroupReaderBasedFileFormat.scala](https://app.codecov.io/gh/apache/hudi/pull/19914?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==) | 0.00% | [11 Missing :warning: ](https://app.codecov.io/gh/apache/hudi/pull/19914?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #19914 +/- ## - Coverage 80.21% 79.94% -0.27% + Complexity3467434571 -103 Files 2546 2546 Lines142463 142472 +9 Branches 1733317335 +2 - Hits 114271 113899 -372 - Misses2028320645 +362 - Partials 7909 7928 +19 ``` | [Components](https://app.codecov.io/gh/apache/hudi/pull/19914/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/19914/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `83.80% <ø> (-0.06%)` | :arrow_down: | | [hudi-client](https://app.codecov.io/gh/apache/hudi/pull/19914/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `83.22% <ø> (-0.07%)` | :arrow_down: | | [hudi-flink](https://app.codecov.io/gh/apache/hudi/pull/19914/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `83.86% <ø> (-1.71%)` | :arrow_down: | | [hudi-spark-datasource](https://app.codecov.io/gh/apache/hudi/pull/19914/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `73.24% <0.00%> (-0.04%)` | :arrow_down: | | [hudi-utilities](https://app.codecov.io/gh/apache/hudi/pull/19914/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `78.14% <ø> (ø)` | | | [hudi-cli](https://app.codecov.io/gh/apache/hudi/pull/19914/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `69.99% <ø> (ø)` | | | [hudi-hadoop](https://app.codecov.io/gh/apache/hudi/pull/19914/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `70.82% <ø> (ø)` | | | [hudi-sync](https://app.codecov.io/gh/apache/hudi/pull/19914/components?src=pr&el=component&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `76.02% <ø> (ø)` | | |
Re: [PR] perf(spark): optimize COW incremental read by enabling file splitting, vectorized reading, and stock reader bypass [hudi]
hudi-bot commented on PR #19914: URL: https://github.com/apache/hudi/pull/19914#issuecomment-5638956520 ## CI report: * bb940a452ed43b0c0b40733a35e732bde088a965 UNKNOWN * 7aae831f5827002a3e10e59d52739f2f29c69790 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=17025) Bot commands @hudi-bot supports the following commands: - `@hudi-bot run azure` re-run the last Azure build -- 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]
Re: [PR] perf(spark): optimize COW incremental read by enabling file splitting, vectorized reading, and stock reader bypass [hudi]
hudi-bot commented on PR #19914: URL: https://github.com/apache/hudi/pull/19914#issuecomment-5638889182 ## CI report: * bb940a452ed43b0c0b40733a35e732bde088a965 UNKNOWN * 7aae831f5827002a3e10e59d52739f2f29c69790 UNKNOWN Bot commands @hudi-bot supports the following commands: - `@hudi-bot run azure` re-run the last Azure build -- 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]
Re: [PR] perf(spark): optimize COW incremental read by enabling file splitting, vectorized reading, and stock reader bypass [hudi]
hudi-bot commented on PR #19914: URL: https://github.com/apache/hudi/pull/19914#issuecomment-5638813300 ## CI report: * bb940a452ed43b0c0b40733a35e732bde088a965 UNKNOWN Bot commands @hudi-bot supports the following commands: - `@hudi-bot run azure` re-run the last Azure build -- 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]
Re: [PR] perf(spark): optimize COW incremental read by enabling file splitting, vectorized reading, and stock reader bypass [hudi]
hudi-agent commented on code in PR #19914:
URL: https://github.com/apache/hudi/pull/19914#discussion_r3992078084
##
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/HoodieFileGroupReaderBasedFileFormat.scala:
##
@@ -366,6 +387,12 @@ class HoodieFileGroupReaderBasedFileFormat(tablePath:
String,
.getSparkPartitionedFileUtils.getPathFromPartitionedFile(file))
fileSliceMapping.getSlice(fileGroupName) match {
case Some(fileSlice) if !isCount && (requiredSchema.nonEmpty ||
fileSlice.getLogFiles.findAny().isPresent) =>
+ if (!fileSlice.getLogFiles.findAny().isPresent && !isBootstrap
&& broadcastStockReader.isDefined) {
Review Comment:
🤖 Going straight to stock `ParquetFileFormat` drops everything Hudi's own
parquet reader layers on top: `internalSchemaOpt` (schema-on-read renames/type
changes), `tableSchemaAsMessageType`-driven type promotion (int→long etc. for
files written with an older schema), `mandatoryFields` partition columns that
must be read from the file rather than the path (timestamp/custom keygen,
precombine-as-partition — and `vectorTypes` still declares those as
`OnHeapColumnVector` while the stock reader emits `ConstantColumnVector`, so
codegen would CCE), and the VECTOR BinaryType rewrite. Have you considered
routing this case through `readBaseFile(file, baseFileReader.value, ...)`
instead? That already skips `HoodieFileGroupReader` while keeping the Hudi
reader semantics — it'd be useful to know how much of the benchmark win is from
bypassing the FG reader vs. bypassing the Hudi parquet reader.
⚠️ AI-generated; verify before applying. React 👍/👎 to flag
quality.
##
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/HoodieFileGroupReaderBasedFileFormat.scala:
##
@@ -218,7 +218,11 @@ class HoodieFileGroupReaderBasedFileFormat(tablePath:
String,
} else {
throw new HoodieNotSupportedException("Unsupported file format: " +
hoodieFileFormat)
}
- supportVectorizedRead = !isIncremental && !isBootstrap && supportBatch
+ // MOR incremental embeds file slices that may contain log files
requiring row-level
+ // merging, so vectorized reading must be disabled. All other
combinations (COW snapshot,
+ // COW incremental, MOR snapshot) either have no log merging or handle
it via a separate
+ // non-vectorized fileGroupBaseFileReader while the base file reader
stays vectorized.
+ supportVectorizedRead = !(isMOR && isIncremental) && !isBootstrap &&
supportBatch
Review Comment:
🤖 One thing to double-check: the incremental `requiredFilters`
(`_hoodie_commit_time IN (...)`) only get a plan-level `Filter` via
`HoodieAnalysis.maybeApplyForNewFileFormat`, i.e. when
`HoodieSparkSessionExtension` is registered. Without the extension the
row-based `ParquetRecordReader` + `FilterCompat` was doing record-level
filtering, but the vectorized reader only prunes row groups/pages — so a
rewritten COW base file containing rows from several commits could leak
out-of-range rows. Is DataFrame incremental read without the extension still a
supported path? @yihua might be able to confirm.
⚠️ AI-generated; verify before applying. React 👍/👎 to flag
quality.
##
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/HoodieFileGroupReaderBasedFileFormat.scala:
##
@@ -347,6 +353,21 @@ class HoodieFileGroupReaderBasedFileFormat(tablePath:
String,
}
val broadcastedStorageConf = spark.sparkContext.broadcast(new
SerializableConfiguration(augmentedStorageConf.unwrap()))
+
+// Build stock Spark ParquetFileFormat reader for COW base-file-only
bypass.
+// When a file slice has only a base file (no log files), this avoids the
overhead of
+// HoodieFileGroupReader (schema handler, record merger, row copy/seal) by
using Spark's
+// native parquet reader directly.
+val stockParquetReader: Option[PartitionedFile => Iterator[InternalRow]] =
if (!isMOR && !isBootstrap) {
Review Comment:
🤖 This gate doesn't check `hoodieFileFormat`, so a COW table with ORC (or
Lance/Vortex/multi-format) base files will be handed to `ParquetFileFormat` and
fail. Also note `HoodieCopyOnWriteSnapshotHadoopFsRelationFactory` builds its
`HoodieFileIndex` with `shouldEmbedFileSlices = true`, so
`file.partitionValues` is a `HoodiePartitionFileSliceMapping` for COW snapshot
reads as well — this bypass ends up on every COW snapshot scan, not just
incremental. Could you scope it to `hoodieFileFormat == PARQUET &&
!isMultipleBaseFileFormatsEnabled` at minimum, and update the description to
reflect the snapshot impact?
⚠️ AI-generated; verify before applying. React 👍/👎 to flag
quality.
##
