Skip to content

[refine](exec) annotate mutex-protected BE caches and client holders#63428

Open
Mryange wants to merge 3 commits into
apache:masterfrom
Mryange:mutex-protected-dev-5.20
Open

[refine](exec) annotate mutex-protected BE caches and client holders#63428
Mryange wants to merge 3 commits into
apache:masterfrom
Mryange:mutex-protected-dev-5.20

Conversation

@Mryange
Copy link
Copy Markdown
Contributor

@Mryange Mryange commented May 20, 2026

What problem does this PR solve?

Issue Number: N/A

Related PR: None

Problem Summary:
Several BE cache and client-holder paths were protected by plain std::mutex or std::shared_mutex, so Clang thread-safety analysis could not understand the lock-to-field relationship. This change switches the touched paths to AnnotatedMutex or AnnotatedSharedMutex with LockGuard, SharedLockGuard, and UniqueLock, adds GUARDED_BY annotations to the protected state, and adjusts one shared-read dictionary lookup to avoid non-read-only map access patterns under a shared lock.

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 20, 2026

run buildall

@hello-stephen
Copy link
Copy Markdown
Contributor

TPC-H: Total hot run time: 31501 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 07b8de956201f76a0db0683f0bfe4e6934279929, 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	17732	3909	3898	3898
q2	q3	10779	1406	810	810
q4	4681	483	350	350
q5	8062	2317	2166	2166
q6	247	186	140	140
q7	955	796	663	663
q8	9440	1692	1589	1589
q9	5147	4935	5015	4935
q10	6430	2080	1778	1778
q11	441	279	244	244
q12	639	426	296	296
q13	18100	3461	2880	2880
q14	265	266	231	231
q15	q16	813	802	711	711
q17	929	915	1000	915
q18	7002	5784	5553	5553
q19	1172	1239	1109	1109
q20	644	464	297	297
q21	5954	2922	2624	2624
q22	455	395	312	312
Total cold run time: 99887 ms
Total hot run time: 31501 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	4731	4523	4565	4523
q2	q3	4913	5256	4653	4653
q4	2134	2204	1459	1459
q5	4948	4650	4592	4592
q6	243	185	131	131
q7	1918	1742	1541	1541
q8	2401	2091	2140	2091
q9	7700	7340	7130	7130
q10	4455	4437	4037	4037
q11	532	381	355	355
q12	709	737	510	510
q13	3033	3422	2752	2752
q14	265	286	254	254
q15	q16	685	705	615	615
q17	1273	1257	1252	1252
q18	7443	6702	6787	6702
q19	1097	1095	1127	1095
q20	2232	2231	1941	1941
q21	5381	4744	4485	4485
q22	521	453	418	418
Total cold run time: 56614 ms
Total hot run time: 50536 ms

@hello-stephen
Copy link
Copy Markdown
Contributor

TPC-DS: Total hot run time: 170061 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 07b8de956201f76a0db0683f0bfe4e6934279929, data reload: false

query5	4345	656	516	516
query6	340	221	208	208
query7	4265	551	306	306
query8	323	272	228	228
query9	8846	4044	4001	4001
query10	462	364	309	309
query11	5851	2408	2158	2158
query12	193	132	130	130
query13	1285	619	416	416
query14	5932	5382	5120	5120
query14_1	4401	4377	4373	4373
query15	214	205	183	183
query16	1007	418	470	418
query17	974	748	617	617
query18	2460	494	365	365
query19	222	206	173	173
query20	139	133	129	129
query21	222	145	121	121
query22	13576	13554	13382	13382
query23	17374	16420	16101	16101
query23_1	16268	16256	16232	16232
query24	7496	1783	1304	1304
query24_1	1281	1307	1326	1307
query25	549	477	406	406
query26	1284	321	171	171
query27	2694	552	337	337
query28	4434	1944	1959	1944
query29	962	613	485	485
query30	323	238	196	196
query31	1106	1064	942	942
query32	87	74	71	71
query33	534	350	290	290
query34	1187	1166	649	649
query35	757	786	662	662
query36	1328	1332	1112	1112
query37	155	104	90	90
query38	3225	3146	3053	3053
query39	928	928	915	915
query39_1	898	896	883	883
query40	233	145	129	129
query41	67	63	62	62
query42	111	111	109	109
query43	317	334	291	291
query44	
query45	204	204	203	203
query46	1079	1179	746	746
query47	2328	2381	2190	2190
query48	401	433	303	303
query49	639	498	383	383
query50	978	350	254	254
query51	4380	4284	4230	4230
query52	109	107	97	97
query53	259	285	205	205
query54	309	274	265	265
query55	92	89	87	87
query56	304	315	303	303
query57	1399	1403	1309	1309
query58	300	271	267	267
query59	1552	1631	1405	1405
query60	349	339	322	322
query61	186	180	184	180
query62	676	611	578	578
query63	245	208	212	208
query64	2494	867	695	695
query65	
query66	1719	506	372	372
query67	30043	29997	29909	29909
query68	
query69	467	342	318	318
query70	1032	1009	1004	1004
query71	320	285	276	276
query72	3001	2698	2414	2414
query73	860	808	445	445
query74	5030	4913	4716	4716
query75	2668	2650	2264	2264
query76	2330	1147	739	739
query77	393	407	332	332
query78	12167	12159	11558	11558
query79	1420	984	739	739
query80	645	552	454	454
query81	457	278	241	241
query82	1355	159	124	124
query83	359	279	253	253
query84	305	143	117	117
query85	884	574	450	450
query86	415	314	307	307
query87	3388	3384	3221	3221
query88	3485	2638	2646	2638
query89	442	393	340	340
query90	1985	187	178	178
query91	179	171	151	151
query92	82	77	74	74
query93	1549	1386	882	882
query94	562	375	305	305
query95	691	475	352	352
query96	1055	794	331	331
query97	2740	2713	2567	2567
query98	241	232	233	232
query99	1108	1110	975	975
Total cold run time: 253346 ms
Total hot run time: 170061 ms

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