Skip to content

[improvement](be) Add disk cache for external file metadata#63376

Open
xylaaaaa wants to merge 10 commits into
apache:masterfrom
xylaaaaa:codex/file-meta-cache-disk-pr
Open

[improvement](be) Add disk cache for external file metadata#63376
xylaaaaa wants to merge 10 commits into
apache:masterfrom
xylaaaaa:codex/file-meta-cache-disk-pr

Conversation

@xylaaaaa

@xylaaaaa xylaaaaa commented May 19, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: N/A

Related PR: #64961

Problem Summary:
External Parquet/ORC footer metadata was only cached in BE memory. After memory cache eviction or BE restart, repeated reads from remote storage such as S3/HDFS had to fetch footer metadata remotely again.

This PR builds on the FileMetaCache persistent-cache interface from #64961 and adds a default-enabled disk-backed layer for external file metadata. The disk layer is implemented behind the FileMetaCache boundary: readers call the file-meta-cache lookup/insert APIs, and only FileMetaDiskCache adapts those calls to the existing BlockFileCache primitives.

Lookup/write flow:

  • Readers first check the existing memory ObjLRUCache using a format-scoped memory key.
  • On memory miss, FileMetaCache asks FileMetaDiskCache for serialized footer bytes stored in the existing BlockFileCache INDEX queue.
  • On total miss, readers parse footer metadata from the file and write it back to memory and, when the serialized payload is eligible, to disk.
  • Persistent cache entries require a stable file identity. If the scan range has no positive modification time, disk lookup/write is skipped to avoid stale or cross-file reuse.

Main changes:

  • Add FileMetaDiskCache, a FileMetaPersistentCache implementation backed by BlockFileCache.
  • Reuse the existing file cache INDEX queue and file_cache_path; no new file-cache queue or standalone storage is added.
  • Add enable_external_file_meta_disk_cache (default true) and external_file_meta_disk_cache_max_entry_bytes (default 64 MiB).
  • Initialize file-cache infrastructure when file meta disk cache is enabled, even if data file cache is disabled.
  • Persist validated Parquet/ORC footer payloads with format, file size, mtime, payload size, and checksum metadata.
  • Include path, mtime, and file size in persistent cache identity.
  • Separate legacy Parquet and v2 Parquet cache formats to avoid mixing incompatible payloads or memory objects.
  • Treat incomplete/missing disk-cache ranges as cache misses without invalidating concurrent in-flight writers.
  • Invalidate and fall back to file reads only for malformed or checksum-invalid persistent payloads.
  • Preserve the existing memory cache path and backfill memory after disk hits when memory cache is enabled.
  • Add reader profile counters for memory hit, disk hit, disk miss, disk write, and disk read/write time.
  • Add focused BE unit coverage for the cache wrapper, disk-cache-backed lookup path, corruption fallback, race/missing-range behavior, and v2 Parquet integration.

Release note

Add a default-enabled disk-backed cache for external Parquet/ORC file metadata. The cache stores eligible serialized footer metadata in the existing local file cache INDEX queue and is controlled by enable_external_file_meta_disk_cache and external_file_meta_disk_cache_max_entry_bytes.

Check List (For Author)

  • Test: Unit Test / Manual test / Code style check
    • git diff --check
    • git diff --cached --check
    • ./run-be-ut.sh --run --filter='*FileMeta*' -j 2
    • ./build.sh --be -j 4
    • Manual e2e with local output/ FE/BE: Parquet local TVF returned count(*) = 25 twice; the second query profile showed FileFooterHitMemoryCache = 1 and ScanBytes dropped from 36.65 KB to 156 B.
    • Manual e2e with local output/ FE/BE: ORC local TVF returned count(*) = 25 twice; the second query profile showed FileFooterHitMemoryCache = 1 and ScanBytes dropped from 16.48 KB to 488 B.
    • Note: local TVF does not populate modification_time, so persistent disk cache is intentionally skipped on that path. The persistent disk behavior is covered by FileMetaCacheDiskTest and NewParquetReaderTest in the *FileMeta* BE UT run.
  • Behavior changed: Yes. External Parquet/ORC footer metadata disk cache is enabled by default. Eligible metadata can persist in the local file cache and be reused after memory eviction or BE restart. The disk layer reuses the existing file cache INDEX queue and its capacity/eviction policy, and requires stable file identity before persisting metadata.
  • Does this need documentation: Yes. Config documentation should describe default-on enable_external_file_meta_disk_cache, external_file_meta_disk_cache_max_entry_bytes, and that persisted metadata reuses the existing INDEX file cache queue.

Copilot AI review requested due to automatic review settings May 19, 2026 01:58
@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?

xylaaaaa added a commit to xylaaaaa/doris that referenced this pull request May 20, 2026
### What problem does this PR solve?

Issue Number: None

Related PR: apache#63376

Problem Summary: Stabilize file meta disk cache related BE unit tests by isolating disk resource limit configuration, initializing FD cache for direct FS storage, and ensuring TTL cache test data carries an expiration time.

### Release note

None

### Check List (For Author)

- Test: Unit Test
    - ./run-be-ut.sh --run --filter=FileMetaDiskCacheTest.* -j 8
    - ./run-be-ut.sh --run --filter=BlockFileCacheTest.file_cache_path_storage_parse:BlockFileCacheTest.file_meta_disk_cache_initializes_without_data_file_cache:BlockFileCacheTest.meta_queue_can_evict_data_cache_first:BlockFileCacheTest.normal_queue_does_not_evict_meta_cache:BlockFileCacheTest.read_if_cached_returns_downloaded_meta_block -j 8
- Behavior changed: No
- Does this need documentation: No
xylaaaaa added a commit to xylaaaaa/doris that referenced this pull request May 20, 2026
### What problem does this PR solve?

Issue Number: None

Related PR: apache#63376

Problem Summary: Large external scans could skip the reader meta cache entirely because the existing file meta cache policy disabled metadata caching when the scan range count exceeded the memory-cache threshold. This prevented the disk-backed file metadata cache from being used for high-file-count workloads. This change separates the L1 memory-cache policy from reader and disk-cache enablement, so large scans can skip the memory cache while still reading from and writing to the disk metadata cache. It also carries the memory-cache policy through row-id file mappings and Iceberg equality readers.

### Release note

Improve external Parquet/ORC metadata disk cache behavior for large scans.

### Check List (For Author)

- Test: Unit Test
    - `PATH=/mnt/disk1/chenjunwei/doris_tools/ldb_toolchain_llvm16/bin:$PATH build-support/check-format.sh`
    - `./run-be-ut.sh --run --filter=FileMetaCacheTest.*:FileMetaDiskCacheTest.*:BlockFileCacheTest.file_meta_disk_cache_initializes_without_data_file_cache:IdFileMapTest.*:ParquetReadLinesTest.*:OrcReadLinesTest.*`
    - Manual test: `plaud_current.DWD.DWD_POSTHOG_EVENTS_DI` CTE cold/hot profiles with external file meta disk cache enabled and disabled.
- Behavior changed: Yes. Large external scans can use disk-backed file metadata cache even when L1 memory metadata cache is skipped.
- Does this need documentation: No
@xylaaaaa

Copy link
Copy Markdown
Contributor Author

run buildall

xylaaaaa added a commit to xylaaaaa/doris that referenced this pull request May 21, 2026
### What problem does this PR solve?

Issue Number: None

Related PR: apache#63376

Problem Summary: Restore the existing ExternalFileMappingInfo comment style so the file meta disk cache PR does not include unrelated comment formatting noise.

