[python] Cache file-format metadata across reads#8731
Conversation
|
Please document this in pytorch doc. |
|
Thanks for working on this. I checked how similar systems handle repeated Parquet reads, and this is a well-established optimization rather than a Paimon-specific workaround:
So the overall direction here looks sound, especially for immutable Paimon data files and long-lived PyTorch workers. Reusing the PyArrow Dataset is also a pragmatic way to extend the lifetime of PyArrow's built-in fragment metadata cache. The per- A few suggestions:
Overall, this has strong precedent in other Parquet engines. My main design concern is the predictability of memory usage; the cache scope and immutable-file assumption should also be documented clearly. |
|
One additional thought on naming: I would suggest:
If we use the generic
For example, the option description could say:
If this PR intentionally guarantees and tests only Parquet footer reuse, keeping a |
Added |
Thanks. I’ve documented the immutable-file and per-process/FileIO cache scope. Byte-based limits, observability, and remote-storage benchmarks will be follow-ups, since PyArrow does not expose the exact retained Dataset size. This PR remains opt-in and entry-bounded, with a test verifying reduced footer I/O. |
Thanks. This PR intentionally guarantees and tests only Parquet footer reuse, so I kept the more precise parquet.* namespace and renamed the limit to parquet.metadata-cache-max-entries. A format-aware generic cache can be introduced if ORC/IPC support is added later. |
|
Just one option: |
|
This is a public API option, so we need to be cautious. Additionally, we’ve already implemented many standardized configurations on the Paimon side, such as |
|
Another potentially more useful cache might be the Blob file cache. |
|
Thanks. Updated as suggested:
The Blob file cache can be handled separately. |
|
Maybe 50MB by default? I remember DataFusion is 50 MB. |
DataFusion uses 50 MB per RuntimeEnv, while this cache is scoped per FileIO, so multiple FileIO instances may each use up to the configured limit. Given the difference in scope, what default would you suggest? |
Why this cache is scoped per FileIO? |
Revised and updated 50MB as default. |
Purpose
Cache reusable PyArrow Dataset metadata across repeated reads in the same process.
The process-wide LRU is isolated by filesystem identity and bounded by estimated metadata size. It benefits long-lived readers such as persistent PyTorch workers; separate worker processes keep independent caches. The cache assumes immutable Paimon data files.
Option:
file-format.metadata-cache.max-size(default:50 mb;0 bbypasses)Tests
pypaimon/tests/parquet_metadata_cache_test.pypypaimon/tests/reader_base_test.py