Repository navigation
Respect zero per-dataset chunk cache settings - #2986
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2986 +/- ##
==========================================
+ Coverage 90.51% 90.62% +0.11%
==========================================
Files 16 16
Lines 2551 2561 +10
==========================================
+ Hits 2309 2321 +12
+ Misses 242 240 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
rmz-oz
left a comment
There was a problem hiding this comment.
zero cache values get applied now, I checked rdcc_nbytes, rdcc_nslots and rdcc_w0 = 0 through create_dataset and require_dataset against master. the prefixes on the same line still go through truthiness though: create_dataset(..., efile_prefix='') or virtual_prefix='' raises AttributeError: 'NoneType' object has no attribute 'set_efile_prefix' because dapl never gets created, and require_dataset on an existing dataset hits the same thing in open_dset. that's older than this PR, but the line is rewritten here anyway, and with is not None test_dataset.py still passes.
| if any([efile_prefix, virtual_prefix, rdcc_nbytes, rdcc_nslots, rdcc_w0]): | ||
| have_cache_settings = any( | ||
| value is not None for value in (rdcc_nbytes, rdcc_nslots, rdcc_w0)) | ||
| if efile_prefix or virtual_prefix or have_cache_settings: |
There was a problem hiding this comment.
| if efile_prefix or virtual_prefix or have_cache_settings: | |
| if efile_prefix is not None or virtual_prefix is not None or have_cache_settings: |
There was a problem hiding this comment.
Thanks @rmz-oz, good catch. I applied both suggestions, so empty str and bytes prefixes now get a DAPL before set_efile_prefix() / set_virtual_prefix() runs.
The new test covers both prefix options through create_dataset, require_dataset creating the dataset, and require_dataset reopening it after the file is closed, with None as a control. Each case checks the prefix on the access property list and writes and reads back data. Before the fix, the 12 empty-prefix cases failed with the AttributeError and the 6 None cases passed. With the fix, the full suite passes locally (907 passed, 79 skipped; Linux, CPython 3.12, HDF5 1.10.10).
| if any([efile_prefix, virtual_prefix, rdcc_nbytes, rdcc_nslots, rdcc_w0]): | ||
| have_cache_settings = any( | ||
| value is not None for value in (rdcc_nbytes, rdcc_nslots, rdcc_w0)) | ||
| if efile_prefix or virtual_prefix or have_cache_settings: |
There was a problem hiding this comment.
same here
| if efile_prefix or virtual_prefix or have_cache_settings: | |
| if efile_prefix is not None or virtual_prefix is not None or have_cache_settings: |
|
Hi @rioyu123, Thanks for the PR.
Follow-up work – not yoursI became aware while reviewing this PR that more work is needed but it does not belong here. The chunk cache settings are built in three steps: (1) read whatever the DAPL currently holds; (2) overwrite with the entries the caller supplied; (3) set all three back. These steps look simple and safe, but the first step is actually problematic. A DAPL that has just been created does not hold numbers for these three properties. It holds sentinels, and a sentinel means: I have nothing to say about this one, use whatever the file was opened with. Libhdf5 honors that when the dataset is opened: The catch is that reading those sentinels back out again is not possible. To fix what I just described requires a follow-up because the fix needs decisions that are not really appropriate for this PR. So: add the |
|
Thanks @ajelenak. I've added the inheritance assertions and the release-note caveat. The explicit-option and data round-trip checks run before the xfail is applied, so they still fail normally: with the production fix reverted, all 21 original regressions fail. On HDF5 2.2.0, the three cases you identified account for the nine expected failures across the three dataset paths. One note from testing: when the cache is disabled with zero bytes or zero slots, HDF5 reports both sizes as zero. Those cases keep their explicit-option and round-trip checks but skip the inheritance assertions. Full suite: HDF5 2.2.0 gives 930 passed, 47 skipped, 9 xfailed; HDF5 1.10.10 gives 901 passed, 85 skipped, with all 39 focused cases passing normally. As requested, the inheritance fix itself stays out of this PR. |
|
Thanks @rioyu123. I'll merge this on October 30 unless there are further comments from other maintainers. |
Group.create_dataset()andGroup.require_dataset()silently ignore an individualrdcc_nbytes=0,rdcc_nslots=0, orrdcc_w0=0. Both dataset helpers check these options for truthiness, so the dataset keeps the file's cache settings instead of applying the requested zero.These are meaningful settings: zero bytes or slots disables the chunk cache for a dataset, and
rdcc_w0=0selects strict LRU preemption. The helpers now check whether a value was supplied (is not None), consistent withFile(...). Omitted options and explicitNoneremain unchanged.The DAPL allocation guard now also uses
is not Nonechecks forefile_prefixandvirtual_prefix. This fixes anAttributeErrorwhen either is an emptystrorbytes. Behavior forNoneand non-empty prefixes is unchanged.There is a separate inheritance limitation: supplying a cache option currently replaces unspecified options with HDF5 defaults rather than preserving the file's settings. The release note now calls this out, and the tests record it as an expected failure, as requested in the review. Fixing that behavior is left to the maintainer's follow-up.
Regression coverage exercises dataset creation,
require_dataset()creating a dataset, andrequire_dataset()reopening an existing one. Explicit cache settings and data round-trips are checked before the inheritance xfail is applied. The zero-byte and zero-slot cases keep those checks; they skip the inheritance assertions because HDF5 reports both sizes as zero when the cache is disabled. Prefix tests cover empty strings, empty bytes, andNonethrough all three paths.Tests
October 23 follow-up: Linux, Python 3.12.3, NumPy 2.5.3, with separate h5py builds from this PR's source against HDF5 2.2.0 and 1.10.10. Both builds have ROS3 and direct VFD support disabled. This follow-up changes only tests and the release note; production code is unchanged from
6d43248.--runxfail, the new inheritance checks produce 9 failures:zero_preemption,positive_preemption, andmixed_valuesacross the three dataset paths. The other 30 focused cases pass.python -m pytest h5py/tests/test_dataset.py h5py/tests/test_group.py --no-network -q -rxXs: 399 passed, 9 xfailed.python -m pytest --pyargs h5py --no-network -q -rxXs: 930 passed, 47 skipped, 9 xfailed, 3 subtests passed.pre-commit run --files h5py/tests/test_dataset.py news/zero-dataset-chunk-cache.rst: passed.I ran pytest and pre-commit directly, not the full tox/platform/HDF5-version matrix.