Skip to content

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

Open
xylaaaaa wants to merge 14 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 14 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 a BE restart, repeated scans had to fetch and parse the same footer from remote storage again.

This PR builds on the FileMetaCache persistent-cache interface from #64961 and adds a disk-backed implementation for external file metadata. The feature switch is enabled by default. The implementation stays behind the FileMetaCache boundary and reuses existing BlockFileCache APIs and its INDEX queue; this PR does not modify BlockFileCache internals or interfaces.

Lookup and write flow:

  • Readers check the existing in-memory ObjLRUCache first.
  • On an L1 miss, FileMetaCache asks FileMetaDiskCache for the serialized footer stored in the existing local file cache.
  • On a total miss, the reader fetches and parses the footer from the file, then writes eligible metadata back to L1 and L2.
  • A disk hit can repopulate L1 when memory-cache admission is enabled.
  • Persistent entries require a positive modification time. Readers without a stable modification time skip L2 to avoid stale reuse.

Main changes:

  • Add FileMetaDiskCache, implementing FileMetaPersistentCache entirely above BlockFileCache.
  • Support legacy and v2 Parquet/ORC readers with format-scoped cache entries.
  • Store a protobuf header containing version, format, file size, modification time, payload size, and CRC32C checksum, followed by the serialized footer payload.
  • Validate the complete entry before use. Malformed, checksum-invalid, incomplete, or partially evicted entries are revalidated under the per-entry write lock and then removed as a complete cache key.
  • Serialize same-key replacement in the wrapper, claim the complete entry before writing, clean the whole key after any write failure, and publish header blocks last.
  • Avoid reading, writing, or deleting metadata entries before the underlying file cache finishes startup restoration.
  • Include the effective file-system identity in metadata keys: HDFS nameservice and S3 endpoint/region/provider are isolated in addition to path, mtime, and file size.
  • Avoid serializing and rewriting an oversized ORC v2 tail after an invalid persisted payload falls back to the source file.
  • Add enable_external_file_meta_disk_cache (default true, startup-only) and external_file_meta_disk_cache_max_entry_bytes (default 64 MiB).
  • Reuse file_cache_path and the existing INDEX queue. Effective disk caching requires a positive file-cache total_size and nonzero INDEX capacity; no independent metadata-cache quota or directory is added.
  • Add reader profile counters for memory hit, disk hit, disk miss, disk write, and disk read/write time.
  • Add focused BE unit coverage for interface fallback, protobuf validation, corruption and partial-entry cleanup, capacity failure, concurrent replacement, restart restoration, LRU behavior through the existing read path, file-system identity, and ORC v2 fallback.

Release note

Add a default-enabled disk-backed cache for eligible external Parquet/ORC metadata. It reuses 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
    • Earlier PR heads: ./run-be-ut.sh --run --filter='*FileMeta*' -j 2
    • Earlier PR heads: ./build.sh --be -j 4
    • Latest commit: build-support/clang-format.sh
    • Latest commit: build-support/check-format.sh
    • Latest commit: git diff --check and git diff --cached --check
    • Latest full build and focused BE UT: triggered through run buildall
    • Manual e2e with local output/ FE/BE: Parquet and ORC local TVFs returned identical results on repeated scans and showed memory-footer hits. Local TVF ranges do not provide a positive modification time, so L2 is intentionally skipped on that path.
  • Behavior changed: Yes. Eligible external Parquet/ORC footer metadata can persist in the local file cache across L1 eviction and BE restart. Invalid or incomplete entries are removed and rebuilt. The feature switch is enabled by default, while actual disk capacity is supplied by the existing file-cache configuration.
  • Does this need documentation: Yes. A usage document will cover capacity configuration, effective conditions, profile counters, eviction/cleanup behavior, and troubleshooting.

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的实现

@gavinchou gavinchou self-requested a review July 14, 2026 07:38
@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17671	4016	3965	3965
q2	2008	324	202	202
q3	10303	1421	835	835
q4	4682	478	345	345
q5	7540	849	591	591
q6	187	173	138	138
q7	762	791	614	614
q8	9394	1495	1572	1495
q9	5584	4342	4317	4317
q10	6757	1743	1465	1465
q11	522	340	306	306
q12	708	547	433	433
q13	18147	3425	2733	2733
q14	277	276	242	242
q15	q16	787	783	714	714
q17	1036	960	1071	960
q18	6999	5942	5680	5680
q19	1189	1217	1046	1046
q20	775	673	532	532
q21	6068	2795	2650	2650
q22	455	372	318	318
Total cold run time: 101851 ms
Total hot run time: 29581 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	5072	4774	4770	4770
q2	321	334	221	221
q3	4984	5304	4651	4651
q4	2073	2171	1376	1376
q5	4857	4578	4559	4559
q6	266	184	141	141
q7	1990	1736	1523	1523
q8	2420	2134	2082	2082
q9	7615	7096	7164	7096
q10	4609	4568	4155	4155
q11	523	383	356	356
q12	727	745	544	544
q13	3018	3259	2776	2776
q14	276	276	267	267
q15	q16	677	701	603	603
q17	1273	1242	1248	1242
q18	7292	6843	6843	6843
q19	1054	1099	1074	1074
q20	2205	2211	1959	1959
q21	5232	4576	4441	4441
q22	517	470	410	410
Total cold run time: 57001 ms
Total hot run time: 51089 ms

@hello-stephen

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

query5	4339	635	478	478
query6	455	214	206	206
query7	4849	585	341	341
query8	344	190	167	167
query9	8763	4059	4035	4035
query10	472	346	301	301
query11	5719	2331	2089	2089
query12	162	99	97	97
query13	1276	632	436	436
query14	6207	5189	4866	4866
query14_1	4204	4213	4198	4198
query15	216	211	176	176
query16	997	430	451	430
query17	901	698	553	553
query18	2434	452	331	331
query19	196	181	145	145
query20	111	107	103	103
query21	236	152	129	129
query22	13563	13508	13279	13279
query23	17418	16620	16144	16144
query23_1	16314	16187	16229	16187
query24	7656	1716	1292	1292
query24_1	1337	1311	1282	1282
query25	593	465	402	402
query26	1340	349	223	223
query27	2585	613	379	379
query28	4504	2016	1985	1985
query29	1077	665	501	501
query30	344	262	232	232
query31	1115	1094	978	978
query32	109	67	63	63
query33	526	324	265	265
query34	1173	1103	666	666
query35	766	785	671	671
query36	1183	1191	1032	1032
query37	157	111	99	99
query38	1878	1700	1676	1676
query39	887	885	859	859
query39_1	829	840	840	840
query40	262	165	141	141
query41	73	71	68	68
query42	93	94	94	94
query43	324	326	279	279
query44	1428	778	779	778
query45	205	188	180	180
query46	1103	1216	729	729
query47	2167	2115	1991	1991
query48	399	401	298	298
query49	589	425	341	341
query50	1040	439	337	337
query51	11135	10889	10399	10399
query52	91	87	80	80
query53	271	284	212	212
query54	311	258	228	228
query55	83	72	73	72
query56	320	301	303	301
query57	1360	1299	1219	1219
query58	294	273	251	251
query59	1599	1669	1449	1449
query60	320	292	285	285
query61	200	154	155	154
query62	566	488	433	433
query63	232	196	207	196
query64	2846	1059	841	841
query65	4701	4673	4635	4635
query66	1813	507	378	378
query67	29415	29331	29200	29200
query68	3127	1595	1037	1037
query69	395	310	263	263
query70	1057	947	938	938
query71	358	329	310	310
query72	3063	2893	2367	2367
query73	855	791	434	434
query74	5054	4921	4714	4714
query75	2519	2503	2121	2121
query76	2306	1173	775	775
query77	368	371	282	282
query78	11952	11937	11327	11327
query79	1437	1166	713	713
query80	638	544	485	485
query81	463	312	276	276
query82	594	154	119	119
query83	393	316	287	287
query84	331	157	130	130
query85	905	627	514	514
query86	380	296	267	267
query87	1823	1837	1753	1753
query88	3678	2784	2762	2762
query89	427	369	319	319
query90	1953	198	193	193
query91	201	185	160	160
query92	68	60	56	56
query93	1660	1611	946	946
query94	559	361	319	319
query95	795	472	461	461
query96	1141	781	352	352
query97	2632	2599	2516	2516
query98	214	201	199	199
query99	1106	1104	978	978
Total cold run time: 263310 ms
Total hot run time: 177270 ms

@hello-stephen

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

query1	0.01	0.01	0.01
query2	0.10	0.04	0.05
query3	0.25	0.14	0.13
query4	1.60	0.14	0.14
query5	0.28	0.23	0.22
query6	1.25	1.07	1.07
query7	0.04	0.01	0.01
query8	0.06	0.03	0.04
query9	0.39	0.30	0.30
query10	0.56	0.55	0.55
query11	0.18	0.15	0.15
query12	0.19	0.15	0.14
query13	0.48	0.47	0.48
query14	1.01	1.02	1.00
query15	0.61	0.59	0.61
query16	0.31	0.33	0.34
query17	1.13	1.08	1.09
query18	0.23	0.22	0.22
query19	2.06	1.88	1.98
query20	0.02	0.01	0.01
query21	15.42	0.20	0.13
query22	4.88	0.05	0.06
query23	16.15	0.33	0.13
query24	3.02	0.44	0.46
query25	0.12	0.05	0.06
query26	0.76	0.22	0.15
query27	0.03	0.04	0.04
query28	3.46	0.89	0.56
query29	12.60	4.18	3.27
query30	0.26	0.16	0.15
query31	2.77	0.59	0.30
query32	3.22	0.59	0.48
query33	3.18	3.18	3.23
query34	15.54	4.25	3.53
query35	3.52	3.53	3.53
query36	0.57	0.45	0.44
query37	0.09	0.07	0.06
query38	0.05	0.04	0.03
query39	0.04	0.04	0.03
query40	0.17	0.16	0.15
query41	0.09	0.03	0.04
query42	0.05	0.03	0.03
query43	0.04	0.03	0.03
Total cold run time: 96.79 s
Total hot run time: 25.16 s

@xylaaaaa

Copy link
Copy Markdown
Contributor Author

run buildall

xylaaaaa added 12 commits July 14, 2026 20:58
### 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
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.

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

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

None

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

None

- 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
### 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
### 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
### What problem does this PR solve?

Issue Number: None

Related PR: apache#64961

Problem Summary: FileMetaCache context lookups could leave a reused memory-cache handle pinned after a persistent hit or miss. Persistent reads also accepted entries larger than the current runtime size limit. Reset the output handle before every context lookup, invalidate oversized persistent entries, and add regression coverage for both cases.

### Release note

None

### Check List (For Author)

- Test: Unit Test
    - ContextLookupClearsReusedMemoryHandle and OversizedPersistentReadFallsBackToMiss (ASAN)
- Behavior changed: Yes. Non-memory lookup results now return an invalid handle, and oversized persistent entries are treated as cache misses.
- Does this need documentation: No
### What problem does this PR solve?

Issue Number: N/A

Related PR: apache#64961

Problem Summary: The external file metadata disk cache used a hand-written entry header and could retain incomplete or corrupted multi-block entries after write failures, partial eviction, or invalid payloads. File identities also needed to distinguish HDFS nameservices and S3 endpoints, and the ORC v2 invalid-payload fallback could serialize an oversized tail that was ineligible for persistence. This change uses a protobuf header, revalidates and removes invalid entries as a complete key, serializes same-key replacement in the FileMetaDiskCache wrapper, guards cache restoration, aligns file-system identity across readers, and avoids the oversized ORC v2 rewrite. BlockFileCache internals and interfaces are unchanged.

### Release note

Improve the robustness and isolation of the default-enabled external Parquet/ORC metadata disk cache.

### Check List (For Author)

- Test: Code style check
    - build-support/clang-format.sh
    - build-support/check-format.sh
    - git diff --check
    - Full BE build and focused BE UT are pending CI
- Behavior changed: Yes. Invalid or incomplete persisted metadata entries are removed and rebuilt, and cache keys include the effective file-system identity.
- Does this need documentation: Yes. A usage document will describe capacity, configuration, profile counters, and fallback behavior.
@xylaaaaa xylaaaaa force-pushed the codex/file-meta-cache-disk-pr branch from 6bba4f0 to f31f23a Compare July 14, 2026 13:04
@xylaaaaa

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17628	4125	4082	4082
q2	2032	340	202	202
q3	10814	1396	801	801
q4	4779	465	341	341
q5	8448	897	564	564
q6	350	174	147	147
q7	839	819	640	640
q8	10646	1657	1539	1539
q9	5784	4365	4343	4343
q10	6636	1753	1528	1528
q11	518	340	317	317
q12	694	559	436	436
q13	18080	3344	2771	2771
q14	263	272	250	250
q15	q16	790	778	719	719
q17	1045	938	968	938
q18	7176	6015	5680	5680
q19	1192	1310	1105	1105
q20	743	640	535	535
q21	5722	2611	2396	2396
q22	441	361	297	297
Total cold run time: 104620 ms
Total hot run time: 29631 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4516	4349	4363	4349
q2	297	322	220	220
q3	4617	4999	4420	4420
q4	2067	2153	1363	1363
q5	4457	4338	4510	4338
q6	296	219	152	152
q7	2106	1889	1648	1648
q8	2572	2260	2254	2254
q9	7943	7830	7902	7830
q10	4695	4630	4403	4403
q11	613	426	379	379
q12	736	820	551	551
q13	3311	3691	3023	3023
q14	308	322	298	298
q15	q16	743	733	644	644
q17	1407	1345	1330	1330
q18	8114	7708	7050	7050
q19	1101	1082	1031	1031
q20	2234	2228	1953	1953
q21	5297	4552	4353	4353
q22	527	467	396	396
Total cold run time: 57957 ms
Total hot run time: 51985 ms

### What problem does this PR solve?

Issue Number: N/A

Related PR: apache#64961

Problem Summary: The Parquet v2 test reader helper added an is_immutable argument before the FileMetaCache pointer. Several new persistent-cache tests omitted that boolean, so the BE UT build converted the cache pointer to bool and then attempted to pass bool as FileMetaCache*. Pass the explicit false value at all affected call sites so the tests compile with the intended immutable-file setting.

### Release note

None

### Check List (For Author)

- Test: Manual test
    - Compiled test/CMakeFiles/doris_be_test.dir/format_v2/parquet/parquet_reader_test.cpp.o with the local ASAN_UT build
    - build-support/check-format.sh
    - git diff --check
- Behavior changed: No
- Does this need documentation: No
@hello-stephen

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

query5	4347	639	495	495
query6	468	213	206	206
query7	4844	614	342	342
query8	346	199	179	179
query9	8786	4131	4115	4115
query10	451	349	292	292
query11	5890	2326	2138	2138
query12	156	104	95	95
query13	1287	600	457	457
query14	6239	5241	4944	4944
query14_1	4311	4335	4261	4261
query15	218	210	183	183
query16	1042	470	452	452
query17	1124	726	570	570
query18	2471	460	344	344
query19	197	184	178	178
query20	125	107	105	105
query21	236	161	140	140
query22	13653	13611	13384	13384
query23	17489	16528	16257	16257
query23_1	16337	16319	16272	16272
query24	7481	1775	1303	1303
query24_1	1326	1332	1274	1274
query25	579	480	397	397
query26	1338	377	205	205
query27	2582	573	390	390
query28	4515	2014	2014	2014
query29	1091	640	506	506
query30	338	264	228	228
query31	1118	1109	998	998
query32	115	63	66	63
query33	541	331	250	250
query34	1192	1209	653	653
query35	780	815	676	676
query36	1187	1183	1076	1076
query37	152	112	107	107
query38	1896	1700	1666	1666
query39	884	877	863	863
query39_1	836	839	856	839
query40	253	169	146	146
query41	74	70	71	70
query42	100	100	94	94
query43	338	348	299	299
query44	1510	789	793	789
query45	198	194	180	180
query46	1080	1193	760	760
query47	2102	2092	1963	1963
query48	396	416	316	316
query49	594	421	317	317
query50	1045	442	343	343
query51	11006	10286	10631	10286
query52	91	89	79	79
query53	267	289	205	205
query54	303	255	235	235
query55	81	74	69	69
query56	313	295	327	295
query57	1311	1276	1233	1233
query58	304	281	268	268
query59	1678	1724	1514	1514
query60	336	288	268	268
query61	180	169	179	169
query62	552	508	467	467
query63	237	203	204	203
query64	2804	1027	898	898
query65	4757	4666	4636	4636
query66	1818	502	371	371
query67	29362	29341	29141	29141
query68	3291	1594	1009	1009
query69	400	309	282	282
query70	1089	990	942	942
query71	363	341	306	306
query72	3089	2714	2465	2465
query73	831	777	432	432
query74	5102	4955	4716	4716
query75	2528	2502	2117	2117
query76	2308	1184	793	793
query77	361	388	294	294
query78	11939	11942	11267	11267
query79	1375	1234	784	784
query80	1317	545	467	467
query81	540	326	276	276
query82	612	169	121	121
query83	369	329	304	304
query84	283	166	131	131
query85	981	624	540	540
query86	431	301	288	288
query87	1853	1839	1770	1770
query88	3780	2802	2794	2794
query89	427	395	333	333
query90	1912	206	201	201
query91	203	191	161	161
query92	68	62	60	60
query93	1682	1493	920	920
query94	727	334	308	308
query95	798	593	482	482
query96	1090	843	360	360
query97	2667	2622	2489	2489
query98	217	209	204	204
query99	1100	1126	1001	1001
Total cold run time: 264974 ms
Total hot run time: 178547 ms

@xylaaaaa

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17690	4020	4050	4020
q2	2020	310	204	204
q3	10275	1458	831	831
q4	4724	468	348	348
q5	7797	848	568	568
q6	259	172	138	138
q7	777	824	618	618
q8	10568	1588	1562	1562
q9	5971	4431	4375	4375
q10	6775	1741	1480	1480
q11	516	337	313	313
q12	714	547	422	422
q13	18110	3397	2707	2707
q14	276	265	236	236
q15	q16	804	775	713	713
q17	1123	989	1026	989
q18	6950	5759	5634	5634
q19	1720	1322	984	984
q20	779	650	524	524
q21	5899	2603	2453	2453
q22	439	349	294	294
Total cold run time: 104186 ms
Total hot run time: 29413 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4504	4243	4299	4243
q2	295	317	214	214
q3	4592	4993	4401	4401
q4	2016	2119	1366	1366
q5	4395	4277	4287	4277
q6	232	180	127	127
q7	2229	1869	1599	1599
q8	2595	2221	2089	2089
q9	7796	7789	7791	7789
q10	4701	4670	4189	4189
q11	567	428	510	428
q12	737	771	548	548
q13	3270	3558	2904	2904
q14	307	300	295	295
q15	q16	728	738	647	647
q17	1373	1334	1381	1334
q18	8112	7342	6831	6831
q19	1143	1052	1077	1052
q20	2214	2193	1935	1935
q21	5212	4526	4399	4399
q22	550	445	409	409
Total cold run time: 57568 ms
Total hot run time: 51076 ms

@hello-stephen

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

query5	4338	643	489	489
query6	460	209	197	197
query7	4847	602	335	335
query8	345	194	173	173
query9	8782	3999	4042	3999
query10	471	349	295	295
query11	5932	2347	2108	2108
query12	156	105	101	101
query13	1277	607	396	396
query14	6167	5210	4881	4881
query14_1	4265	4230	4222	4222
query15	213	206	176	176
query16	1034	474	453	453
query17	969	703	551	551
query18	2472	467	339	339
query19	202	186	145	145
query20	112	107	109	107
query21	237	155	131	131
query22	13596	13672	13357	13357
query23	17371	16798	16339	16339
query23_1	16283	16264	16264	16264
query24	7585	1765	1319	1319
query24_1	1301	1292	1278	1278
query25	576	457	398	398
query26	1343	340	222	222
query27	2595	614	380	380
query28	4477	1980	1984	1980
query29	1082	619	507	507
query30	350	266	222	222
query31	1116	1114	990	990
query32	111	64	61	61
query33	531	323	248	248
query34	1168	1144	637	637
query35	767	787	669	669
query36	1200	1193	1048	1048
query37	146	122	91	91
query38	1891	1707	1677	1677
query39	893	886	879	879
query39_1	830	838	841	838
query40	248	168	151	151
query41	77	70	68	68
query42	97	95	95	95
query43	323	340	281	281
query44	1422	784	801	784
query45	202	184	174	174
query46	1055	1187	727	727
query47	2096	2137	1984	1984
query48	403	417	284	284
query49	595	437	322	322
query50	1053	434	333	333
query51	11069	10541	10849	10541
query52	86	88	77	77
query53	262	277	210	210
query54	304	273	243	243
query55	76	75	80	75
query56	321	300	310	300
query57	1297	1299	1208	1208
query58	308	268	272	268
query59	1567	1717	1440	1440
query60	338	285	273	273
query61	201	182	190	182
query62	544	500	436	436
query63	236	196	200	196
query64	2850	1035	860	860
query65	4749	4636	4600	4600
query66	1850	495	379	379
query67	29313	29331	29179	29179
query68	3286	1518	936	936
query69	419	300	262	262
query70	1071	1005	978	978
query71	342	342	291	291
query72	3044	2687	2333	2333
query73	806	818	456	456
query74	5058	4909	4695	4695
query75	2520	2493	2140	2140
query76	2368	1170	784	784
query77	344	381	286	286
query78	11940	11850	11327	11327
query79	1401	1185	776	776
query80	643	552	451	451
query81	452	321	282	282
query82	571	157	125	125
query83	394	318	291	291
query84	312	152	131	131
query85	965	607	496	496
query86	368	303	296	296
query87	1840	1819	1754	1754
query88	3679	2759	2778	2759
query89	428	376	318	318
query90	2022	199	189	189
query91	196	189	163	163
query92	66	61	58	58
query93	1551	1530	954	954
query94	558	354	324	324
query95	822	488	461	461
query96	998	779	337	337
query97	2648	2638	2511	2511
query98	213	205	196	196
query99	1096	1116	978	978
Total cold run time: 262992 ms
Total hot run time: 177684 ms

@hello-stephen

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

query1	0.01	0.01	0.01
query2	0.14	0.08	0.08
query3	0.37	0.24	0.25
query4	1.61	0.28	0.25
query5	0.32	0.31	0.31
query6	1.16	0.67	0.67
query7	0.04	0.01	0.00
query8	0.09	0.07	0.07
query9	0.51	0.39	0.38
query10	0.58	0.59	0.57
query11	0.31	0.18	0.17
query12	0.31	0.18	0.20
query13	0.54	0.53	0.53
query14	0.94	0.94	0.94
query15	0.68	0.59	0.60
query16	0.38	0.39	0.39
query17	1.02	0.97	1.02
query18	0.31	0.30	0.29
query19	1.96	1.87	1.87
query20	0.02	0.01	0.02
query21	15.38	0.36	0.32
query22	4.91	0.14	0.13
query23	15.88	0.50	0.31
query24	2.48	0.57	0.40
query25	0.16	0.10	0.10
query26	0.73	0.27	0.20
query27	0.11	0.09	0.10
query28	3.43	0.85	0.53
query29	12.46	4.12	3.23
query30	0.37	0.25	0.27
query31	2.77	0.61	0.32
query32	3.23	0.60	0.48
query33	2.94	2.98	3.04
query34	15.79	4.07	3.34
query35	3.30	3.30	3.29
query36	0.63	0.55	0.49
query37	0.14	0.09	0.09
query38	0.08	0.07	0.07
query39	0.07	0.06	0.06
query40	0.22	0.19	0.17
query41	0.12	0.08	0.08
query42	0.09	0.07	0.06
query43	0.08	0.07	0.07
Total cold run time: 96.67 s
Total hot run time: 25.58 s

### What problem does this PR solve?

Issue Number: N/A

Related PR: apache#63376

Problem Summary: The Parquet v2 reader test helper defaults mtime to 123 for file metadata cache coverage. UnknownMtimeSkipsPageCacheForMutableFile inherited that stable mtime after the branches were combined, so the page cache was enabled and CI observed PageReadCount=2. Explicitly pass mtime=0 so the test exercises an unknown-version mutable file as intended.

### Release note

None

### Check List (For Author)

- Test: Code style check
    - build-support/check-format.sh
    - git diff --check
    - Targeted BE UT pending CI
- Behavior changed: No. This is a test-only correction.
- Does this need documentation: No
@xylaaaaa

Copy link
Copy Markdown
Contributor 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