### Release note

None

### Check List (For Author)

- Test: No need to test (comment-only change)
    - `git diff --check`
    - `PATH=/mnt/disk1/chenjunwei/doris_tools/ldb_toolchain_llvm16/bin:$PATH build-support/check-format.sh`
- Behavior changed: No
- Does this need documentation: No
@xylaaaaa

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

Cloud UT Coverage Report

Increment line coverage 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 78.06% (1854/2375)
Line Coverage 64.53% (33336/51662)
Region Coverage 65.22% (16528/25341)
Branch Coverage 55.71% (8831/15852)

@hello-stephen

Copy link
Copy Markdown
Contributor

Cloud UT Coverage Report

Increment line coverage 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 78.06% (1854/2375)
Line Coverage 64.52% (33333/51662)
Region Coverage 65.20% (16523/25341)
Branch Coverage 55.72% (8833/15852)

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage `` 🎉
Increment coverage report
Complete coverage report

xylaaaaa added a commit to xylaaaaa/doris that referenced this pull request May 21, 2026
### What problem does this PR solve?

Issue Number: None

Related PR: apache#63376

Problem Summary: External Parquet/ORC file metadata disk cache profiles exposed hit/miss/write counts but did not report the local disk cache read and write cost. This adds FileFooterReadDiskCacheTime for successful disk-cache reads and FileFooterWriteDiskCacheTime for successful disk-cache writes so cold and hot query profiles can separate local cache overhead from remote footer read and parse time.

### Release note

Add profile timers for external Parquet/ORC file metadata disk cache read and write cost.

### Check List (For Author)

- Test: Unit Test
    - PATH=/mnt/disk1/chenjunwei/doris_tools/ldb_toolchain_llvm16/bin:$PATH build-support/check-format.sh
    - ./run-be-ut.sh --run --filter=FileMetaCacheTest.*:FileMetaDiskCacheTest.*:BlockFileCacheTest.file_meta_disk_cache_initializes_without_data_file_cache:IdFileMapTest.*:ParquetReaderTest.file_footer_disk_cache_time_counters_exist:OrcReaderTest.file_footer_disk_cache_time_counters_exist:ParquetReadLinesTest.*:OrcReadLinesTest.*
- Behavior changed: Yes. Query profiles now include external file metadata disk cache read and write timers.
- Does this need documentation: No
@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 31487 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 43f5e9a613f9f67da144136051d6e095367b5b44, 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	17616	3942	4026	3942
q2	q3	10945	1533	855	855
q4	4817	479	359	359
q5	10300	2299	2129	2129
q6	358	172	142	142
q7	991	775	635	635
q8	9593	1764	1773	1764
q9	7038	4966	4924	4924
q10	6475	2238	1786	1786
q11	441	284	245	245
q12	651	435	301	301
q13	18163	3389	2761	2761
q14	264	257	234	234
q15	q16	821	784	709	709
q17	951	957	932	932
q18	6846	5767	5522	5522
q19	1150	1288	1085	1085
q20	506	411	262	262
q21	5520	2623	2594	2594
q22	444	358	306	306
Total cold run time: 103890 ms
Total hot run time: 31487 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	4240	4148	4175	4148
q2	q3	4509	4907	4316	4316
q4	2123	2228	1411	1411
q5	4474	4320	5129	4320
q6	247	191	143	143
q7	2013	1876	1630	1630
q8	2537	2165	2120	2120
q9	7866	7882	7753	7753
q10	4549	4646	4064	4064
q11	575	406	403	403
q12	756	740	525	525
q13	3371	3690	2981	2981
q14	311	329	275	275
q15	q16	705	747	659	659
q17	1368	1334	1322	1322
q18	7892	7287	6750	6750
q19	1143	1115	1144	1115
q20	2228	2248	1936	1936
q21	5362	4674	4556	4556
q22	540	497	416	416
Total cold run time: 56809 ms
Total hot run time: 50843 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 169344 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 43f5e9a613f9f67da144136051d6e095367b5b44, data reload: false

query5	4322	665	504	504
query6	323	215	202	202
query7	4276	544	297	297
query8	323	234	225	225
query9	8837	4111	4092	4092
query10	459	363	296	296
query11	5816	2394	2131	2131
query12	183	127	126	126
query13	1280	607	444	444
query14	6051	5420	5104	5104
query14_1	4397	4403	4367	4367
query15	212	207	181	181
query16	1023	452	458	452
query17	1143	744	613	613
query18	2453	500	373	373
query19	230	212	176	176
query20	140	135	134	134
query21	214	144	119	119
query22	13675	13520	13416	13416
query23	17268	16267	15956	15956
query23_1	16197	16183	16143	16143
query24	7515	1778	1296	1296
query24_1	1320	1309	1325	1309
query25	584	522	448	448
query26	1322	330	174	174
query27	2699	550	346	346
query28	4387	1983	1987	1983
query29	1044	656	518	518
query30	310	242	200	200
query31	1135	1066	943	943
query32	91	78	75	75
query33	565	369	304	304
query34	1176	1128	645	645
query35	775	825	677	677
query36	1334	1313	1190	1190
query37	146	105	89	89
query38	3232	3157	3078	3078
query39	930	920	896	896
query39_1	890	900	880	880
query40	235	150	126	126
query41	64	63	60	60
query42	110	108	110	108
query43	326	327	290	290
query44	
query45	211	200	196	196
query46	1077	1212	714	714
query47	2281	2291	2201	2201
query48	410	426	308	308
query49	628	489	385	385
query50	1066	355	255	255
query51	4278	4280	4198	4198
query52	108	105	94	94
query53	249	275	200	200
query54	316	265	255	255
query55	96	90	88	88
query56	305	305	343	305
query57	1415	1398	1317	1317
query58	297	269	258	258
query59	1555	1622	1450	1450
query60	322	343	312	312
query61	161	155	156	155
query62	666	621	566	566
query63	244	210	210	210
query64	2411	801	631	631
query65	
query66	1739	474	357	357
query67	30105	29950	29968	29950
query68	
query69	498	336	302	302
query70	988	1005	951	951
query71	306	287	271	271
query72	3112	2756	2412	2412
query73	881	743	408	408
query74	5114	4910	4750	4750
query75	2662	2604	2251	2251
query76	2283	1132	758	758
query77	401	400	334	334
query78	12270	12288	11695	11695
query79	1517	1037	777	777
query80	804	544	458	458
query81	473	277	234	234
query82	1363	154	120	120
query83	351	274	245	245
query84	282	144	117	117
query85	921	536	452	452
query86	450	332	343	332
query87	3404	3438	3260	3260
query88	3566	2676	2695	2676
query89	459	386	337	337
query90	1866	180	183	180
query91	181	170	141	141
query92	82	75	74	74
query93	1515	1406	912	912
query94	589	368	281	281
query95	679	474	345	345
query96	1071	736	334	334
query97	2702	2689	2546	2546
query98	238	233	235	233
query99	1106	1112	988	988
Total cold run time: 254065 ms
Total hot run time: 169344 ms

@hello-stephen

Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 73.41% (439/598) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 53.56% (20758/38757)
Line Coverage 37.21% (196552/528196)
Region Coverage 33.53% (153996/459315)
Branch Coverage 34.55% (67133/194298)

@hello-stephen

Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 73.41% (439/598) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 53.56% (20758/38757)
Line Coverage 37.21% (196551/528196)
Region Coverage 33.51% (153935/459315)
Branch Coverage 34.55% (67126/194298)

