Skip to content

[Fix](query cache) support partition-based instance parallelism#60974

Open
924060929 wants to merge 2 commits intoapache:masterfrom
924060929:query_cache_partition_parallel
Open

[Fix](query cache) support partition-based instance parallelism#60974
924060929 wants to merge 2 commits intoapache:masterfrom
924060929:query_cache_partition_parallel

Conversation

@924060929
Copy link
Contributor

@924060929 924060929 commented Mar 3, 2026

What problem does this PR solve?

When total tablets are much larger than pipeline capacity, one-tablet-per-instance planning creates excessive BE concurrency pressure in query-cache workloads.

Trigger partition-based planning when:
total_tablets > parallel_pipeline_task_num * participating_be_num

Before:
instance_num ~= total_tablets
After:
instance_num ~= partitions_on_each_be

Per-BE planning example:
BE1 tablets: p1[t1,t2], p2[t3] -> instances: [p1:t1,t2], [p2:t3]
BE2 tablets: p1[t4], p2[t5,t6] -> instances: [p1:t4], [p2:t5,t6]

This keeps tablets from the same partition in one instance and separates
different partitions into different instances. If partition mapping is incomplete
or partition planning fails, fallback to default planning for correctness.

Tests:

  • partition-based planning path
  • fallback-to-default path (incomplete mapping)
  • non-query-cache default planning path

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

When total tablets are much larger than pipeline capacity, one-tablet-per-instance planning creates excessive BE concurrency pressure in query-cache workloads.

Trigger partition-based planning when:
  total_tablets > parallel_pipeline_task_num * participating_be_num

Before:
  instance_num ~= total_tablets
After:
  instance_num ~= partitions_on_each_be

Per-BE planning example:
  BE1 tablets: p1[t1,t2], p2[t3]     -> instances: [p1:t1,t2], [p2:t3]
  BE2 tablets: p1[t4],    p2[t5,t6]  -> instances: [p1:t4],    [p2:t5,t6]

This keeps tablets from the same partition in one instance and separates
 different partitions into different instances. If partition mapping is incomplete
or partition planning fails, fallback to default planning for correctness.

Tests:
- partition-based planning path
- fallback-to-default path (incomplete mapping)
- non-query-cache default planning path
@Thearas
Copy link
Contributor

Thearas commented Mar 3, 2026

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?

@924060929
Copy link
Contributor Author

run buildall

@doris-robot
Copy link

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

------ Round 1 ----------------------------------
============================================
q1	17617	4463	4278	4278
q2	q3	10641	755	521	521
q4	4679	351	248	248
q5	7561	1195	1013	1013
q6	170	176	147	147
q7	782	838	679	679
q8	9306	1444	1311	1311
q9	4975	4556	4704	4556
q10	6779	1864	1631	1631
q11	460	255	237	237
q12	711	568	481	481
q13	17761	4249	3419	3419
q14	228	237	211	211
q15	952	792	792	792
q16	754	733	689	689
q17	711	843	407	407
q18	6226	5268	5219	5219
q19	1175	972	620	620
q20	495	501	381	381
q21	4813	1937	1533	1533
q22	373	313	270	270
Total cold run time: 97169 ms
Total hot run time: 28643 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4642	4682	4625	4625
q2	q3	1783	2218	1758	1758
q4	856	1175	764	764
q5	4022	4349	4313	4313
q6	179	176	143	143
q7	1770	1676	1526	1526
q8	2469	2690	2572	2572
q9	7400	7261	7204	7204
q10	2700	2876	2448	2448
q11	508	451	427	427
q12	504	595	465	465
q13	4114	4432	3846	3846
q14	275	288	272	272
q15	857	800	803	800
q16	695	785	737	737
q17	1193	1619	1316	1316
q18	7053	6748	6881	6748
q19	873	817	868	817
q20	2101	2177	2029	2029
q21	3913	3415	3319	3319
q22	500	421	403	403
Total cold run time: 48407 ms
Total hot run time: 46532 ms

@doris-robot
Copy link

TPC-DS: Total hot run time: 183195 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 b06fdee056baf0b2f1952830d45011cf0aa05251, data reload: false

query5	4786	632	498	498
query6	322	217	193	193
query7	4218	463	273	273
query8	333	237	227	227
query9	8725	2765	2716	2716
query10	525	387	345	345
query11	16977	17361	17044	17044
query12	219	185	172	172
query13	2185	460	372	372
query14	7754	3282	3141	3141
query14_1	2908	2884	2842	2842
query15	215	200	170	170
query16	1018	501	461	461
query17	1454	728	687	687
query18	2674	447	397	397
query19	230	199	181	181
query20	149	129	130	129
query21	217	132	117	117
query22	5433	5252	4700	4700
query23	17174	16742	16517	16517
query23_1	16702	16688	16634	16634
query24	7101	1612	1242	1242
query24_1	1220	1239	1229	1229
query25	531	449	394	394
query26	1227	265	148	148
query27	2782	472	296	296
query28	4502	1881	1886	1881
query29	792	557	465	465
query30	310	240	209	209
query31	870	704	641	641
query32	80	67	69	67
query33	507	365	280	280
query34	917	903	562	562
query35	639	667	588	588
query36	1095	1097	1000	1000
query37	131	90	84	84
query38	2929	2899	2917	2899
query39	875	853	849	849
query39_1	839	817	823	817
query40	224	149	133	133
query41	62	60	57	57
query42	110	102	102	102
query43	376	394	347	347
query44	
query45	198	191	185	185
query46	887	985	597	597
query47	2154	2140	2038	2038
query48	324	312	231	231
query49	611	477	388	388
query50	668	294	233	233
query51	4115	4047	4070	4047
query52	104	107	92	92
query53	289	332	291	291
query54	288	266	259	259
query55	94	84	85	84
query56	305	298	302	298
query57	1380	1353	1253	1253
query58	290	276	268	268
query59	2582	2782	2565	2565
query60	320	330	320	320
query61	148	147	149	147
query62	642	589	555	555
query63	313	270	287	270
query64	4918	1377	1079	1079
query65	
query66	1438	472	361	361
query67	16328	16361	16301	16301
query68	
query69	395	309	289	289
query70	986	979	972	972
query71	344	306	317	306
query72	2894	2806	2373	2373
query73	535	550	313	313
query74	9913	9872	9727	9727
query75	2832	2740	2457	2457
query76	2300	1027	661	661
query77	358	392	309	309
query78	11129	11301	10648	10648
query79	2806	770	606	606
query80	1773	616	530	530
query81	555	280	246	246
query82	1014	146	120	120
query83	341	257	240	240
query84	248	124	104	104
query85	888	470	427	427
query86	410	311	292	292
query87	3152	3094	2929	2929
query88	3548	2672	2646	2646
query89	428	364	337	337
query90	2006	166	167	166
query91	162	159	135	135
query92	75	70	69	69
query93	1133	836	511	511
query94	651	318	297	297
query95	575	399	312	312
query96	646	515	230	230
query97	2448	2486	2427	2427
query98	238	223	219	219
query99	1004	991	931	931
Total cold run time: 259156 ms
Total hot run time: 183195 ms

@hello-stephen
Copy link
Contributor

FE UT Coverage Report

Increment line coverage 66.25% (53/80) 🎉
Increment coverage report
Complete coverage report

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants