OIiveirra opened a new pull request, #71331: URL: https://github.com/apache/doris/pull/71331
### Background Doris can build aggregate states independently in several local workers, then merge states for the same group after a fragment exchange. The master FE local shuffle planner chooses how scan blocks reach those workers. ### What problem does this PR solve? Issue Number: None Related PR: #70296 (preserves required shuffles after key-breaking children) PR Type: Performance Problem Summary: In Iceberg TPC-H Q1, hashing by four groups sends almost half the rows to one worker and none to another. Distribute scan blocks across workers and merge partial states in the existing downstream exchange. ### Details - **Why it was slow:** Two low-cardinality grouping keys concentrate Q1 input on three of four hash partitions. Local repartitioning also hashes and copies the input before any groups are reduced. - **Optimization:** The FE requests passthrough for a fragment-root streaming partial aggregate over a serial file scan when the downstream stream repartitions its states on the same two string grouping slots, in order. - **Results:** Q1 improved at all three measured scale factors. - **Applicability and cost:** The rule applies to eligible first-stage built-in SUM, AVG and COUNT aggregates. A group can have a partial state in each worker. This trades additional partial states and merge work for cheaper distribution and more balanced input. The rule requires known grouping-key statistics and an estimated group count within the available parallelism on every participating BE. It preserves explicit hash distribution and the existing choices for limited or order-sensitive aggregations. Q1 produces 16 partial states instead of four. - **Behavior change:** The default FE local shuffle planner can choose block distribution for this partial aggregation shape. Query results and session defaults are preserved. Single-variable distribution benchmark on the 4.2 base `ddecccd2a6`. Each scale used the original Q1 SQL, a fixed Iceberg snapshot on a 4-vCPU, 16-GiB host, four execution lanes, and six alternating pairs of warm runs. Both arms used the original grouping hash table. Each pair produced identical results. | Scale | Hash shuffle, median (s) | Block distribution, median (s) | Median paired saving (s) | Median paired reduction | Faster pairs | | --- | ---: | ---: | ---: | ---: | ---: | | SF10 | 4.5650 | 3.1040 | 1.462 | 32.03% | 6/6 | | SF30 | 12.8750 | 9.0315 | 3.832 | 29.79% | 6/6 | | SF50 | 22.3545 | 15.9485 | 6.432 | 28.77% | 6/6 | At SF50 the busiest worker's share dropped from 49.29% to at most 25.02%. Paired savings and percentages are calculated within each pair before taking the median. ### Testing - Built the unmodified and candidate master FE from `6abaeefa095` and the release BE from the same base. - Ran 43 FE tests with Maven Surefire, including positive and fallback coverage for the local exchange planner. The positive fixture selected hash distribution with the original FE and passthrough with the candidate. The negative cases covered unknown or excessive group estimates, fewer workers, swapped outgoing keys, a different output tuple, explicit hash distribution, limits, and order-sensitive aggregates. - Ran the original TPC-H SF10 Q1 on a frozen Iceberg snapshot on master, with FULL column statistics and four workers. Both FEs used the same unmodified BE process. With the default FE planner and streaming-aggregation shuffle setting, the stock plan used a local hash exchange (one task processed 29,144,351 rows and one processed zero). The candidate automatically used passthrough (14,752,230–14,862,430 rows per task). With the explicit hash option enabled, both plans used the local hash exchange. All eight executions returned exactly the same four rows and ten columns. ### Release note Improves parallel partial aggregation for eligible two-string-key groupings on external scans. ### Check List (For Author) - Behavior changed: Yes (see Details). - Does this need documentation: No. - Pre-submission status: Ready. ### AI Disclosure - Tool: OpenAI Codex. - Generated: Implementation, tests, and description. - Human review: Pending author review. -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
