Skip to content

[refine](pipeline) stop splitting distinct streaming agg output by batch size#63750

Open
Mryange wants to merge 1 commit into
apache:masterfrom
Mryange:stop-splitting-distinct-streaming-agg
Open

[refine](pipeline) stop splitting distinct streaming agg output by batch size#63750
Mryange wants to merge 1 commit into
apache:masterfrom
Mryange:stop-splitting-distinct-streaming-agg

Conversation

@Mryange
Copy link
Copy Markdown
Contributor

@Mryange Mryange commented May 27, 2026

What problem does this PR solve?

Issue Number: N/A

Problem Summary:
DistinctStreamingAggOperatorX kept each output block at or below batch_size by splitting rows between _aggregated_block and an extra _cache_block, then replaying the cached tail on the next pull. Root cause: the operator coupled its accumulation threshold with a hard output-size cap. This change removes the cache path and appends all distinct rows directly into _aggregated_block. The operator still uses batch_size in need_more_input_data() to decide when to stop reading more input, but once one append crosses the threshold it now returns the full block instead of splitting it.

Release note

None

Check List (For Author)

  • Test

    • Regression test
    • Unit Test
    • Manual test (add detailed scripts or steps below)
    • No need to test or manual test. Explain why:
      • This is a refactor/code format and no logic has been changed.
      • Previous test can cover this change.
      • No code files have been changed.
      • Other reason
  • Behavior changed:

    • No.
    • Yes.
  • Does this need documentation?

    • No.
    • Yes.

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

@hello-stephen
Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@Mryange
Copy link
Copy Markdown
Contributor Author

Mryange commented May 27, 2026

/review

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review result: no blocking PR-introduced issues found in the distinct streaming aggregation change.

Critical checkpoint conclusions:

  • Goal/test: The patch removes the cache-block split path so distinct streaming aggregation can return the full accumulated block after crossing batch_size. The updated BE unit test covers the new oversized output behavior and passthrough transition.
  • Scope: The code change is small and focused on _cache_block removal and related test expectations.
  • Concurrency: No new shared state, locks, dependencies, or thread interactions are introduced; operator local state remains task-local.
  • Lifecycle: Removing _cache_block simplifies close/pull lifecycle. _aggregated_block is still cleared/reused through the existing Block swap/clear path.
  • Configuration/compatibility: No new configs, formats, thrift fields, or mixed-version protocol concerns.
  • Parallel paths: The related pull/push/need_more_input_data paths were checked; behavior is intentionally aligned with allowing a full accumulated block rather than splitting by batch_size.
  • Conditions/error handling: Existing Status handling is preserved; no ignored new Status values.
  • Tests: Unit coverage was updated for the changed behavior. I did not run tests in this review runner.
  • Observability/performance: No new logging or metrics needed; output can now exceed batch_size by the current accumulated block as intended by the PR.
  • Data correctness/transactions/persistence: No storage, transaction, or visibility-version paths are modified.

User focus: No additional user-provided review focus was present.

@Mryange
Copy link
Copy Markdown
Contributor Author

Mryange commented May 27, 2026

run buildall

@hello-stephen
Copy link
Copy Markdown
Contributor

TPC-H: Total hot run time: 32097 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 50e6c3b22f95b42f2cc264623ac2d082c93ed573, data reload: false

------ Round 1 ----------------------------------
orders	Doris	NULL	NULL	0	0	0	NULL	0	NULL	NULL	2023-12-26 18:27:23	2023-12-26 18:42:55	NULL	utf-8	NULL	NULL	
============================================
q1	17614	4168	4122	4122
q2	q3	10769	1401	856	856
q4	4701	476	344	344
q5	7544	2287	2105	2105
q6	233	180	144	144
q7	955	782	647	647
q8	9428	1757	1599	1599
q9	5215	5007	4985	4985
q10	6384	2246	1887	1887
q11	437	275	249	249
q12	642	422	291	291
q13	18120	3415	2713	2713
q14	266	260	238	238
q15	q16	816	766	698	698
q17	982	915	903	903
q18	6933	5880	5685	5685
q19	1319	1291	1195	1195
q20	582	436	304	304
q21	6312	2931	2807	2807
q22	489	447	325	325
Total cold run time: 99741 ms
Total hot run time: 32097 ms