@xylaaaaa

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage `` 🎉
Increment coverage report
Complete coverage report

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 31341 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 98b7a7b69691ebdad3ad96e44c08d2366db9026e, 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	4254	4102	4102
q2	q3	10985	1494	800	800
q4	4812	476	347	347
q5	10365	2314	2069	2069
q6	376	180	142	142
q7	985	771	670	670
q8	9600	1694	1593	1593
q9	6931	4868	4913	4868
q10	6464	2071	1798	1798
q11	440	270	247	247
q12	650	410	297	297
q13	18133	3556	2751	2751
q14	268	262	249	249
q15	q16	813	775	713	713
q17	998	971	954	954
q18	6812	5662	5493	5493
q19	1187	1272	1110	1110
q20	530	426	267	267
q21	5502	2632	2554	2554
q22	430	365	317	317
Total cold run time: 103911 ms
Total hot run time: 31341 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	4227	4200	4288	4200
q2	q3	4580	4854	4326	4326
q4	2271	2228	1428	1428
q5	4402	4285	5281	4285
q6	279	215	152	152
q7	1960	1842	1619	1619
q8	2643	2248	2202	2202
q9	7862	7907	7760	7760
q10	4639	4444	4106	4106
q11	581	445	429	429
q12	742	751	544	544
q13	3318	3649	2995	2995
q14	297	299	286	286
q15	q16	713	774	669	669
q17	1395	1350	1341	1341
q18	8190	7221	6865	6865
q19	1160	1101	1090	1090
q20	2215	2225	1948	1948
q21	5385	4771	4706	4706
q22	552	468	443	443
Total cold run time: 57411 ms
Total hot run time: 51394 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 170014 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 98b7a7b69691ebdad3ad96e44c08d2366db9026e, data reload: false

query5	4304	642	530	530
query6	340	214	199	199
query7	4220	567	303	303
query8	339	228	213	213
query9	8814	4080	4034	4034
query10	452	340	301	301
query11	5794	2399	2223	2223
query12	181	129	122	122
query13	1295	631	487	487
query14	6006	5338	5055	5055
query14_1	4381	4361	4337	4337
query15	218	202	178	178
query16	1004	422	426	422
query17	1127	718	585	585
query18	2449	480	358	358
query19	210	207	166	166
query20	133	130	134	130
query21	213	141	122	122
query22	13549	13634	13365	13365
query23	17221	16379	16109	16109
query23_1	16173	16164	16190	16164
query24	7451	1789	1317	1317
query24_1	1285	1315	1302	1302
query25	587	496	455	455
query26	1310	320	178	178
query27	2731	561	341	341
query28	4479	2002	1958	1958
query29	1020	646	526	526
query30	308	235	200	200
query31	1111	1071	949	949
query32	89	82	86	82
query33	555	370	322	322
query34	1199	1148	667	667
query35	770	802	671	671
query36	1346	1332	1167	1167
query37	156	103	90	90
query38	3218	3147	3057	3057
query39	936	938	903	903
query39_1	887	874	869	869
query40	235	153	131	131
query41	72	71	88	71
query42	116	114	116	114
query43	330	332	291	291
query44	
query45	211	207	207	207
query46	1099	1193	714	714
query47	2304	2306	2187	2187
query48	398	430	303	303
query49	649	495	402	402
query50	1036	354	257	257
query51	4352	4263	4218	4218
query52	111	114	97	97
query53	266	285	210	210
query54	330	288	266	266
query55	97	93	89	89
query56	319	335	319	319
query57	1414	1389	1301	1301
query58	309	289	295	289
query59	1551	1608	1451	1451
query60	338	333	368	333
query61	158	154	155	154
query62	666	620	560	560
query63	242	201	205	201
query64	2404	784	638	638
query65	
query66	1764	470	352	352
query67	30325	29355	29204	29204
query68	
query69	453	343	311	311
query70	1020	1002	963	963
query71	311	264	261	261
query72	2974	2757	2439	2439
query73	817	730	425	425
query74	5066	4937	4767	4767
query75	2678	2603	2270	2270
query76	2293	1132	758	758
query77	402	419	334	334
query78	12201	12276	11571	11571
query79	1462	1034	753	753
query80	808	540	452	452
query81	476	281	244	244
query82	1344	157	121	121
query83	353	281	246	246
query84	261	144	116	116
query85	921	535	489	489
query86	449	339	316	316
query87	3478	3353	3215	3215
query88	3541	2703	2675	2675
query89	453	386	336	336
query90	1764	183	189	183
query91	183	168	143	143
query92	82	79	78	78
query93	1443	1406	820	820
query94	617	347	319	319
query95	692	378	347	347
query96	1086	761	344	344
query97	2725	2690	2544	2544
query98	237	227	225	225
query99	1130	1104	984	984
Total cold run time: 253635 ms
Total hot run time: 170014 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 31410 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 98b7a7b69691ebdad3ad96e44c08d2366db9026e, 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	17625	3867	4156	3867
q2	q3	10770	1462	814	814
q4	4744	482	349	349
q5	9388	2302	2127	2127
q6	404	183	139	139
q7	921	787	640	640
q8	9580	1776	1549	1549
q9	7084	4937	4927	4927
q10	6483	2127	1857	1857
q11	436	270	242	242
q12	692	433	298	298
q13	18219	3367	2807	2807
q14	261	255	237	237
q15	q16	824	767	704	704
q17	903	921	888	888
q18	6899	5740	5675	5675
q19	1272	1438	1071	1071
q20	564	431	283	283
q21	6164	2806	2634	2634
q22	455	367	302	302
Total cold run time: 103688 ms
Total hot run time: 31410 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	4634	4414	4513	4414
q2	q3	4918	5154	4724	4724
q4	2220	2234	1397	1397
q5	4765	4669	4653	4653
q6	236	180	127	127
q7	1872	1779	1497	1497
q8	2336	2109	2016	2016
q9	7402	7250	7256	7250
q10	4487	4422	3987	3987
q11	528	374	342	342
q12	709	720	511	511
q13	3053	3392	2770	2770
q14	270	271	261	261
q15	q16	673	708	607	607
q17	1273	1229	1231	1229
q18	7282	6886	6944	6886
q19	1101	1121	1128	1121
q20	2227	2206	1944	1944
q21	5334	4593	4488	4488
q22	517	487	401	401
Total cold run time: 55837 ms
Total hot run time: 50625 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 170252 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 98b7a7b69691ebdad3ad96e44c08d2366db9026e, data reload: false

query5	4318	652	550	550
query6	357	221	201	201
query7	4266	576	329	329
query8	336	233	222	222
query9	8848	3962	3986	3962
query10	441	364	292	292
query11	5825	2410	2226	2226
query12	178	126	127	126
query13	1318	608	430	430
query14	5971	5323	5037	5037
query14_1	4345	4362	4316	4316
query15	211	204	186	186
query16	1047	459	443	443
query17	1133	711	584	584
query18	2529	493	360	360
query19	232	202	167	167
query20	134	135	127	127
query21	222	140	121	121
query22	13658	13623	13393	13393
query23	17167	16392	16088	16088
query23_1	16207	16219	16283	16219
query24	7474	1803	1329	1329
query24_1	1323	1347	1319	1319
query25	593	512	450	450
query26	1317	337	198	198
query27	2676	582	345	345
query28	4488	1969	1977	1969
query29	1014	655	548	548
query30	319	252	206	206
query31	1112	1074	962	962
query32	96	79	79	79
query33	561	373	318	318
query34	1171	1126	648	648
query35	779	821	670	670
query36	1280	1327	1189	1189
query37	160	112	103	103
query38	3204	3171	3074	3074
query39	947	954	907	907
query39_1	878	879	906	879
query40	249	155	132	132
query41	73	71	69	69
query42	117	113	114	113
query43	334	340	293	293
query44	
query45	220	208	193	193
query46	1108	1206	761	761
query47	2317	2341	2136	2136
query48	412	417	312	312
query49	660	516	401	401
query50	987	346	259	259
query51	4313	4307	4199	4199
query52	115	114	102	102
query53	280	298	219	219
query54	332	303	270	270
query55	100	95	89	89
query56	334	337	319	319
query57	1433	1405	1308	1308
query58	312	284	293	284
query59	1541	1631	1396	1396
query60	339	344	325	325
query61	221	161	159	159
query62	676	639	569	569
query63	247	208	209	208
query64	2395	806	623	623
query65	
query66	1683	487	356	356
query67	29520	30049	29825	29825
query68	
query69	468	349	312	312
query70	1014	992	994	992
query71	313	276	269	269
query72	3051	2738	2632	2632
query73	856	777	405	405
query74	5050	5006	4732	4732
query75	2668	2590	2259	2259
query76	2340	1173	784	784
query77	396	410	334	334
query78	12126	12176	11741	11741
query79	1586	1082	773	773
query80	658	570	475	475
query81	458	280	248	248
query82	1385	163	125	125
query83	361	278	248	248
query84	267	151	116	116
query85	902	551	490	490
query86	397	356	322	322
query87	3427	3360	3225	3225
query88	3615	2718	2677	2677
query89	432	385	333	333
query90	1970	185	182	182
query91	183	168	145	145
query92	83	80	77	77
query93	1499	1471	837	837
query94	529	300	315	300
query95	672	485	348	348
query96	1064	786	349	349
query97	2727	2714	2584	2584
query98	233	227	227	227
query99	1133	1090	976	976
Total cold run time: 253102 ms
Total hot run time: 170252 ms

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 82.92% (529/638) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 73.83% (27967/37879)
Line Coverage 57.68% (303725/526588)
Region Coverage 54.76% (253837/463529)
Branch Coverage 56.38% (109898/194932)

Comment thread be/src/io/fs/file_meta_cache.cpp Outdated
}

bool FileMetaCache::should_enable_for_reader(int64_t num_scan_ranges) const {
return should_enable_memory_cache(num_scan_ranges) ||

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.

这个条件只用config::enable_external_file_meta_disk_cache就行

Comment thread be/src/exec/scan/file_scanner.cpp Outdated
_current_range, _should_enable_file_meta_cache()));
auto file_id = id_file_map->get_file_mapping_id(std::make_shared<FileMapping>(
((FileScanLocalState*)_local_state)->parent_id(), _current_range,
_should_enable_file_meta_cache(), _should_enable_file_meta_memory_cache()));

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.

这里不需要两个开关,我们只需要一个是否开启cache的开关,cache里内存的占比应该是有cache内部机制通过一个比例来控制的

Comment thread be/src/exec/scan/file_scanner.cpp Outdated
auto* file_meta_cache_ptr = _should_enable_file_meta_cache()
? ExecEnv::GetInstance()->file_meta_cache()
: nullptr;
const bool enable_file_meta_memory_cache = _should_enable_file_meta_memory_cache();

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.

不需要这个

@Gabriel39 Gabriel39 left a comment

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.

scanner::enable_cache -> 改成通过一个配置项
cache: memory-》memory+disk

xylaaaaa added a commit to xylaaaaa/doris that referenced this pull request May 25, 2026
### What problem does this PR solve?

Issue Number: None

Related PR: apache#63376

Problem Summary: File meta disk cache reader wiring still carried a separate memory-cache switch, so scan-range admission policy leaked into ORC/Parquet reader setup and could also disable disk-cache use. This change uses enable_external_file_meta_disk_cache as the only reader switch and lets FileMetaCache internals handle memory cache admission and eviction.

### Release note

External file meta disk cache reader wiring is now controlled by enable_external_file_meta_disk_cache.

### Check List (For Author)

- Test: Unit Test
    - ./run-be-ut.sh --run --filter=FileMetaCacheTest.*:FileMetaDiskCacheTest.* -j 8
    - ./run-be-ut.sh --run --filter=ParquetReaderTest.file_footer_disk_cache_time_counters_exist:OrcReaderTest.file_footer_disk_cache_time_counters_exist -j 8
- Behavior changed: Yes. The reader file meta cache path no longer has a separate scanner-level memory-cache switch.
- Does this need documentation: No
Comment thread be/src/format/orc/vorc_reader.cpp Outdated
// Local variables can be required because setSerializedFileTail is an assignment operation, not a reference.
ObjLRUCache::CacheHandle _meta_cache_handle;
if (_meta_cache->lookup(file_meta_cache_key, &_meta_cache_handle)) {
const bool use_memory_cache = _meta_cache->enabled();

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.

这些接口都不需要改,我们只是替换了一下cache的实现

xylaaaaa added a commit to xylaaaaa/doris that referenced this pull request Jul 9, 2026
### What problem does this PR solve?

Issue Number: None

Related PR: apache#63376

Problem Summary: BE UT crashed in OrcReadLinesTest.test0 because read_lines_from_range can initialize readers without an ExecEnv file meta cache object. The scanner memory-cache toggle still dereferenced ExecEnv::file_meta_cache()->enabled() directly. Use the actual FileMetaCache pointer selected for the reader when enabling memory cache and require an initialized cache object before enabling memory or persistent file meta cache.

### Release note

None

### Check List (For Author)

- Test:
    - Unit Test: ./run-be-ut.sh --run --filter='OrcReadLinesTest.test0' -j 1
    - Unit Test: ./run-be-ut.sh --run --filter='OrcReadLinesTest.*:ParquetReadLinesTest.*:*FileMeta*' -j 1
    - Manual test: build-support/clang-format.sh be/src/exec/scan/file_scanner.h be/src/exec/scan/file_scanner.cpp be/src/exec/scan/file_scanner_v2.h be/src/exec/scan/file_scanner_v2.cpp
    - Manual test: build-support/check-format.sh
    - Manual test: git diff --check
    - Manual test: git diff --cached --check
- Behavior changed: No
- Does this need documentation: No
@xylaaaaa

xylaaaaa commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17645	4055	4106	4055
q2	2075	349	197	197
q3	10283	1428	825	825
q4	4684	472	342	342
q5	7594	894	574	574
q6	181	172	138	138
q7	792	855	637	637
q8	9373	1557	1629	1557
q9	5627	4471	4426	4426
q10	6774	1824	1561	1561
q11	504	344	320	320
q12	732	561	444	444
q13	18105	3426	2741	2741
q14	274	272	247	247
q15	q16	793	780	715	715
q17	1023	945	1030	945
q18	7107	5826	5534	5534
q19	1378	1325	1011	1011
q20	745	649	539	539
q21	6010	2717	2395	2395
q22	436	356	303	303
Total cold run time: 102135 ms
Total hot run time: 29506 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4453	4416	4373	4373
q2	283	318	215	215
q3	4620	5003	4434	4434
q4	2054	2155	1379	1379
q5	4464	4324	4358	4324
q6	235	177	131	131
q7	1963	2091	1681	1681
q8	2586	2437	2231	2231
q9	8084	8063	7871	7871
q10	4741	4706	4303	4303
q11	562	412	375	375
q12	760	773	537	537
q13	3383	3699	2987	2987
q14	293	297	272	272
q15	q16	717	744	658	658
q17	1332	1339	1318	1318
q18	7741	7410	7258	7258
q19	1136	1122	1109	1109
q20	2212	2231	1948	1948
q21	5244	4679	4409	4409
q22	536	458	415	415
Total cold run time: 57399 ms
Total hot run time: 52228 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 180345 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 2c6841bc69cc96113ee60cb3d4860762c68385cb, data reload: false

query5	4340	634	487	487
query6	438	236	200	200
query7	4840	572	334	334
query8	341	188	170	170
query9	8779	4077	4061	4061
query10	470	364	303	303
query11	5935	2355	2156	2156
query12	153	102	108	102
query13	1259	628	437	437
query14	6245	5311	5022	5022
query14_1	4311	4276	4318	4276
query15	212	210	186	186
query16	1037	513	465	465
query17	1129	731	599	599
query18	2526	483	363	363
query19	225	194	162	162
query20	122	106	108	106
query21	239	162	130	130
query22	13639	13540	13546	13540
query23	17586	16638	16306	16306
query23_1	16302	16362	16228	16228
query24	7649	1773	1296	1296
query24_1	1307	1280	1302	1280
query25	572	478	386	386
query26	1334	350	216	216
query27	2569	600	389	389
query28	4417	2012	2034	2012
query29	1119	627	506	506
query30	340	262	231	231
query31	1121	1104	992	992
query32	118	73	64	64
query33	567	337	265	265
query34	1187	1175	657	657
query35	764	790	678	678
query36	1402	1397	1311	1311
query37	155	104	95	95
query38	1885	1707	1664	1664
query39	928	919	910	910
query39_1	871	883	863	863
query40	241	163	133	133
query41	77	76	61	61
query42	92	99	92	92
query43	323	327	277	277
query44	1443	776	783	776
query45	204	190	179	179
query46	1098	1237	759	759
query47	2383	2369	2276	2276
query48	376	422	306	306
query49	570	424	318	318
query50	1061	420	330	330
query51	10947	10502	10833	10502
query52	85	91	73	73
query53	258	284	202	202
query54	288	228	237	228
query55	77	76	67	67
query56	290	290	267	267
query57	1425	1400	1325	1325
query58	286	255	262	255
query59	1593	1677	1437	1437
query60	304	270	253	253
query61	148	149	155	149
query62	692	649	605	605
query63	256	201	203	201
query64	2831	1054	901	901
query65	4865	4837	4778	4778
query66	1873	525	382	382
query67	29550	29469	29422	29422
query68	3338	1600	952	952
query69	419	357	268	268
query70	1077	957	904	904
query71	360	319	326	319
query72	2989	2681	2318	2318
query73	856	750	452	452
query74	5111	4915	4750	4750
query75	2614	2592	2203	2203
query76	2372	1183	775	775
query77	352	365	288	288
query78	12227	12325	11781	11781
query79	1470	1122	741	741
query80	1341	539	475	475
query81	512	322	282	282
query82	567	161	121	121
query83	369	326	288	288
query84	278	162	129	129
query85	972	588	515	515
query86	424	311	288	288
query87	1839	1823	1747	1747
query88	3668	2775	2816	2775
query89	472	408	373	373
query90	2077	206	196	196
query91	203	184	158	158
query92	66	61	53	53
query93	1637	1496	1079	1079
query94	731	349	279	279
query95	771	482	556	482
query96	1124	844	365	365
query97	2713	2677	2556	2556
query98	213	204	199	199
query99	1170	1170	1031	1031
Total cold run time: 267023 ms
Total hot run time: 180345 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 25.12 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 2c6841bc69cc96113ee60cb3d4860762c68385cb, data reload: false

query1	0.01	0.00	0.01
query2	0.10	0.04	0.04
query3	0.27	0.14	0.13
query4	1.61	0.14	0.17
query5	0.24	0.24	0.24
query6	1.28	1.05	1.10
query7	0.04	0.01	0.00
query8	0.06	0.04	0.04
query9	0.39	0.32	0.32
query10	0.58	0.59	0.56
query11	0.19	0.14	0.14
query12	0.19	0.14	0.14
query13	0.48	0.48	0.47
query14	1.02	1.01	1.02
query15	0.65	0.60	0.63
query16	0.34	0.34	0.31
query17	1.14	1.12	1.15
query18	0.24	0.23	0.22
query19	2.01	1.91	2.00
query20	0.02	0.01	0.01
query21	15.47	0.20	0.14
query22	4.88	0.06	0.06
query23	16.14	0.31	0.13
query24	3.00	0.41	0.33
query25	0.11	0.05	0.04
query26	0.73	0.20	0.16
query27	0.03	0.04	0.04
query28	3.50	0.91	0.56
query29	12.54	4.14	3.22
query30	0.28	0.15	0.15
query31	2.78	0.62	0.32
query32	3.22	0.60	0.49
query33	3.15	3.18	3.14
query34	15.55	4.24	3.56
query35	3.57	3.55	3.52
query36	0.55	0.44	0.44
query37	0.09	0.07	0.07
query38	0.06	0.04	0.04
query39	0.04	0.02	0.03
query40	0.18	0.16	0.15
query41	0.08	0.03	0.03
query42	0.04	0.03	0.03
query43	0.05	0.03	0.03
Total cold run time: 96.9 s
Total hot run time: 25.12 s

@xylaaaaa

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 78.45% (568/724) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 56.87% (23497/41317)
Line Coverage 40.50% (229469/566659)
Region Coverage 36.42% (181467/498247)
Branch Coverage 37.49% (80957/215928)

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17631	4050	4120	4050
q2	2013	339	201	201
q3	10344	1485	837	837
q4	4680	472	343	343
q5	7484	874	570	570
q6	185	175	139	139
q7	759	834	625	625
q8	9315	1522	1557	1522
q9	5696	4419	4412	4412
q10	6794	1784	1542	1542
q11	505	352	324	324
q12	701	567	450	450
q13	18097	3466	2778	2778
q14	273	267	244	244
q15	q16	793	771	712	712
q17	988	1008	983	983
q18	7141	5958	5474	5474
q19	1317	1255	999	999
q20	788	642	528	528
q21	6440	2857	2642	2642
q22	472	372	329	329
Total cold run time: 102416 ms
Total hot run time: 29704 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	5203	4774	4944	4774
q2	322	345	219	219
q3	4956	5325	4688	4688
q4	2050	2187	1408	1408
q5	4970	4654	4675	4654
q6	227	179	135	135
q7	2018	1782	1529	1529
q8	2508	2162	2129	2129
q9	7773	7420	7227	7227
q10	4677	4618	4191	4191
q11	527	406	360	360
q12	739	748	552	552
q13	3000	3364	2746	2746
q14	273	274	269	269
q15	q16	690	704	610	610
q17	1302	1277	1281	1277
q18	7470	7022	6999	6999
q19	1095	1076	1062	1062
q20	2228	2213	1960	1960
q21	5313	4589	4506	4506
q22	533	446	416	416
Total cold run time: 57874 ms
Total hot run time: 51711 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 180076 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 a51d8c40c93af99dada7ba2376643a469afb0d62, data reload: false

query5	4314	637	497	497
query6	467	234	197	197
query7	4883	607	345	345
query8	342	186	170	170
query9	8801	4060	4015	4015
query10	465	351	294	294
query11	5965	2370	2127	2127
query12	156	109	100	100
query13	1235	583	428	428
query14	6241	5273	4936	4936
query14_1	4282	4264	4259	4259
query15	225	203	185	185
query16	1011	446	433	433
query17	897	689	558	558
query18	2429	454	336	336
query19	201	184	151	151
query20	107	108	105	105
query21	233	155	133	133
query22	13670	13537	13474	13474
query23	17563	16550	16232	16232
query23_1	16331	16345	16230	16230
query24	7529	1789	1297	1297
query24_1	1329	1284	1301	1284
query25	576	471	400	400
query26	1358	360	214	214
query27	2589	621	383	383
query28	4487	2025	2057	2025
query29	1101	655	516	516
query30	341	253	224	224
query31	1118	1110	989	989
query32	114	64	65	64
query33	539	327	263	263
query34	1216	1144	649	649
query35	776	787	688	688
query36	1435	1394	1263	1263
query37	158	106	93	93
query38	1892	1701	1652	1652
query39	923	936	907	907
query39_1	893	884	881	881
query40	247	161	145	145
query41	70	67	69	67
query42	94	93	93	93
query43	318	320	278	278
query44	1442	794	774	774
query45	215	186	183	183
query46	1064	1200	721	721
query47	2403	2333	2240	2240
query48	423	433	325	325
query49	586	428	312	312
query50	1084	423	336	336
query51	10503	10832	10619	10619
query52	86	87	76	76
query53	274	281	209	209
query54	289	241	246	241
query55	78	79	68	68
query56	321	312	298	298
query57	1418	1418	1329	1329
query58	325	273	270	270
query59	1598	1661	1426	1426
query60	347	287	275	275
query61	205	143	145	143
query62	708	637	590	590
query63	237	199	203	199
query64	2821	1013	843	843
query65	4857	4736	4750	4736
query66	1808	506	381	381
query67	29537	29373	29401	29373
query68	3177	1657	1045	1045
query69	416	299	267	267
query70	1037	942	959	942
query71	349	317	305	305
query72	3134	2755	2358	2358
query73	861	833	433	433
query74	5127	4955	4748	4748
query75	2633	2595	2213	2213
query76	2307	1182	800	800
query77	360	376	288	288
query78	12334	12392	11861	11861
query79	1402	1105	757	757
query80	1273	569	472	472
query81	528	329	283	283
query82	1033	163	126	126
query83	391	320	291	291
query84	321	165	131	131
query85	981	601	533	533
query86	479	298	277	277
query87	1828	1827	1739	1739
query88	3767	2812	2824	2812
query89	469	399	365	365
query90	1921	199	193	193
query91	199	185	157	157
query92	62	62	55	55
query93	1708	1466	960	960
query94	830	361	312	312
query95	817	586	471	471
query96	1128	774	345	345
query97	2693	2683	2547	2547
query98	221	206	208	206
query99	1150	1183	1033	1033
Total cold run time: 266881 ms
Total hot run time: 180076 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 25.03 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit a51d8c40c93af99dada7ba2376643a469afb0d62, data reload: false

query1	0.01	0.01	0.01
query2	0.10	0.05	0.05
query3	0.26	0.14	0.13
query4	1.61	0.16	0.14
query5	0.24	0.22	0.23
query6	1.27	1.11	1.04
query7	0.03	0.01	0.00
query8	0.06	0.04	0.04
query9	0.39	0.31	0.32
query10	0.56	0.59	0.55
query11	0.20	0.14	0.14
query12	0.19	0.15	0.15
query13	0.47	0.46	0.48
query14	1.02	1.02	1.01
query15	0.62	0.60	0.59
query16	0.31	0.34	0.33
query17	1.12	1.09	1.10
query18	0.22	0.20	0.21
query19	2.04	1.93	1.89
query20	0.02	0.02	0.01
query21	15.44	0.21	0.14
query22	4.79	0.06	0.05
query23	16.11	0.31	0.12
query24	3.02	0.42	0.31
query25	0.14	0.05	0.04
query26	0.72	0.20	0.15
query27	0.04	0.03	0.02
query28	3.52	0.91	0.53
query29	12.48	4.05	3.24
query30	0.27	0.15	0.15
query31	2.77	0.60	0.31
query32	3.21	0.59	0.48
query33	3.28	3.20	3.21
query34	15.63	4.22	3.57
query35	3.58	3.55	3.56
query36	0.55	0.42	0.43
query37	0.09	0.07	0.07
query38	0.06	0.03	0.03
query39	0.04	0.03	0.03
query40	0.18	0.17	0.17
query41	0.08	0.03	0.03
query42	0.05	0.03	0.03
query43	0.04	0.04	0.03
Total cold run time: 96.83 s
Total hot run time: 25.03 s

xylaaaaa added 6 commits July 12, 2026 16:47
### What problem does this PR solve?

Issue Number: close #xxx

Related PR: #xxx

Problem Summary: External file metadata disk cache should be built behind the FileMetaCache boundary instead of exposing a generic complete-value put/get API from BlockFileCache. This change adds a narrow FileMetaCache persistent cache interface, lookup/insert result types, profile counter plumbing, and config gates so upper-layer metadata cache code can depend on FileMetaCache APIs while the storage implementation remains replaceable.

### Release note

None

### Check List (For Author)

- Test: Unit Test
    - Added focused FileMetaCache interface tests. Attempted targeted BE UT; initial run hit stale PCH after branch switch, clean run was stopped because it triggered a large full rebuild before reaching the target tests.
- Behavior changed: No
- Does this need documentation: No
### What problem does this PR solve?

Issue Number: None

Related PR: apache#64961

Problem Summary: External Parquet and ORC readers only kept file metadata in the in-memory FileMetaCache. This change adds a FileMetaDiskCache implementation behind the FileMetaCache persistent-cache interface, stores serialized Parquet footers and ORC file tails in the existing BlockFileCache through its block APIs, and wires readers to read from disk cache, refill memory cache, and write new persistent entries on misses. It also wires the v2 Parquet reader path through FileScannerV2/TableReader so current Parquet scans use the file meta cache, and enables external file meta disk cache by default.

### Release note

Enable disk cache for external Parquet/ORC file metadata by default.

### Check List (For Author)

- Test: Regression test / Unit Test / Manual test
    - python3 build-support/run_clang_format.py --clang-format-executable clang-format --style file --inplace true -j 1 <changed C++ files>
    - git diff --check -- <changed C++ files>
    - ./run-be-ut.sh --run --filter=NewParquetReaderTest.UsesFileMetaCacheForFooterMetadata -j 4
    - ./run-be-ut.sh --run --filter=FileMetaCache* -j 4
    - ./build.sh --be -j 4
    - Manual e2e with output FE/BE: local Parquet TVF returned 30000 before and after BE restart, local ORC TVF returned 10, BE runtime config showed enable_external_file_meta_disk_cache=true, and the post-restart Parquet query added no new file meta disk cache miss log.
- Behavior changed: Yes. External Parquet/ORC metadata disk cache is enabled by default and can persist file metadata through the file cache.
- Does this need documentation: No
### What problem does this PR solve?

Issue Number: None

Related PR: apache#64961

Problem Summary: The external file metadata disk cache integration needed stronger correctness boundaries before review. Memory cache keys did not include the metadata format, so legacy Parquet and v2 Parquet could collide while storing incompatible in-memory objects. Persistent entries could also be attempted for files without a stable modification time, and missing disk-cache ranges were treated the same as corrupt entries. This change scopes memory keys by format, adds a PARQUET_V2 persistent format, builds persistent cache identities from path, modification time, and file size, skips persistent cache when the file identity is unstable, handles missing ranges without invalidating concurrent writers, falls back to file reads on invalid persistent payloads, and separates memory-cache gating from persistent-cache gating in file scanners.

### Release note

None

### Check List (For Author)

- Test: Unit Test / Manual test
    - git diff --check
    - git diff --cached --check
    - ./run-be-ut.sh --run --filter='*FileMeta*' -j 2
    - Manual e2e with output FE/BE: local Parquet TVF returned count 25 twice and second profile showed FileFooterHitMemoryCache=1; local ORC TVF returned count 25 twice and second profile showed FileFooterHitMemoryCache=1. Local TVF does not provide modification_time, so persistent disk cache is intentionally skipped on that path and covered by FileMetaCacheDiskTest.
- Behavior changed: Yes. File metadata persistent cache now requires a stable modification time, uses format-scoped identities, and avoids invalidating incomplete in-flight cache writes.
- Does this need documentation: No
### What problem does this PR solve?

Issue Number: None

Related PR: apache#63376

Problem Summary: BE UT crashed in OrcReadLinesTest.test0 because read_lines_from_range can initialize readers without an ExecEnv file meta cache object. The scanner memory-cache toggle still dereferenced ExecEnv::file_meta_cache()->enabled() directly. Use the actual FileMetaCache pointer selected for the reader when enabling memory cache and require an initialized cache object before enabling memory or persistent file meta cache.

### Release note

None

### Check List (For Author)

- Test:
    - Unit Test: ./run-be-ut.sh --run --filter='OrcReadLinesTest.test0' -j 1
    - Unit Test: ./run-be-ut.sh --run --filter='OrcReadLinesTest.*:ParquetReadLinesTest.*:*FileMeta*' -j 1
    - Manual test: build-support/clang-format.sh be/src/exec/scan/file_scanner.h be/src/exec/scan/file_scanner.cpp be/src/exec/scan/file_scanner_v2.h be/src/exec/scan/file_scanner_v2.cpp
    - Manual test: build-support/check-format.sh
    - Manual test: git diff --check
    - Manual test: git diff --cached --check
- Behavior changed: No
- Does this need documentation: No
### What problem does this PR solve?

Issue Number: N/A

Related PR: apache#64961

Problem Summary: Row-id fetch scanners read a mapped range without a split source, but Parquet and ORC reader initialization evaluated the normal scan-range memory file metadata cache admission rule and dereferenced the missing split source. This crashed external, P0, and cloud regression jobs. The unknown-mtime Parquet unit test also accidentally used a synthetic nonzero mtime, enabling page cache while asserting it remained disabled. Disable memory file metadata cache for row-id fetch reader initialization and make the unit test pass an explicit unknown mtime.

### Release note

None

### Check List (For Author)

- Test: Unit Test / Code style check
    - `./run-be-ut.sh --run --filter='OrcReadLinesTest.*:ParquetReadLinesTest.*:NewParquetReaderTest.RewriteSameLocalPathDoesNotReuseUnknownMtimePageCache' -j 1`
    - `build-support/check-format.sh`
    - `git diff --check`
    - `git diff --cached --check`
- Behavior changed: No
- Does this need documentation: No
### What problem does this PR solve?

Issue Number: close #xxx

Related PR: apache#63376

Problem Summary: File meta disk cache already supports external file metadata through the FileMetaCache boundary, but format v2 ORC did not participate in the cache. This change adds an ORC_V2 file meta cache namespace, wires ordinary format v2 ORC readers through FileMetaCache, reuses ORC serialized file tail payloads for memory and persistent cache hits, and refreshes invalid persistent payloads after a successful source-file fallback. Legacy ORC keeps using the ORC namespace so both reader implementations do not share incompatible cached values.

### Release note

None

### Check List (For Author)

- Test: Unit Test / Manual test
    - ./build.sh --be -j 10
    - ./run-be-ut.sh --run --filter='FileMetaCacheDiskTest.OrcFormatsUseIndependentKeys:NewOrcReaderTest.*FileMetaCache*:NewOrcReaderTest.OversizedPersistentPayloadRemainsMemoryCacheEligible' -j 10
    - git diff --check
- Behavior changed: Yes. Format v2 ORC file metadata can use the existing external file meta disk cache when enabled.
- Does this need documentation: No
@xylaaaaa xylaaaaa force-pushed the codex/file-meta-cache-disk-pr branch from a51d8c4 to 48d7b10 Compare July 12, 2026 08:51
@xylaaaaa

Copy link
Copy Markdown
Contributor Author

run buildall

xylaaaaa added 3 commits July 12, 2026 19:15
### What problem does this PR solve?

Issue Number: None

Related PR: apache#64961

Problem Summary: Runtime activation could enable persistent metadata lookups after startup without constructing the required cache objects. Nested Iceberg and transactional Hive delete readers also ignored the parent memory-cache policy, and a capacity rejection during a multi-block write could leave downloaded payload blocks behind. Separate startup configuration from the runtime size gate, propagate the reader policy, preclaim complete entries before writing, and cover real disk reinitialization.

### Release note

None

### Check List (For Author)

- Test: Unit Tests added; modified production and test objects compiled with ASAN and -Werror; full BE UT execution pending the local rebuild
- Behavior changed: Yes, runtime cache-size activation is supported and failed writes no longer leave partial entries
- Does this need documentation: No
### What problem does this PR solve?

Issue Number: None

Related PR: apache#63376

Problem Summary: The file metadata persistent cache interface had no direct unit coverage. Add boundary-level tests for successful round trips, invalidation, profile counters, and read/write failure fallback without depending on BlockFileCache internals.

### Release note

None

### Check List (For Author)

- Test: Unit Test object compiled with ASAN and -Werror; full execution pending the local BE rebuild
- Behavior changed: No
- Does this need documentation: No
### What problem does this PR solve?

Issue Number: None

Related PR: apache#64961

Problem Summary: Iceberg format-v2 data readers received the shared file metadata cache and memory-cache policy, but format-v2 position and equality delete readers were constructed without either value. Their Parquet and ORC footer metadata therefore bypassed the persistent cache entirely. Pass the cache, memory policy, and timestamp mapping option through the delete-reader construction boundary and add enabled/disabled behavior coverage.

### Release note

None

### Check List (For Author)

- Test: Unit Test added; modified v2 production and test objects compiled with ASAN and -Werror; full execution pending the local BE rebuild
- Behavior changed: Yes, Iceberg v2 delete-file metadata now uses the configured file metadata cache
- Does this need documentation: No
@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 91.24% (771/845) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 74.84% (30236/40402)
Line Coverage 58.83% (332239/564724)
Region Coverage 55.60% (278835/501458)
Branch Coverage 56.87% (123257/216726)

### What problem does this PR solve?

Issue Number: None

Related PR: apache#64961

Problem Summary: The disk-cache restart test exercised FSFileCacheStorage without initializing ExecEnv's FDCache, so the restored read dereferenced a null cache under ASAN. Initialize and release the FDCache only when this test owns it, and shorten the TTL worker intervals so destruction does not wait six minutes.

### Release note

None

### Check List (For Author)

- Test: Unit Test - 20 focused BE tests passed under ASAN

- Behavior changed: No

- Does this need documentation: No
@xylaaaaa

Copy link
Copy Markdown
Contributor Author

run buildall

xylaaaaa added a commit to xylaaaaa/doris that referenced this pull request Jul 12, 2026
### What problem does this PR solve?

Issue Number: None

Related PR: apache#63376

Problem Summary: The file metadata persistent cache interface had no direct unit coverage. Add boundary-level tests for successful round trips, invalidation, profile counters, and read/write failure fallback without depending on BlockFileCache internals.

### Release note

None

### Check List (For Author)

- Test: Unit Test added; execution pending the local BE rebuild
- Behavior changed: No
- Does this need documentation: No
@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17602	3956	3960	3956
q2	2046	315	193	193
q3	10283	1411	825	825
q4	4676	470	335	335
q5	7602	843	566	566
q6	185	166	139	139
q7	767	835	625	625
q8	9657	1617	1562	1562
q9	6236	4406	4359	4359
q10	6845	1795	1555	1555
q11	504	345	316	316
q12	741	556	443	443
q13	18101	3352	2795	2795
q14	270	264	238	238
q15	q16	795	773	707	707
q17	1053	988	1014	988
q18	6898	5771	5502	5502
q19	1554	1258	1059	1059
q20	787	645	540	540
q21	5680	2672	2450	2450
q22	442	350	297	297
Total cold run time: 102724 ms
Total hot run time: 29450 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4370	4256	4260	4256
q2	280	313	220	220
q3	4603	4919	4394	4394
q4	2084	2156	1362	1362
q5	4432	4286	4332	4286
q6	226	175	125	125
q7	1729	2034	1746	1746
q8	2494	2162	2089	2089
q9	7869	7864	7846	7846
q10	4744	4780	4297	4297
q11	577	395	380	380
q12	739	755	611	611
q13	3344	3580	2973	2973
q14	287	319	274	274
q15	q16	703	736	645	645
q17	1344	1330	1338	1330
q18	8057	7519	6792	6792
q19	1095	1027	1054	1027
q20	2203	2197	1925	1925
q21	5252	4568	4337	4337
q22	502	465	400	400
Total cold run time: 56934 ms
Total hot run time: 51315 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 180156 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 a55bd3e26aa8825e90aab293963d422fb84b406e, data reload: false

query5	4335	650	526	526
query6	465	219	210	210
query7	4846	593	350	350
query8	338	187	168	168
query9	8783	4094	4087	4087
query10	499	350	290	290
query11	5919	2352	2197	2197
query12	157	105	102	102
query13	1298	635	463	463
query14	6291	5337	4992	4992
query14_1	4317	4303	4307	4303
query15	222	212	184	184
query16	1022	467	407	407
query17	1135	728	603	603
query18	2563	484	368	368
query19	224	195	153	153
query20	117	110	110	110
query21	230	164	138	138
query22	13661	13835	13512	13512
query23	17428	16495	16119	16119
query23_1	16292	16234	16249	16234
query24	7518	1776	1311	1311
query24_1	1322	1316	1295	1295
query25	581	476	404	404
query26	1335	366	206	206
query27	2587	578	383	383
query28	4420	2055	2049	2049
query29	1117	651	505	505
query30	339	265	228	228
query31	1136	1116	984	984
query32	113	66	63	63
query33	548	327	265	265
query34	1194	1095	642	642
query35	784	794	681	681
query36	1384	1371	1197	1197
query37	154	107	104	104
query38	1892	1703	1653	1653
query39	919	919	895	895
query39_1	905	871	899	871
query40	249	158	146	146
query41	65	64	63	63
query42	92	94	94	94
query43	340	325	290	290
query44	1467	775	796	775
query45	199	188	179	179
query46	1094	1202	788	788
query47	2342	2418	2226	2226
query48	418	433	287	287
query49	578	431	304	304
query50	1014	429	329	329
query51	10526	10519	10547	10519
query52	87	86	80	80
query53	288	292	197	197
query54	283	237	217	217
query55	73	72	66	66
query56	296	285	269	269
query57	1441	1405	1319	1319
query58	269	258	254	254
query59	1598	1653	1461	1461
query60	298	267	240	240
query61	156	151	155	151
query62	690	648	583	583
query63	243	208	210	208
query64	2862	1088	891	891
query65	4887	4781	4768	4768
query66	1818	501	386	386
query67	29793	28983	29443	28983
query68	3195	1502	1012	1012
query69	410	320	274	274
query70	1082	952	930	930
query71	348	329	312	312
query72	3064	2736	2405	2405
query73	841	795	405	405
query74	5131	4990	4799	4799
query75	2638	2601	2239	2239
query76	2342	1207	830	830
query77	372	390	293	293
query78	12409	12352	11737	11737
query79	1396	1186	777	777
query80	1290	549	459	459
query81	544	345	286	286
query82	747	158	122	122
query83	375	318	290	290
query84	285	156	126	126
query85	1008	605	523	523
query86	436	309	262	262
query87	1829	1827	1733	1733
query88	3757	2829	2826	2826
query89	459	416	350	350
query90	1892	202	201	201
query91	207	194	165	165
query92	63	59	57	57
query93	1712	1517	957	957
query94	721	364	318	318
query95	795	586	464	464
query96	1070	785	352	352
query97	2703	2706	2603	2603
query98	219	206	198	198
query99	1146	1169	1037	1037
Total cold run time: 266621 ms
Total hot run time: 180156 ms

@hello-stephen

Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 81.58% (704/863) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 56.97% (23589/41409)
Line Coverage 40.66% (231093/568289)
Region Coverage 36.51% (182373/499570)
Branch Coverage 37.61% (81492/216658)

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 25.07 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit a55bd3e26aa8825e90aab293963d422fb84b406e, data reload: false

query1	0.01	0.01	0.01
query2	0.09	0.05	0.05
query3	0.26	0.14	0.14
query4	1.61	0.14	0.14
query5	0.24	0.22	0.22
query6	1.24	1.09	1.06
query7	0.04	0.01	0.00
query8	0.05	0.04	0.03
query9	0.39	0.30	0.32
query10	0.56	0.54	0.55
query11	0.18	0.14	0.13
query12	0.18	0.15	0.15
query13	0.49	0.47	0.47
query14	1.02	1.01	1.00
query15	0.63	0.58	0.59
query16	0.30	0.32	0.33
query17	1.13	1.11	1.11
query18	0.23	0.21	0.21
query19	2.05	1.90	1.92
query20	0.01	0.01	0.01
query21	15.43	0.22	0.13
query22	4.87	0.05	0.05
query23	16.15	0.31	0.12
query24	2.99	0.41	0.33
query25	0.12	0.05	0.05
query26	0.75	0.22	0.14
query27	0.05	0.04	0.03
query28	3.52	0.89	0.56
query29	12.52	4.12	3.24
query30	0.27	0.14	0.17
query31	2.76	0.59	0.31
query32	3.22	0.59	0.48
query33	3.16	3.22	3.30
query34	15.69	4.23	3.57
query35	3.53	3.50	3.58
query36	0.56	0.43	0.43
query37	0.09	0.07	0.07
query38	0.06	0.04	0.04
query39	0.03	0.03	0.03
query40	0.17	0.16	0.16
query41	0.08	0.03	0.03
query42	0.04	0.03	0.03
query43	0.05	0.04	0.04
Total cold run time: 96.82 s
Total hot run time: 25.07 s

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 91.31% (788/863) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 74.78% (30215/40403)
Line Coverage 58.80% (332050/564726)
Region Coverage 55.61% (278862/501463)
Branch Coverage 56.86% (123234/216732)

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.

5 participants