voonhous opened a new issue, #20625: URL: https://github.com/apache/hudi/issues/20625
Snapshot (`_rt`) queries on MOR tables through the Trino connector are much slower than the same queries on COW or on the read-optimized view. Any file slice with log files leaves the native Parquet page source for the `HoodieFileGroupReader` merge path in `HudiPageSourceProvider.createPageSource`, and that path pays the costs below on every split. This issue tracks the work. Line references are against master `db90a0da`. ### Measured locally Generated TPC-DS-shaped MOR table: 48 partitions, 40k rows each, table version 9, 4 Avro log files per file group, 48 splits, storage behind injected object-store latency. Full scan with an aggregate: | | `_ro` | `_rt` | |---|---|---| | CPU | 0.1 - 0.3 s | about 9 s | | wall | 0.9 s | 3.8 - 4.0 s | | `hoodie.properties` reads | 2 | 50 (one per split) | | timeline LIST + instant GET | 1 | 97 (one of each per split) | Merge buffer alone, 300k log records of one file group: the size estimate is 13,304 B/record, so 235,852 of 300,000 records (78.6%) spill to disk under the default 1 GiB budget. ### Work items - [ ] **Benchmarks.** Land the local MOR read benchmarks in `hudi-trino` test scope (`HudiMorReadBenchmark`, `HudiMergeBufferBenchmark`), so each item below has a number to move without a cluster. - [ ] **Record size estimator and spill serializer.** `HudiTrinoReaderContext` inherits `HoodieRecordSizeEstimator` and the Kryo `DefaultSerializer`, so every estimate includes the Avro schema object graph and the map spills early. `HoodieAvroReaderContext` already overrides both (`AvroRecordSizeEstimator`, `BufferedRecordSerializer`). - [ ] **Per-split meta client.** A new `HoodieTableMetaClient` is built per split (`HudiPageSourceProvider.java:232-234`, has a TODO), reading `hoodie.properties` each time, plus the index definitions file when one is registered. The coordinator already holds the table config; it could ship in the table handle (`TableState` is serializable and the file group reader accepts it). - [ ] **Per-split schema resolution.** With `hudi.table.resolve-column-name-casing.enabled=false` (the default) each split runs `TableSchemaResolver.getTableSchema()`: a recursive timeline listing, at least one instant file read with full commit metadata parsing, and an operation-field probe that can open a log file. Resolve once on the coordinator and ship it in the handle regardless of that flag. - [ ] **Log file sizes dropped.** `HudiUtil.convertToFileSlice` rebuilds each log file without the size the split already carries, so the reader stats every log file again; native log files also get two footer reads each. - [ ] **One page per file group.** `HudiPageSource.getNextSourcePage` drains the whole merged file group into a single page (no `pageBuilder.isFull()` check): no pipelining, a large transient heap, and `LIMIT` cannot stop early. - [ ] **Memory and I/O accounting.** `getMemoryUsage`, `getCompletedBytes` and `getReadTimeNanos` only cover the base file page source; the merge map and all log reads are invisible to Trino. - [ ] **Record-key predicate pushdown.** The base file is read with `TupleDomain.all()` and no dynamic filter when logs are present, so there is no row-group or page pruning. Spark and Flink push record-key-only filters to the base file under MOR; Trino pushes nothing. (Partition-level dynamic filtering in `HudiSplitSource` already applies to MOR splits.) - [ ] **Row-by-row Avro conversion.** Every base and log row becomes a `GenericData.Record` with boxed and decoded values, then is re-encoded into a page. Larger change; scope after the items above are measured. - [ ] **One split per file slice.** Slices with logs are never cut by size, which limits scan parallelism on large base files. Needs the file group reader to support `start != 0` with logs. Related: #20522, #19344. -- 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]
