Skip to content

Add a memory bound FileStatisticsCache for the Listing Table#20047

Open
mkleen wants to merge 49 commits intoapache:mainfrom
mkleen:file-stats-cache
Open

Add a memory bound FileStatisticsCache for the Listing Table#20047
mkleen wants to merge 49 commits intoapache:mainfrom
mkleen:file-stats-cache

Conversation

@mkleen
Copy link
Copy Markdown
Contributor

@mkleen mkleen commented Jan 28, 2026

Which issue does this PR close?

This change introduces a default FileStatisticsCache implementation for the Listing-Table with a size limit, implementing the following steps following #19052 (comment) :

Rationale for this change

See above.

What changes are included in this PR?

See above.

Are these changes tested?

Yes.

Are there any user-facing changes?

A new runtime setting datafusion.runtime.file_statistics.cache_limit

@github-actions github-actions bot added documentation Improvements or additions to documentation core Core DataFusion crate sqllogictest SQL Logic Tests (.slt) catalog Related to the catalog crate common Related to common crate execution Related to the execution crate labels Jan 28, 2026
@github-actions github-actions bot removed the documentation Improvements or additions to documentation label Jan 28, 2026
@mkleen mkleen force-pushed the file-stats-cache branch 2 times, most recently from e273afc to b297378 Compare January 28, 2026 14:40
@github-actions github-actions bot added the documentation Improvements or additions to documentation label Jan 28, 2026
@mkleen mkleen marked this pull request as ready for review January 28, 2026 16:23
@mkleen mkleen changed the title Add a default FileStatisticsCache implementation for the ListingTable Add a default FileStatisticsCache with a size limit Jan 28, 2026
@mkleen mkleen changed the title Add a default FileStatisticsCache with a size limit Add a FileStatisticsCache with a size limit Jan 28, 2026
@mkleen mkleen changed the title Add a FileStatisticsCache with a size limit Add FileStatisticsCache with a size limit Jan 28, 2026
@mkleen mkleen changed the title Add FileStatisticsCache with a size limit Add a memory bound FileStatisticsCache with a size limit Jan 29, 2026
@mkleen mkleen changed the title Add a memory bound FileStatisticsCache with a size limit Add a memory bound FileStatisticsCache for the Listing Table Jan 31, 2026
Copy link
Copy Markdown
Contributor

@kosiew kosiew left a comment

Choose a reason for hiding this comment

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

@mkleen

Thanks for working on this.

Comment thread datafusion/execution/src/cache/cache_unit.rs Outdated
Comment thread datafusion/common/src/heap_size.rs
@mkleen
Copy link
Copy Markdown
Contributor Author

mkleen commented Feb 4, 2026

@kosiew Thank you for the feedback!

@mkleen mkleen requested a review from kosiew February 4, 2026 12:10
Copy link
Copy Markdown
Contributor

@kosiew kosiew left a comment

Choose a reason for hiding this comment

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

LGTM

@mkleen
Copy link
Copy Markdown
Contributor Author

mkleen commented Feb 10, 2026

@kosiew Anything else needed to get this merged? Another approval maybe?