----- Round 2, with runtime_filter_mode=off -----
orders	Doris	NULL	NULL	150000000	42	6422171781	NULL	22778155	NULL	NULL	2023-12-26 18:27:23	2023-12-26 18:42:55	NULL	utf-8	NULL	NULL	
============================================
q1	5248	4946	4868	4868
q2	q3	4937	5269	4686	4686
q4	2172	2251	1405	1405
q5	4978	4763	4720	4720
q6	231	181	134	134
q7	1989	1772	1587	1587
q8	2515	2186	2230	2186
q9	7958	7539	7449	7449
q10	4787	4720	4241	4241
q11	541	395	386	386
q12	740	749	539	539
q13	3038	3414	2827	2827
q14	273	276	252	252
q15	q16	685	709	629	629
q17	1307	1288	1282	1282
q18	7531	6915	7053	6915
q19	1181	1097	1098	1097
q20	2262	2239	1973	1973
q21	5400	4729	4522	4522
q22	526	485	412	412
Total cold run time: 58299 ms
Total hot run time: 52110 ms

@hello-stephen
Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 100.00% (4/4) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 53.91% (20944/38852)
Line Coverage 37.47% (198445/529680)
Region Coverage 33.72% (155352/460690)
Branch Coverage 34.75% (67710/194851)

@hello-stephen
Copy link
Copy Markdown
Contributor

TPC-DS: Total hot run time: 172415 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 50e6c3b22f95b42f2cc264623ac2d082c93ed573, data reload: false

query5	4302	666	508	508
query6	344	229	199	199
query7	4305	571	329	329
query8	330	240	229	229
query9	8796	4108	4079	4079
query10	456	348	303	303
query11	5816	2478	2261	2261
query12	177	130	123	123
query13	1262	620	448	448
query14	6144	5490	5202	5202
query14_1	4510	4496	4513	4496
query15	219	208	189	189
query16	1017	466	438	438
query17	973	766	630	630
query18	2467	494	364	364
query19	229	215	176	176
query20	139	135	133	133
query21	229	140	118	118
query22	13699	13552	13547	13547
query23	17495	16580	16227	16227
query23_1	16336	16386	16331	16331
query24	7492	1749	1341	1341
query24_1	1322	1303	1338	1303
query25	538	473	409	409
query26	1308	315	176	176
query27	2704	572	347	347
query28	4445	2060	2054	2054
query29	982	617	492	492
query30	317	225	199	199
query31	1125	1088	966	966
query32	98	75	73	73
query33	544	361	308	308
query34	1182	1137	657	657
query35	774	806	702	702
query36	1428	1400	1222	1222
query37	151	105	91	91
query38	3244	3149	3053	3053
query39	949	928	895	895
query39_1	891	878	873	873
query40	235	150	134	134
query41	68	65	66	65
query42	115	115	112	112
query43	369	334	297	297
query44	
query45	211	207	201	201
query46	1107	1184	735	735
query47	2331	2348	2272	2272
query48	427	451	293	293
query49	643	484	380	380
query50	1071	344	251	251
query51	4375	4278	4264	4264
query52	106	112	93	93
query53	255	277	204	204
query54	319	263	263	263
query55	94	90	87	87
query56	296	298	301	298
query57	1447	1422	1343	1343
query58	296	270	264	264
query59	1581	1640	1506	1506
query60	322	322	307	307
query61	164	159	153	153
query62	696	649	588	588
query63	243	200	210	200
query64	2404	805	687	687
query65	
query66	1707	482	363	363
query67	29775	29661	29664	29661
query68	
query69	465	343	300	300
query70	1048	999	1028	999
query71	294	272	269	269
query72	3079	2688	2285	2285
query73	808	793	426	426
query74	5121	5014	4787	4787
query75	2715	2585	2280	2280
query76	2259	1158	812	812
query77	412	418	325	325
query78	12405	12463	11837	11837
query79	1314	1098	758	758
query80	576	559	456	456
query81	456	277	244	244
query82	366	169	122	122
query83	383	273	248	248
query84	316	143	119	119
query85	944	606	549	549
query86	417	348	312	312
query87	3406	3399	3223	3223
query88	3637	2765	2747	2747
query89	443	399	347	347
query90	1910	181	185	181
query91	202	185	157	157
query92	82	81	83	81
query93	1490	1391	909	909
query94	556	367	344	344
query95	698	411	368	368
query96	1090	804	356	356
query97	2783	2807	2695	2695
query98	242	228	228	228
query99	1187	1156	1034	1034
Total cold run time: 253555 ms
Total hot run time: 172415 ms

@hello-stephen
Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 100.00% (4/4) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 73.75% (28064/38051)
Line Coverage 57.73% (304990/528323)
Region Coverage 54.90% (255332/465111)
Branch Coverage 56.34% (110191/195577)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants