Skip to content

[Enhancement](ms) Add sharded LRU cache for tablet index metadata to reduce FDB IO#61666

Open
wyxxxcat wants to merge 1 commit intoapache:masterfrom
wyxxxcat:ms_lru_cache
Open

[Enhancement](ms) Add sharded LRU cache for tablet index metadata to reduce FDB IO#61666
wyxxxcat wants to merge 1 commit intoapache:masterfrom
wyxxxcat:ms_lru_cache

Conversation

@wyxxxcat
Copy link
Copy Markdown
Collaborator

@wyxxxcat wyxxxcat commented Mar 24, 2026

Summary

This commit mainly does three things:

  1. Move lru_cache from be/src/util/ to common/cpp/ so Cloud components can reuse the same ShardedLRUCache implementation.
  2. Hook BE LRUCachePolicy into a unified cache metrics recorder, including capacity, usage, hit ratio, lookup/hit/miss, and stampede metrics.
  3. Add a tablet index KV cache to Cloud MetaService and Recycler, introduce capacity and TTL configs, invalidate cache entries when tablet index records are removed, and add Cloud-side unit tests.

What problem does this PR solve?

Issue Number: None

Related PR: None

Problem Summary:
Cloud tablet index lookups in meta service and recycler repeatedly read from txn kv, while
the LRU cache implementation was only available under BE utility code and could not be reused
directly by cloud components. This change moves the shared LRU cache into common code, adds
a cloud KV cache wrapper for tablet index metadata with configurable capacity and TTL, wires
cache invalidation into recycler cleanup, and hooks BE LRU caches into unified cache metrics.

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?

@wyxxxcat wyxxxcat force-pushed the ms_lru_cache branch 2 times, most recently from 4311778 to 6b47a05 Compare March 24, 2026 09:26
@wyxxxcat
Copy link
Copy Markdown
Collaborator Author

run buildall

@wyxxxcat wyxxxcat force-pushed the ms_lru_cache branch 3 times, most recently from 3065073 to e15e9bc Compare March 30, 2026 06:15
@wyxxxcat
Copy link
Copy Markdown
Collaborator Author

run buildall

@wyxxxcat wyxxxcat marked this pull request as ready for review March 30, 2026 07:04
@wyxxxcat
Copy link
Copy Markdown
Collaborator Author

/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.

Code Review Summary

This PR adds a sharded LRU cache for meta_tablet_idx_key lookups in both MetaService and Recycler, and also refactors the LRU cache from be/src/util/ to common/cpp/ to share it with the Cloud module. The refactoring to separate metrics from the core cache is well-structured.

However, I found several issues ranging from correctness to performance concerns.

Critical Checkpoint Conclusions

1. Goal and Correctness: The goal is to cache immutable tablet index metadata to reduce FDB reads. The core caching logic works, but there are missing cache invalidation paths in the MetaService (see below), and the LOG(INFO) on every cache hit is a performance anti-pattern that will flood logs.

2. Minimal and Focused: The PR mixes two independent concerns: (a) LRU cache refactoring from BE to common/cpp with metrics extraction, and (b) adding KvCache for cloud. These should ideally be separate PRs, but this is a style concern.

3. Concurrency: The ShardedLRUCache handles concurrency via per-shard mutexes. The g_ms_cache_manager and g_recycler_cache_manager globals are initialized once and read concurrently thereafter (the cache methods are thread-safe). No concurrency issues found.

4. Lifecycle Management: Both g_ms_cache_manager and g_recycler_cache_manager are allocated with new but never deleted. This is an intentional process-lifetime pattern but creates issues: (a) If MetaServiceImpl is constructed multiple times (e.g., in tests), the old cache pointer leaks. (b) ASAN/LeakSanitizer will flag these.

5. Configuration: New configs (enable_tablet_index_cache, ms_tablet_index_cache_capacity, etc.) are CONF_mBool/CONF_mInt64 (mutable), but the cache is only created once at startup. Changing these configs at runtime has no effect - the cache won't be resized or recreated. Either make them non-mutable or implement runtime reconfiguration.

6. Incompatible Changes: The LRU cache insert() now requires an explicit CacheValueDeleter parameter where it previously defaulted to nullptr. All existing callers are updated. No incompatibility concern.

7. Parallel Code Paths: The MS cache lacks invalidation in repair_tablet_index (meta_service_txn.cpp:2150) and fix_tablet_db_id (meta_service.cpp:5719) which modify TabletIndexPB.db_id via txn->put() without invalidating the cache.

8. Test Coverage: Unit tests cover basic get/put, eviction, invalidation, clear, and concurrent access. Missing: TTL expiration test, test for the key encoding edge cases, integration test verifying cache correctness with actual MS operations.

9. Observability: Cache hit/miss metrics are not added for the cloud KvCache (only for BE LRU caches via BELRUCacheMetricsRecorder). The LOG(INFO) on every cache hit is not a substitute for proper metrics.

10. Performance: The LOG(INFO) on every cache hit is the most significant performance issue - this function is called on hot paths like commit_txn, and the whole point is to reduce overhead.

11. Missing blank line between init_recycler_cache() closing brace and namespace config { in recycler/util.cpp.

@wyxxxcat
Copy link
Copy Markdown
Collaborator Author

run buildall

@doris-robot
Copy link
Copy Markdown

TPC-H: Total hot run time: 26844 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 8d0e9b8f0db6b371de2f4bfe8e28a4fe03fc6eca, 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	17630	4487	4311	4311
q2	q3	10638	799	524	524
q4	4684	381	251	251
q5	7558	1221	1043	1043
q6	174	173	145	145
q7	796	839	683	683
q8	9848	1516	1329	1329
q9	5050	4986	4728	4728
q10	6331	1950	1669	1669
q11	489	245	258	245
q12	746	575	469	469
q13	18091	2744	1930	1930
q14	225	236	212	212
q15	q16	729	738	671	671
q17	773	866	460	460
q18	5993	5458	5293	5293
q19	1413	967	610	610
q20	542	496	393	393
q21	4505	1841	1604	1604
q22	488	366	274	274
Total cold run time: 96703 ms
Total hot run time: 26844 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	4905	4688	4551	4551
q2	q3	3881	4363	3833	3833
q4	873	1200	801	801
q5	4150	4485	4369	4369
q6	182	177	140	140
q7	1767	1685	1525	1525
q8	2533	2703	2621	2621
q9	7689	7450	7422	7422
q10	3860	4016	3604	3604
q11	528	432	420	420
q12	494	617	465	465
q13	2596	3008	2056	2056
q14	281	318	302	302
q15	q16	724	758	704	704
q17	1213	1365	1377	1365
q18	7229	6896	6589	6589
q19	899	941	917	917
q20	2088	2162	1997	1997
q21	4067	3548	3329	3329
q22	461	445	379	379
Total cold run time: 50420 ms
Total hot run time: 47389 ms

@doris-robot
Copy link
Copy Markdown

TPC-DS: Total hot run time: 169470 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 8d0e9b8f0db6b371de2f4bfe8e28a4fe03fc6eca, data reload: false

query5	4357	647	508	508
query6	345	227	201	201
query7	4223	466	264	264
query8	347	238	227	227
query9	8710	2732	2733	2732
query10	553	406	326	326
query11	6989	5099	4891	4891
query12	181	132	123	123
query13	1274	483	358	358
query14	5665	3704	3463	3463
query14_1	2876	2900	2844	2844
query15	209	201	179	179
query16	1001	469	476	469
query17	1018	702	588	588
query18	2438	441	350	350
query19	218	206	181	181
query20	130	125	125	125
query21	213	136	112	112
query22	13481	14336	14611	14336
query23	16779	16298	15988	15988
query23_1	16167	16059	15576	15576
query24	7200	1626	1233	1233
query24_1	1230	1234	1224	1224
query25	533	464	417	417
query26	1238	258	151	151
query27	2783	492	298	298
query28	4502	1853	1862	1853
query29	877	559	469	469
query30	302	223	190	190
query31	993	968	868	868
query32	89	68	69	68
query33	508	337	288	288
query34	904	857	521	521
query35	635	690	612	612
query36	1038	1119	996	996
query37	130	94	82	82
query38	2946	2899	2886	2886
query39	857	845	826	826
query39_1	795	805	796	796
query40	237	151	135	135
query41	66	62	59	59
query42	257	254	258	254
query43	247	244	223	223
query44	
query45	231	189	187	187
query46	881	985	608	608
query47	2173	2115	2064	2064
query48	311	323	227	227
query49	630	461	398	398
query50	680	292	205	205
query51	4068	4055	4009	4009
query52	268	269	257	257
query53	291	346	289	289
query54	316	265	265	265
query55	92	85	91	85
query56	325	313	302	302
query57	1835	1700	1675	1675
query58	276	284	267	267
query59	2783	2973	2753	2753
query60	334	335	316	316
query61	158	148	153	148
query62	632	583	536	536
query63	307	283	276	276
query64	5133	1271	1023	1023
query65	
query66	1473	454	370	370
query67	24476	24323	24222	24222
query68	
query69	414	322	307	307
query70	1006	940	939	939
query71	346	321	313	313
query72	3120	2886	2648	2648
query73	545	553	317	317
query74	9652	9648	9473	9473
query75	2900	2777	2507	2507
query76	2275	1044	698	698
query77	369	409	312	312
query78	10917	11050	10501	10501
query79	3180	778	560	560
query80	1731	613	527	527
query81	574	262	222	222
query82	1019	154	121	121
query83	334	267	248	248
query84	281	126	97	97
query85	917	483	466	466
query86	496	293	302	293
query87	3158	3139	2994	2994
query88	3587	2671	2656	2656
query89	431	369	344	344
query90	2073	192	177	177
query91	175	164	137	137
query92	83	78	74	74
query93	1606	839	506	506
query94	653	311	296	296
query95	574	338	324	324
query96	641	517	228	228
query97	2452	2512	2386	2386
query98	238	224	238	224
query99	1017	1001	913	913
Total cold run time: 254485 ms
Total hot run time: 169470 ms

@wyxxxcat
Copy link
Copy Markdown
Collaborator Author

run p0

@wyxxxcat wyxxxcat force-pushed the ms_lru_cache branch 4 times, most recently from d70b6c8 to 4c0db13 Compare April 1, 2026 02:51
@wyxxxcat
Copy link
Copy Markdown
Collaborator Author

wyxxxcat commented Apr 1, 2026

run buildall

@hello-stephen
Copy link
Copy Markdown
Contributor

Cloud UT Coverage Report

Increment line coverage 68.35% (108/158) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 78.09% (1846/2364)
Line Coverage 64.04% (32715/51083)
Region Coverage 64.90% (16378/25235)
Branch Coverage 55.33% (8724/15766)

@wyxxxcat
Copy link
Copy Markdown
Collaborator Author

wyxxxcat commented Apr 1, 2026

run buildall

@doris-robot
Copy link
Copy Markdown

TPC-H: Total hot run time: 26581 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 3d6117ddfee4422530926cef13fcfd1162c1a1ba, 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	17634	4440	4318	4318
q2	q3	10665	785	524	524
q4	4681	348	256	256
q5	7565	1210	1014	1014
q6	170	172	143	143
q7	771	843	666	666
q8	9304	1481	1355	1355
q9	4786	4790	4727	4727
q10	6251	1933	1655	1655
q11	456	269	247	247
q12	699	580	465	465
q13	18037	2686	1939	1939
q14	223	229	205	205
q15	q16	719	743	664	664
q17	748	840	445	445
q18	6030	5377	5291	5291
q19	1119	985	616	616
q20	534	488	377	377
q21	4377	1866	1422	1422
q22	347	297	252	252
Total cold run time: 95116 ms
Total hot run time: 26581 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	4877	4711	4614	4614
q2	q3	3909	4352	3856	3856
q4	864	1233	795	795
q5	4113	4402	4340	4340
q6	186	180	145	145
q7	1781	1607	1548	1548
q8	2507	2756	2561	2561
q9	7617	7468	7493	7468
q10	3788	4025	3571	3571
q11	526	460	416	416
q12	482	597	444	444
q13	2496	2906	2103	2103
q14	279	297	289	289
q15	q16	711	753	713	713
q17	1141	1319	1321	1319
q18	7337	6881	6884	6881
q19	908	919	886	886
q20	2154	2210	2028	2028
q21	3930	3641	3282	3282
q22	463	419	384	384
Total cold run time: 50069 ms
Total hot run time: 47643 ms

@wyxxxcat
Copy link
Copy Markdown
Collaborator Author

wyxxxcat commented Apr 1, 2026

run buildall

@doris-robot
Copy link
Copy Markdown

Cloud UT Coverage Report

Increment line coverage 71.93% (123/171) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 78.11% (1848/2366)
Line Coverage 64.03% (32719/51097)
Region Coverage 64.88% (16375/25237)
Branch Coverage 55.28% (8715/15766)

@doris-robot
Copy link
Copy Markdown

TPC-H: Total hot run time: 29461 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit ac4b5946d5b954cb8a1e232cda952d4813960cc8, 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	17727	3909	3814	3814
q2	q3	10673	884	621	621
q4	4680	472	361	361
q5	7460	1351	1173	1173
q6	187	164	136	136
q7	924	977	775	775
q8	9327	1494	1342	1342
q9	5662	5354	5259	5259
q10	6323	2042	1784	1784
q11	491	278	282	278
q12	852	693	516	516
q13	18046	2797	2157	2157
q14	284	291	263	263
q15	q16	905	860	783	783
q17	1027	1034	798	798
q18	6511	5806	5557	5557
q19	1200	1288	1046	1046
q20	617	551	405	405
q21	4780	2447	2037	2037
q22	478	407	356	356
Total cold run time: 98154 ms
Total hot run time: 29461 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	4469	4349	4425	4349
q2	q3	4631	4820	4147	4147
q4	2022	2146	1331	1331
q5	4939	5000	5346	5000
q6	197	172	133	133
q7	2088	1798	1600	1600
q8	3323	3047	3045	3045
q9	8236	8347	8371	8347
q10	4516	4534	4371	4371
q11	589	404	415	404
q12	815	741	500	500
q13	2755	3333	2383	2383
q14	318	308	266	266
q15	q16	805	762	686	686
q17	1317	1334	1268	1268
q18	7998	7026	7218	7026
q19	1208	1219	1128	1128
q20	2243	2194	1978	1978
q21	6281	5400	5021	5021
q22	576	560	436	436
Total cold run time: 59326 ms
Total hot run time: 53419 ms

@doris-robot
Copy link
Copy Markdown

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

query5	4341	669	524	524
query6	343	235	205	205
query7	4216	567	336	336
query8	333	245	229	229
query9	8755	3943	3917	3917
query10	499	387	359	359
query11	6678	5493	5143	5143
query12	194	137	135	135
query13	1320	636	461	461
query14	5629	5234	4781	4781
query14_1	4186	4172	4148	4148
query15	210	205	184	184
query16	1013	464	460	460
query17	1154	778	661	661
query18	2529	520	393	393
query19	259	232	192	192
query20	143	135	134	134
query21	231	152	126	126
query22	14045	14630	14416	14416
query23	18196	17176	16774	16774
query23_1	17246	16966	17169	16966
query24	8214	1981	1417	1417
query24_1	1412	1363	1380	1363
query25	579	493	437	437
query26	1256	324	178	178
query27	2652	585	372	372
query28	4467	1895	1856	1856
query29	966	650	565	565
query30	307	235	194	194
query31	1090	1055	945	945
query32	98	77	79	77
query33	534	341	294	294
query34	1181	1162	653	653
query35	742	774	656	656
query36	1202	1237	1073	1073
query37	152	98	89	89
query38	3120	3035	2957	2957
query39	915	902	847	847
query39_1	853	829	827	827
query40	234	160	139	139
query41	63	59	98	59
query42	274	268	281	268
query43	315	320	279	279
query44	
query45	210	197	194	194
query46	1162	1285	773	773
query47	2332	2345	2225	2225
query48	411	398	298	298
query49	631	538	440	440
query50	726	288	215	215
query51	4343	4292	4246	4246
query52	279	282	271	271
query53	329	347	267	267
query54	321	285	277	277
query55	98	95	95	95
query56	319	314	327	314
query57	1669	1753	1620	1620
query58	301	277	268	268
query59	2874	2972	2748	2748
query60	336	344	327	327
query61	155	153	153	153
query62	683	623	579	579
query63	313	271	276	271
query64	5396	1448	1128	1128
query65	
query66	1483	467	364	364
query67	24393	24458	24224	24224
query68	
query69	448	333	311	311
query70	1007	1009	985	985
query71	365	315	315	315
query72	2982	2723	2461	2461
query73	794	816	452	452
query74	9873	9797	9533	9533
query75	3575	3384	3007	3007
query76	2314	1139	785	785
query77	412	418	353	353
query78	11307	11382	10744	10744
query79	1495	1093	819	819
query80	847	752	651	651
query81	456	285	245	245
query82	1311	162	122	122
query83	323	287	262	262
query84	263	144	117	117
query85	864	495	470	470
query86	382	314	309	309
query87	3296	3210	3087	3087
query88	3581	2683	2700	2683
query89	476	424	378	378
query90	1972	191	187	187
query91	181	167	149	149
query92	77	78	72	72
query93	909	893	509	509
query94	556	344	285	285
query95	665	458	340	340
query96	1039	802	333	333
query97	2697	2672	2563	2563
query98	245	234	225	225
query99	1075	1081	970	970
Total cold run time: 260130 ms
Total hot run time: 180413 ms

@wyxxxcat
Copy link
Copy Markdown
Collaborator Author

wyxxxcat commented Apr 2, 2026

run buildall

@doris-robot
Copy link
Copy Markdown

Cloud UT Coverage Report

Increment line coverage 70.76% (121/171) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 78.11% (1848/2366)
Line Coverage 64.06% (32742/51111)
Region Coverage 64.91% (16386/25245)
Branch Coverage 55.33% (8726/15772)

@doris-robot
Copy link
Copy Markdown

TPC-H: Total hot run time: 29454 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 6c7a62a3bc65614f441d81499d039babc522b35b, 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	17704	3699	3664	3664
q2	q3	10689	874	607	607
q4	4682	480	355	355
q5	7470	1359	1163	1163
q6	214	161	139	139
q7	925	963	794	794
q8	9600	1446	1303	1303
q9	5577	5309	5292	5292
q10	6314	2032	1813	1813
q11	489	285	273	273
q12	881	684	504	504
q13	18033	2784	2143	2143
q14	282	285	261	261
q15	q16	903	844	784	784
q17	1019	1086	896	896
q18	6389	5584	5615	5584
q19	1153	1185	1090	1090
q20	590	554	411	411
q21	4873	2470	2031	2031
q22	456	394	347	347
Total cold run time: 98243 ms
Total hot run time: 29454 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	4346	4456	4264	4264
q2	q3	4617	4757	4150	4150
q4	2025	2090	1334	1334
q5	4872	4978	5180	4978
q6	196	170	131	131
q7	2025	1769	1603	1603
q8	3493	3215	3059	3059
q9	8385	8362	8198	8198
q10	4453	4403	4191	4191
q11	565	400	394	394
q12	765	782	492	492
q13	2636	3071	2236	2236
q14	301	291	285	285
q15	q16	754	785	689	689
q17	1301	1286	1317	1286
q18	8174	7114	7190	7114
q19	1202	1111	1162	1111
q20	2215	2201	1950	1950
q21	5982	5267	4893	4893
q22	532	498	436	436
Total cold run time: 58839 ms
Total hot run time: 52794 ms

@doris-robot
Copy link
Copy Markdown

TPC-DS: Total hot run time: 180364 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 6c7a62a3bc65614f441d81499d039babc522b35b, data reload: false

query5	4347	660	514	514
query6	355	227	207	207
query7	4220	560	330	330
query8	336	239	228	228
query9	8734	3906	3923	3906
query10	480	384	348	348
query11	6810	5493	5184	5184
query12	200	134	130	130
query13	1311	613	446	446
query14	5660	5169	4777	4777
query14_1	4151	4110	4119	4110
query15	211	211	179	179
query16	1011	519	502	502
query17	1154	795	662	662
query18	2528	526	378	378
query19	245	232	190	190
query20	143	137	134	134
query21	226	148	120	120
query22	13999	14593	14516	14516
query23	17943	17194	16892	16892
query23_1	16782	16909	17018	16909
query24	7843	1730	1367	1367
query24_1	1356	1349	1353	1349
query25	628	544	438	438
query26	1279	317	177	177
query27	2676	656	383	383
query28	4433	1892	1905	1892
query29	997	678	559	559
query30	304	238	191	191
query31	1084	1045	944	944
query32	83	73	71	71
query33	546	359	290	290
query34	1186	1154	669	669
query35	736	773	663	663
query36	1260	1269	1134	1134
query37	152	96	87	87
query38	3105	3026	2987	2987
query39	922	901	850	850
query39_1	837	825	832	825
query40	234	157	136	136
query41	63	60	59	59
query42	282	287	277	277
query43	325	323	271	271
query44	
query45	210	197	187	187
query46	1157	1272	799	799
query47	2363	2307	2222	2222
query48	403	417	311	311
query49	634	540	428	428
query50	705	281	212	212
query51	4347	4218	4221	4218
query52	281	281	266	266
query53	332	347	267	267
query54	322	285	288	285
query55	100	95	89	89
query56	320	315	314	314
query57	1742	1688	1664	1664
query58	301	276	280	276
query59	2867	2965	2715	2715
query60	334	338	329	329
query61	154	156	172	156
query62	699	623	588	588
query63	335	276	271	271
query64	5280	1433	1094	1094
query65	
query66	1470	481	381	381
query67	24396	24263	24074	24074
query68	
query69	441	336	305	305
query70	1043	1036	969	969
query71	365	335	312	312
query72	2941	2724	2497	2497
query73	774	815	433	433
query74	9867	9701	9582	9582
query75	3554	3375	2990	2990
query76	2288	1119	720	720
query77	391	429	320	320
query78	11297	11382	10751	10751
query79	1548	1106	816	816
query80	1396	765	683	683
query81	520	283	245	245
query82	983	161	122	122
query83	332	287	256	256
query84	256	144	117	117
query85	916	500	468	468
query86	458	334	329	329
query87	3278	3179	3073	3073
query88	3560	2720	2674	2674
query89	475	409	376	376
query90	2037	173	173	173
query91	179	174	149	149
query92	80	75	71	71
query93	1052	889	513	513
query94	716	297	302	297
query95	673	363	424	363
query96	1032	779	319	319
query97	2696	2695	2556	2556
query98	238	234	225	225
query99	1086	1075	963	963
Total cold run time: 260005 ms
Total hot run time: 180364 ms

@wyxxxcat
Copy link
Copy Markdown
Collaborator Author

wyxxxcat commented Apr 3, 2026

run buildall

@doris-robot
Copy link
Copy Markdown

Cloud UT Coverage Report

Increment line coverage 71.93% (123/171) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 78.11% (1848/2366)
Line Coverage 64.06% (32740/51111)
Region Coverage 64.87% (16376/25245)
Branch Coverage 55.33% (8726/15772)

@doris-robot
Copy link
Copy Markdown

TPC-H: Total hot run time: 29474 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit c3f46de5f6580b0124fb5b5c166d0a5d546186f6, 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	17723	3838	3789	3789
q2	q3	10680	871	596	596
q4	4684	461	359	359
q5	7470	1352	1163	1163
q6	186	169	139	139
q7	916	978	779	779
q8	9334	1429	1309	1309
q9	5736	5335	5299	5299
q10	6304	2060	1773	1773
q11	481	277	285	277
q12	901	693	514	514
q13	18038	2793	2177	2177
q14	284	281	260	260
q15	q16	900	870	786	786
q17	1107	1135	814	814
q18	6550	5707	5615	5615
q19	1434	1216	1042	1042
q20	634	553	405	405
q21	4809	2437	2029	2029
q22	493	415	349	349
Total cold run time: 98664 ms
Total hot run time: 29474 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	4760	4540	4524	4524
q2	q3	4642	4740	4170	4170
q4	2066	2115	1352	1352
q5	5030	5045	5255	5045
q6	213	178	139	139
q7	2035	1763	1627	1627
q8	3321	3046	3086	3046
q9	8260	8441	8365	8365
q10	4549	4477	4202	4202
q11	602	404	393	393
q12	672	752	499	499
q13	2861	3088	2423	2423
q14	287	307	281	281
q15	q16	808	779	715	715
q17	1342	1368	1282	1282
q18	7971	7206	7136	7136
q19	1133	1153	1143	1143
q20	2249	2190	1967	1967
q21	6135	5485	4959	4959
q22	554	509	443	443
Total cold run time: 59490 ms
Total hot run time: 53711 ms

@doris-robot
Copy link
Copy Markdown

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

query5	4337	676	523	523
query6	340	236	220	220
query7	4207	578	335	335
query8	360	243	236	236
query9	8744	3936	3951	3936
query10	493	397	353	353
query11	6677	5532	5164	5164
query12	194	134	130	130
query13	1273	591	472	472
query14	5824	5281	4794	4794
query14_1	4149	4145	4180	4145
query15	220	222	190	190
query16	1014	486	397	397
query17	1156	814	676	676
query18	2645	519	397	397
query19	259	231	196	196
query20	146	138	132	132
query21	226	147	125	125
query22	15335	15167	14542	14542
query23	18433	17296	16820	16820
query23_1	16869	16772	17165	16772
query24	7523	1778	1404	1404
query24_1	1376	1370	1399	1370
query25	620	540	420	420
query26	1309	334	174	174
query27	2577	635	377	377
query28	4455	1902	1892	1892
query29	1007	671	580	580
query30	307	245	201	201
query31	1118	1076	965	965
query32	88	72	72	72
query33	551	370	298	298
query34	1197	1166	692	692
query35	754	775	665	665
query36	1238	1236	1122	1122
query37	152	98	87	87
query38	3127	3054	2975	2975
query39	926	907	854	854
query39_1	842	840	842	840
query40	235	164	144	144
query41	62	60	59	59
query42	290	277	276	276
query43	317	317	281	281
query44	
query45	209	238	192	192
query46	1181	1248	802	802
query47	2302	2364	2232	2232
query48	419	432	313	313
query49	640	538	431	431
query50	712	305	229	229
query51	4353	4328	4260	4260
query52	302	297	273	273
query53	320	352	272	272
query54	328	294	282	282
query55	107	93	90	90
query56	340	335	328	328
query57	1685	1742	1535	1535
query58	303	289	275	275
query59	2907	2987	2750	2750
query60	361	346	335	335
query61	156	152	160	152
query62	685	635	548	548
query63	316	273	269	269
query64	5389	1431	1113	1113
query65	
query66	1440	477	378	378
query67	24791	24709	24702	24702
query68	
query69	460	350	332	332
query70	1034	1012	1006	1006
query71	368	324	319	319
query72	3038	2820	2466	2466
query73	796	788	416	416
query74	9911	9747	9550	9550
query75	3661	3422	3048	3048
query76	2328	1159	788	788
query77	402	428	342	342
query78	11833	11841	11093	11093
query79	1541	1139	825	825
query80	954	755	644	644
query81	503	288	253	253
query82	1366	163	135	135
query83	347	296	269	269
query84	264	152	122	122
query85	923	523	468	468
query86	419	341	334	334
query87	3345	3270	3126	3126
query88	3600	2699	2714	2699
query89	476	422	385	385
query90	1913	193	186	186
query91	182	171	139	139
query92	77	76	71	71
query93	906	894	512	512
query94	599	327	293	293
query95	651	461	334	334
query96	1050	814	335	335
query97	2698	2651	2553	2553
query98	243	241	223	223
query99	1074	1063	962	962
Total cold run time: 262339 ms
Total hot run time: 181857 ms

@hello-stephen
Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 52.94% (20036/37846)
Line Coverage 36.55% (188378/515404)
Region Coverage 32.81% (146247/445782)
Branch Coverage 33.97% (64059/188589)

@hello-stephen
Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 94.22% (440/467) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 73.62% (27295/37077)
Line Coverage 57.22% (294058/513870)
Region Coverage 54.43% (244900/449943)
Branch Coverage 56.18% (106271/189177)

@hello-stephen
Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 85.93% (989/1151) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 73.62% (27295/37077)
Line Coverage 57.22% (294032/513870)
Region Coverage 54.44% (244969/449943)
Branch Coverage 56.16% (106251/189177)

Comment on lines +98 to +99
_cache->release(handle);
_cache->erase(CacheKey(encoded_key));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

After releasing and then erasing here, is there a possibility of a race condition?

For example, multiple threads might obtain the same handle, all determine that the TTL has expired, and then attempt to erase simultaneously.

If, during this process, a thread executes a put operation, it could be erased unexpectedly. This doesn’t seem like a critical issue, but perhaps we can explore a better solution.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The solution is to release the data and return false immediately upon detecting an expired TTL during a get op instead of deleting it. This continues until a subsequent put operation evicts the data

@wyxxxcat wyxxxcat force-pushed the ms_lru_cache branch 2 times, most recently from 61ab109 to 913d227 Compare April 15, 2026 01:54
@wyxxxcat
Copy link
Copy Markdown
Collaborator Author

run buildall

@wyxxxcat wyxxxcat force-pushed the ms_lru_cache branch 2 times, most recently from 11c72dc to f56e0b0 Compare April 15, 2026 02:54
@wyxxxcat
Copy link
Copy Markdown
Collaborator Author

run buildall

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.

5 participants