Comment thread datafusion/common/src/heap_size.rs Outdated
impl<T: DFHeapSize> DFHeapSize for Arc<T> {
fn heap_size(&self) -> usize {
// Arc stores weak and strong counts on the heap alongside an instance of T
2 * size_of::<usize>() + size_of::<T>() + self.as_ref().heap_size()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This won't be accurate.

let a1 = Arc::new(vec![1, 2, 3]);
let a2 = a1.clone();
let a3 = a1.clone();
let a4 = a3.clone();

// this should be true because all `a`s point to the same object in memory 
// but the current implementation does not detect this and counts them separately
assert_eq!(a4.heap_size(), a1.heap_size() + a2.heap_size() + a3.heap_size() + a4.heap_size());

The only solution I imagine is the caller to keep track of the pointer addresses which have been "sized" and ignore any Arc's which point to an address which has been "sized" earlier.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch! I took this implementation from https://github.com/apache/arrow-rs/blob/main/parquet/src/file/metadata/memory.rs#L97-L102 . I would suggest to also do a follow-up here. We are planing anyway to restructure the whole heap size estimation.

Comment thread datafusion/execution/src/cache/cache_unit.rs Outdated
Comment thread datafusion/execution/src/cache/cache_manager.rs
Comment thread datafusion/core/src/execution/context/mod.rs Outdated
Comment thread datafusion/execution/src/cache/cache_unit.rs Outdated
Comment thread datafusion/execution/src/cache/file_statistics_cache.rs
Comment thread datafusion/execution/src/cache/cache_unit.rs Outdated
Comment thread datafusion/execution/src/cache/file_statistics_cache.rs
Comment thread datafusion/sqllogictest/test_files/set_variable.slt Outdated
Comment thread datafusion/execution/src/cache/cache_manager.rs Outdated
@mkleen
Copy link
Copy Markdown
Contributor Author

mkleen commented Feb 10, 2026

@martin-g Thanks for this great review! I am on it.

@mkleen mkleen force-pushed the file-stats-cache branch from 365cb2f to 9b48bd8 Compare April 15, 2026 09:14
@mkleen
Copy link
Copy Markdown
Contributor Author

mkleen commented Apr 15, 2026

@adriangb Could please do another benchmark run? I have no regressions anymore running clickbench_partitioned locally with the new default limit.

@Dandandan
Copy link
Copy Markdown
Contributor

run benchmark clickbench_partitioned

@mkleen
Copy link
Copy Markdown
Contributor Author

mkleen commented Apr 15, 2026

run benchmark clickbench_partitioned

@Dandandan Thank you, i broke the linter. It's fixed now. Does this affect the benchmark run?

@adriangbot
Copy link
Copy Markdown

🤖 Benchmark running (GKE) | trigger
Instance: c4a-highmem-16 (12 vCPU / 65 GiB) | Linux bench-c4251865503-1285-n44mp 6.12.55+ #1 SMP Sun Feb 1 08:59:41 UTC 2026 aarch64 GNU/Linux

CPU Details (lscpu)
Architecture:                            aarch64
CPU op-mode(s):                          64-bit
Byte Order:                              Little Endian
CPU(s):                                  16
On-line CPU(s) list:                     0-15
Vendor ID:                               ARM
Model name:                              Neoverse-V2
Model:                                   1
Thread(s) per core:                      1
Core(s) per cluster:                     16
Socket(s):                               -
Cluster(s):                              1
Stepping:                                r0p1
BogoMIPS:                                2000.00
Flags:                                   fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh rng bti
L1d cache:                               1 MiB (16 instances)
L1i cache:                               1 MiB (16 instances)
L2 cache:                                32 MiB (16 instances)
L3 cache:                                80 MiB (1 instance)
NUMA node(s):                            1
NUMA node0 CPU(s):                       0-15
Vulnerability Gather data sampling:      Not affected
Vulnerability Indirect target selection: Not affected
Vulnerability Itlb multihit:             Not affected
Vulnerability L1tf:                      Not affected
Vulnerability Mds:                       Not affected
Vulnerability Meltdown:                  Not affected
Vulnerability Mmio stale data:           Not affected
Vulnerability Reg file data sampling:    Not affected
Vulnerability Retbleed:                  Not affected
Vulnerability Spec rstack overflow:      Not affected
Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:                Mitigation; __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; CSV2, BHB
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Not affected

Comparing file-stats-cache (3b64005) to 244f891 (merge-base) diff using: clickbench_partitioned
Results will be posted here when complete


File an issue against this benchmark runner

@mkleen mkleen requested a review from kosiew April 15, 2026 12:24
@adriangbot
Copy link
Copy Markdown

🤖 Benchmark completed (GKE) | trigger

Instance: c4a-highmem-16 (12 vCPU / 65 GiB)

CPU Details (lscpu)
Architecture:                            aarch64
CPU op-mode(s):                          64-bit
Byte Order:                              Little Endian
CPU(s):                                  16
On-line CPU(s) list:                     0-15
Vendor ID:                               ARM
Model name:                              Neoverse-V2
Model:                                   1
Thread(s) per core:                      1
Core(s) per cluster:                     16
Socket(s):                               -
Cluster(s):                              1
Stepping:                                r0p1
BogoMIPS:                                2000.00
Flags:                                   fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh rng bti
L1d cache:                               1 MiB (16 instances)
L1i cache:                               1 MiB (16 instances)
L2 cache:                                32 MiB (16 instances)
L3 cache:                                80 MiB (1 instance)
NUMA node(s):                            1
NUMA node0 CPU(s):                       0-15
Vulnerability Gather data sampling:      Not affected
Vulnerability Indirect target selection: Not affected
Vulnerability Itlb multihit:             Not affected
Vulnerability L1tf:                      Not affected
Vulnerability Mds:                       Not affected
Vulnerability Meltdown:                  Not affected
Vulnerability Mmio stale data:           Not affected
Vulnerability Reg file data sampling:    Not affected
Vulnerability Retbleed:                  Not affected
Vulnerability Spec rstack overflow:      Not affected
Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:                Mitigation; __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; CSV2, BHB
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Not affected
Details

Comparing HEAD and file-stats-cache
--------------------
Benchmark clickbench_partitioned.json
--------------------
┏━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓
┃ Query     ┃                                  HEAD ┃                       file-stats-cache ┃        Change ┃
┡━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩
│ QQuery 0  │          1.21 / 4.43 ±6.35 / 17.13 ms │           1.24 / 4.48 ±6.39 / 17.27 ms │     no change │
│ QQuery 1  │        14.71 / 14.92 ±0.18 / 15.23 ms │         14.17 / 14.68 ±0.32 / 15.17 ms │     no change │
│ QQuery 2  │        43.45 / 43.82 ±0.38 / 44.52 ms │         43.72 / 44.07 ±0.33 / 44.61 ms │     no change │
│ QQuery 3  │        40.71 / 44.62 ±2.98 / 48.23 ms │         42.83 / 45.30 ±1.54 / 47.53 ms │     no change │
│ QQuery 4  │     279.65 / 290.03 ±5.81 / 297.44 ms │     278.66 / 297.03 ±16.87 / 321.40 ms │     no change │
│ QQuery 5  │     334.32 / 342.47 ±4.70 / 347.62 ms │      341.14 / 347.92 ±5.80 / 357.84 ms │     no change │
│ QQuery 6  │           5.96 / 6.35 ±0.28 / 6.69 ms │           6.50 / 8.50 ±1.55 / 10.30 ms │  1.34x slower │
│ QQuery 7  │        16.21 / 16.97 ±0.71 / 18.27 ms │         16.43 / 19.59 ±5.88 / 31.34 ms │  1.15x slower │
│ QQuery 8  │     407.88 / 418.65 ±8.08 / 429.99 ms │     413.70 / 422.51 ±11.66 / 445.28 ms │     no change │
│ QQuery 9  │     630.52 / 639.24 ±5.76 / 647.14 ms │      636.38 / 644.87 ±5.68 / 653.84 ms │     no change │
│ QQuery 10 │        91.55 / 93.38 ±2.06 / 97.40 ms │         91.34 / 93.25 ±2.69 / 98.47 ms │     no change │
│ QQuery 11 │     104.43 / 106.09 ±1.48 / 108.07 ms │      103.53 / 104.35 ±0.69 / 105.38 ms │     no change │
│ QQuery 12 │     336.53 / 340.35 ±2.76 / 342.96 ms │     334.51 / 344.06 ±10.30 / 363.61 ms │     no change │
│ QQuery 13 │    442.59 / 461.29 ±10.16 / 469.46 ms │     453.08 / 464.30 ±11.72 / 486.13 ms │     no change │
│ QQuery 14 │     341.31 / 347.52 ±4.45 / 355.08 ms │      331.97 / 342.74 ±6.03 / 349.90 ms │     no change │
│ QQuery 15 │    336.48 / 358.64 ±16.34 / 376.56 ms │      349.66 / 356.81 ±6.09 / 366.04 ms │     no change │
│ QQuery 16 │    707.21 / 724.92 ±24.63 / 771.45 ms │     708.45 / 735.09 ±22.05 / 760.15 ms │     no change │
│ QQuery 17 │     701.30 / 707.87 ±3.41 / 710.73 ms │      702.04 / 711.70 ±7.27 / 723.78 ms │     no change │
│ QQuery 18 │ 1408.45 / 1435.30 ±31.63 / 1474.81 ms │  1406.19 / 1466.16 ±32.91 / 1495.90 ms │     no change │
│ QQuery 19 │      37.27 / 67.03 ±57.51 / 182.04 ms │         35.68 / 36.38 ±0.44 / 36.92 ms │ +1.84x faster │
│ QQuery 20 │    716.98 / 734.53 ±16.79 / 759.20 ms │     714.51 / 726.58 ±10.30 / 745.62 ms │     no change │
│ QQuery 21 │     759.17 / 765.43 ±4.01 / 771.15 ms │      757.87 / 762.47 ±3.01 / 766.74 ms │     no change │
│ QQuery 22 │  1130.56 / 1135.51 ±5.00 / 1144.12 ms │   1126.58 / 1131.44 ±3.45 / 1136.13 ms │     no change │
│ QQuery 23 │ 3076.89 / 3091.52 ±14.61 / 3115.69 ms │   3039.29 / 3051.77 ±6.58 / 3057.50 ms │     no change │
│ QQuery 24 │      99.64 / 103.26 ±3.96 / 110.88 ms │      101.25 / 102.93 ±2.59 / 108.05 ms │     no change │
│ QQuery 25 │     137.98 / 139.26 ±0.99 / 141.04 ms │      139.03 / 140.87 ±1.51 / 143.21 ms │     no change │
│ QQuery 26 │      99.40 / 101.26 ±1.53 / 103.96 ms │       98.27 / 101.75 ±2.31 / 104.70 ms │     no change │
│ QQuery 27 │     847.69 / 853.45 ±6.14 / 864.08 ms │      853.40 / 862.91 ±9.09 / 878.90 ms │     no change │
│ QQuery 28 │ 3226.22 / 3252.91 ±22.69 / 3291.06 ms │   3266.92 / 3273.56 ±7.98 / 3283.43 ms │     no change │
│ QQuery 29 │        49.92 / 55.40 ±5.95 / 66.66 ms │         51.25 / 55.08 ±4.96 / 64.69 ms │     no change │
│ QQuery 30 │     356.34 / 360.72 ±3.85 / 366.30 ms │      360.91 / 365.75 ±2.85 / 368.66 ms │     no change │
│ QQuery 31 │     370.15 / 374.09 ±5.16 / 384.12 ms │      386.99 / 393.08 ±3.53 / 396.52 ms │  1.05x slower │
│ QQuery 32 │ 1211.40 / 1249.72 ±33.32 / 1311.21 ms │ 1102.22 / 1264.41 ±140.92 / 1489.89 ms │     no change │
│ QQuery 33 │ 1516.49 / 1536.85 ±14.62 / 1555.02 ms │  1429.64 / 1450.41 ±18.65 / 1475.11 ms │ +1.06x faster │
│ QQuery 34 │ 1465.20 / 1497.56 ±28.05 / 1547.90 ms │  1431.03 / 1449.80 ±20.79 / 1480.06 ms │     no change │
│ QQuery 35 │     379.51 / 381.22 ±2.32 / 385.69 ms │      384.37 / 386.95 ±2.06 / 390.01 ms │     no change │
│ QQuery 36 │     112.54 / 119.67 ±4.71 / 126.19 ms │      119.55 / 122.23 ±2.21 / 126.07 ms │     no change │
│ QQuery 37 │        46.52 / 48.58 ±1.42 / 50.61 ms │         46.53 / 48.80 ±1.20 / 49.98 ms │     no change │
│ QQuery 38 │        74.56 / 76.93 ±1.40 / 78.56 ms │         75.70 / 76.94 ±0.69 / 77.71 ms │     no change │
│ QQuery 39 │     214.37 / 218.21 ±3.99 / 225.63 ms │      208.28 / 215.29 ±5.81 / 224.80 ms │     no change │
│ QQuery 40 │        20.83 / 24.90 ±2.62 / 28.78 ms │         24.42 / 26.87 ±1.86 / 29.45 ms │  1.08x slower │
│ QQuery 41 │        20.10 / 20.84 ±1.19 / 23.21 ms │         19.26 / 21.01 ±0.95 / 21.96 ms │     no change │
│ QQuery 42 │        19.09 / 19.47 ±0.34 / 20.02 ms │         19.36 / 20.07 ±0.82 / 21.67 ms │     no change │
└───────────┴───────────────────────────────────────┴────────────────────────────────────────┴───────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ Benchmark Summary               ┃            ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━┩
│ Total Time (HEAD)               │ 22625.17ms │
│ Total Time (file-stats-cache)   │ 22554.80ms │
│ Average Time (HEAD)             │   526.17ms │
│ Average Time (file-stats-cache) │   524.53ms │
│ Queries Faster                  │          2 │
│ Queries Slower                  │          4 │
│ Queries with No Change          │         37 │
│ Queries with Failure            │          0 │
└─────────────────────────────────┴────────────┘

Resource Usage

clickbench_partitioned — base (merge-base)

Metric Value
Wall time 114.3s
Peak memory 38.5 GiB
Avg memory 28.7 GiB
CPU user 1063.0s
CPU sys 95.9s
Peak spill 0 B

clickbench_partitioned — branch

Metric Value
Wall time 113.9s
Peak memory 41.7 GiB
Avg memory 30.9 GiB
CPU user 1062.3s
CPU sys 94.8s
Peak spill 0 B

File an issue against this benchmark runner

@mkleen
Copy link
Copy Markdown
Contributor Author

mkleen commented Apr 15, 2026

This looks much better now:

┏━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓
┃ Query     ┃                                  HEAD ┃                       file-stats-cache ┃        Change ┃
┡━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩
│ QQuery 0  │          1.21 / 4.43 ±6.35 / 17.13 ms │           1.24 / 4.48 ±6.39 / 17.27 ms │     no change │

There are a few minor regressions which could be just noise. Could we do a benchmark second run?

@mkleen
Copy link
Copy Markdown
Contributor Author

mkleen commented Apr 15, 2026

@kosiew I added all the changes you requested. Could you do another review please?

@adriangb
Copy link
Copy Markdown
Contributor

run benchmark clickbench_partitioned

@adriangbot
Copy link
Copy Markdown

🤖 Benchmark running (GKE) | trigger
Instance: c4a-highmem-16 (12 vCPU / 65 GiB) | Linux bench-c4252876807-1300-wbhhh 6.12.55+ #1 SMP Sun Feb 1 08:59:41 UTC 2026 aarch64 GNU/Linux

CPU Details (lscpu)
Architecture:                            aarch64
CPU op-mode(s):                          64-bit
Byte Order:                              Little Endian
CPU(s):                                  16
On-line CPU(s) list:                     0-15
Vendor ID:                               ARM
Model name:                              Neoverse-V2
Model:                                   1
Thread(s) per core:                      1
Core(s) per cluster:                     16
Socket(s):                               -
Cluster(s):                              1
Stepping:                                r0p1
BogoMIPS:                                2000.00
Flags:                                   fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh rng bti
L1d cache:                               1 MiB (16 instances)
L1i cache:                               1 MiB (16 instances)
L2 cache:                                32 MiB (16 instances)
L3 cache:                                80 MiB (1 instance)
NUMA node(s):                            1
NUMA node0 CPU(s):                       0-15
Vulnerability Gather data sampling:      Not affected
Vulnerability Indirect target selection: Not affected
Vulnerability Itlb multihit:             Not affected
Vulnerability L1tf:                      Not affected
Vulnerability Mds:                       Not affected
Vulnerability Meltdown:                  Not affected
Vulnerability Mmio stale data:           Not affected
Vulnerability Reg file data sampling:    Not affected
Vulnerability Retbleed:                  Not affected
Vulnerability Spec rstack overflow:      Not affected
Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:                Mitigation; __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; CSV2, BHB
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Not affected

Comparing file-stats-cache (3b64005) to 244f891 (merge-base) diff using: clickbench_partitioned
Results will be posted here when complete


File an issue against this benchmark runner

@adriangb
Copy link
Copy Markdown
Contributor

@mkleen you should be able to trigger benchmark runs now fwiw

@adriangbot
Copy link
Copy Markdown

🤖 Benchmark completed (GKE) | trigger

Instance: c4a-highmem-16 (12 vCPU / 65 GiB)

CPU Details (lscpu)
Architecture:                            aarch64
CPU op-mode(s):                          64-bit
Byte Order:                              Little Endian
CPU(s):                                  16
On-line CPU(s) list:                     0-15
Vendor ID:                               ARM
Model name:                              Neoverse-V2
Model:                                   1
Thread(s) per core:                      1
Core(s) per cluster:                     16
Socket(s):                               -
Cluster(s):                              1
Stepping:                                r0p1
BogoMIPS:                                2000.00
Flags:                                   fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 sve asimdfhm dit uscat ilrcpc flagm sb paca pacg dcpodp sve2 sveaes svepmull svebitperm svesha3 svesm4 flagm2 frint svei8mm svebf16 i8mm bf16 dgh rng bti
L1d cache:                               1 MiB (16 instances)
L1i cache:                               1 MiB (16 instances)
L2 cache:                                32 MiB (16 instances)
L3 cache:                                80 MiB (1 instance)
NUMA node(s):                            1
NUMA node0 CPU(s):                       0-15
Vulnerability Gather data sampling:      Not affected
Vulnerability Indirect target selection: Not affected
Vulnerability Itlb multihit:             Not affected
Vulnerability L1tf:                      Not affected
Vulnerability Mds:                       Not affected
Vulnerability Meltdown:                  Not affected
Vulnerability Mmio stale data:           Not affected
Vulnerability Reg file data sampling:    Not affected
Vulnerability Retbleed:                  Not affected
Vulnerability Spec rstack overflow:      Not affected
Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:                Mitigation; __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; CSV2, BHB
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Not affected
Details

Comparing HEAD and file-stats-cache
--------------------
Benchmark clickbench_partitioned.json
--------------------
┏━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓
┃ Query     ┃                                  HEAD ┃                      file-stats-cache ┃        Change ┃
┡━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩
│ QQuery 0  │          1.20 / 4.41 ±6.34 / 17.09 ms │          1.23 / 4.47 ±6.37 / 17.22 ms │     no change │
│ QQuery 1  │        14.66 / 14.94 ±0.24 / 15.25 ms │        14.41 / 14.57 ±0.22 / 15.00 ms │     no change │
│ QQuery 2  │        44.00 / 44.14 ±0.13 / 44.37 ms │        43.38 / 43.86 ±0.28 / 44.25 ms │     no change │
│ QQuery 3  │        42.56 / 44.96 ±1.66 / 47.06 ms │        39.38 / 39.80 ±0.27 / 40.11 ms │ +1.13x faster │
│ QQuery 4  │     277.84 / 285.17 ±4.27 / 288.65 ms │     277.58 / 283.29 ±3.88 / 287.93 ms │     no change │
│ QQuery 5  │     337.90 / 341.30 ±2.18 / 343.91 ms │     331.05 / 336.37 ±3.60 / 342.10 ms │     no change │
│ QQuery 6  │           5.81 / 6.72 ±0.74 / 7.97 ms │           5.61 / 6.57 ±1.06 / 8.58 ms │     no change │
│ QQuery 7  │        16.68 / 17.12 ±0.25 / 17.45 ms │        16.62 / 16.71 ±0.10 / 16.90 ms │     no change │
│ QQuery 8  │     412.71 / 420.72 ±8.99 / 438.06 ms │    401.33 / 417.04 ±12.01 / 434.91 ms │     no change │
│ QQuery 9  │     628.36 / 639.32 ±6.84 / 648.31 ms │     621.94 / 634.97 ±6.93 / 640.84 ms │     no change │
│ QQuery 10 │        91.30 / 92.43 ±1.55 / 95.45 ms │        89.73 / 91.25 ±1.11 / 92.92 ms │     no change │
│ QQuery 11 │     102.80 / 104.42 ±1.63 / 106.92 ms │     102.82 / 103.85 ±0.81 / 105.11 ms │     no change │
│ QQuery 12 │     330.37 / 342.33 ±7.28 / 353.21 ms │     329.29 / 339.39 ±8.93 / 353.37 ms │     no change │
│ QQuery 13 │     442.00 / 457.80 ±9.56 / 469.38 ms │    446.65 / 468.59 ±18.24 / 501.15 ms │     no change │
│ QQuery 14 │     340.00 / 343.67 ±3.22 / 348.81 ms │     338.85 / 341.73 ±2.69 / 346.04 ms │     no change │
│ QQuery 15 │    338.12 / 354.82 ±16.14 / 377.72 ms │    346.50 / 356.33 ±12.66 / 379.30 ms │     no change │
│ QQuery 16 │    708.06 / 723.87 ±12.97 / 744.24 ms │     706.01 / 711.11 ±3.92 / 717.49 ms │     no change │
│ QQuery 17 │    715.71 / 730.38 ±12.93 / 747.68 ms │     698.61 / 705.25 ±5.38 / 712.25 ms │     no change │
│ QQuery 18 │ 1378.74 / 1436.15 ±37.91 / 1469.96 ms │ 1383.04 / 1437.28 ±44.46 / 1496.70 ms │     no change │
│ QQuery 19 │        37.02 / 37.84 ±0.96 / 39.19 ms │        36.18 / 39.82 ±4.88 / 49.32 ms │  1.05x slower │
│ QQuery 20 │    716.69 / 731.14 ±15.09 / 750.37 ms │    725.77 / 733.04 ±10.62 / 753.75 ms │     no change │
│ QQuery 21 │     764.90 / 771.26 ±5.19 / 777.90 ms │     763.26 / 769.93 ±7.02 / 781.56 ms │     no change │
│ QQuery 22 │  1122.81 / 1133.34 ±9.73 / 1151.56 ms │  1124.96 / 1130.72 ±5.44 / 1140.42 ms │     no change │
│ QQuery 23 │ 3063.02 / 3081.51 ±19.54 / 3118.72 ms │  3042.83 / 3056.84 ±8.77 / 3066.95 ms │     no change │
│ QQuery 24 │      99.74 / 103.07 ±2.95 / 108.55 ms │      97.02 / 100.93 ±3.57 / 107.30 ms │     no change │
│ QQuery 25 │     138.79 / 140.58 ±0.90 / 141.15 ms │     139.78 / 140.29 ±0.44 / 140.84 ms │     no change │
│ QQuery 26 │      99.52 / 102.28 ±1.54 / 103.79 ms │      97.25 / 101.33 ±2.14 / 103.23 ms │     no change │
│ QQuery 27 │     854.45 / 860.84 ±5.56 / 870.82 ms │     853.36 / 859.57 ±9.11 / 877.44 ms │     no change │
│ QQuery 28 │ 3223.14 / 3249.41 ±14.73 / 3262.38 ms │ 3247.39 / 3284.04 ±39.67 / 3357.60 ms │     no change │
│ QQuery 29 │        50.82 / 55.21 ±4.88 / 63.83 ms │        49.48 / 54.42 ±4.77 / 61.76 ms │     no change │
│ QQuery 30 │     347.81 / 357.04 ±9.12 / 374.37 ms │     358.70 / 364.92 ±5.85 / 373.08 ms │     no change │
│ QQuery 31 │     370.47 / 383.69 ±9.73 / 399.15 ms │     367.60 / 378.83 ±9.88 / 389.85 ms │     no change │
│ QQuery 32 │ 1008.93 / 1030.16 ±13.99 / 1047.10 ms │ 1173.76 / 1262.84 ±67.20 / 1346.01 ms │  1.23x slower │
│ QQuery 33 │ 1426.46 / 1447.75 ±11.49 / 1458.03 ms │ 1426.13 / 1462.42 ±45.20 / 1547.49 ms │     no change │
│ QQuery 34 │ 1464.62 / 1498.65 ±36.46 / 1567.14 ms │  1450.39 / 1461.55 ±7.78 / 1472.24 ms │     no change │
│ QQuery 35 │     376.16 / 382.30 ±3.92 / 387.34 ms │     377.19 / 380.00 ±2.51 / 383.30 ms │     no change │
│ QQuery 36 │     111.64 / 120.63 ±4.76 / 125.65 ms │     119.36 / 120.81 ±0.87 / 122.03 ms │     no change │
│ QQuery 37 │        45.90 / 48.52 ±1.36 / 49.60 ms │        47.66 / 50.28 ±2.54 / 54.27 ms │     no change │
│ QQuery 38 │        74.71 / 76.52 ±1.83 / 79.23 ms │        76.16 / 80.54 ±4.36 / 87.71 ms │  1.05x slower │
│ QQuery 39 │     207.02 / 211.26 ±3.00 / 215.60 ms │     214.23 / 216.50 ±2.47 / 221.30 ms │     no change │
│ QQuery 40 │        21.93 / 25.15 ±2.03 / 27.79 ms │        24.72 / 27.01 ±1.62 / 28.53 ms │  1.07x slower │
│ QQuery 41 │        19.47 / 21.27 ±1.51 / 23.58 ms │        19.48 / 21.20 ±1.53 / 23.28 ms │     no change │
│ QQuery 42 │        18.99 / 19.59 ±0.62 / 20.63 ms │        19.71 / 20.32 ±0.46 / 20.96 ms │     no change │
└───────────┴───────────────────────────────────────┴───────────────────────────────────────┴───────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━┓
┃ Benchmark Summary               ┃            ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━┩
│ Total Time (HEAD)               │ 22293.70ms │
│ Total Time (file-stats-cache)   │ 22470.59ms │
│ Average Time (HEAD)             │   518.46ms │
│ Average Time (file-stats-cache) │   522.57ms │
│ Queries Faster                  │          1 │
│ Queries Slower                  │          4 │
│ Queries with No Change          │         38 │
│ Queries with Failure            │          0 │
└─────────────────────────────────┴────────────┘

Resource Usage

clickbench_partitioned — base (merge-base)

Metric Value
Wall time 112.6s
Peak memory 41.5 GiB
Avg memory 32.9 GiB
CPU user 1064.0s
CPU sys 83.9s
Peak spill 0 B

clickbench_partitioned — branch

Metric Value
Wall time 113.3s
Peak memory 37.2 GiB
Avg memory 27.8 GiB
CPU user 1061.6s
CPU sys 92.6s
Peak spill 0 B

File an issue against this benchmark runner

@mkleen
Copy link
Copy Markdown
Contributor Author

mkleen commented Apr 15, 2026

Ok, the benchmarks are looking good now again. At the moment we have 20 mb default cache size, with 10 mb the stats for clickhouse_partitioned did not fit yet. I wonder what would be a reasonable default value?

Copy link
Copy Markdown
Contributor

@kosiew kosiew left a comment

Choose a reason for hiding this comment

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

@mkleen,

Thanks for the updates here, this is shaping up nicely.

I still have a couple of concerns.

Some previously noted issues appear to be intentionally deferred, like the Arc heap size double-counting and the empty string parsing case. Could you clarify whether those are planned for a follow-up PR?

I also ran into two additional issues while reviewing the final diff, including what looks like a functional regression in the reader path cache wiring. Because of that, I am not yet confident that the branch is free of new problems.

Would love your thoughts on the points below.

let table = ListingTable::try_new(config)?.with_definition(sql_definition);
let table = ListingTable::try_new(config)?
.with_definition(sql_definition)
.with_cache(self.runtime_env().cache_manager.get_file_statistic_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.

I noticed that only the registered-listing-table path was updated to call .with_cache(...). Was it intentional that the generic reader path in _read_type() still uses ListingTable::try_new(config)? without attaching the runtime cache?

With ListingTable now defaulting collected_statistics to None, could this mean that SessionContext::read_parquet, read_csv, read_json, read_avro, and similar methods no longer benefit from the file statistics cache?

If so, would this be considered a regression in the default-cache rollout? How do you see this affecting users who rely on those reader paths?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No this was not intentional. This needs to be fixed. Thanks a lot!

Some("50M".to_owned()),
Some("1M".to_owned()),
None,
Some("1M".to_owned()),
Copy link
Copy Markdown
Contributor

@kosiew kosiew Apr 16, 2026

Choose a reason for hiding this comment

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

I see that DEFAULT_FILE_STATISTICS_MEMORY_LIMIT was increased to 20 MiB, but RuntimeEnvBuilder::entries() still hard-codes Some("1M".to_owned()) for datafusion.runtime.file_statistics_cache_limit.

Would it make sense to update entries() to match the new default?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, good point.

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

Labels

catalog Related to the catalog crate common Related to common crate core Core DataFusion crate datasource Changes to the datasource crate documentation Improvements or additions to documentation execution Related to the execution crate sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a default FileStatisticsCache implementation for the ListingTable Add limit to DefaultFileStatisticsCache

8 participants