Docs · I/O adapters
Cache HDF5 datasets with the VOL connector.
The VOL connector clio sits above the HDF5 library and caches whole dataset images in the Context Transfer Engine, so a dataset read again in a later session can come from a fast tier instead of slow storage. The native HDF5 file is always written first and stays authoritative. Select it with two environment variables; the application does not change.
- Connector
- clio (value 600)
- Library
- libclio_hdf5_vol.so
- Build
- CLIO_CTE_ENABLE_HDF5_VOL=ON, HDF5 1.14+
- Select
- HDF5_VOL_CONNECTOR=clio
- Install
- Spack (+vol), CMake, or the Docker image
What it does
A VOL (virtual object layer) connector sees each request as the application made it: this dataset, this selection, this datatype. The clio connector passes every operation to HDF5's native connector, so the file on disk is an ordinary HDF5 file that h5dump and h5py read with or without CLIO. In addition it mirrors dataset transfers into the CTE:
- Cached: datasets of atomic types (integer, float, enum, bitfield, fixed-length string), when the memory datatype is the native form of the stored type. The image is split into 64 KiB blobs by default.
- Passed through: compound, array, variable-length and reference types, transfers whose memory type converts, and everything that is not dataset I/O (groups, attributes, links).
- Served from the cache: whole-dataset reads, and hyperslab or point reads of a dataset whose image is already cached. A partial read never triggers staging, and a miss reads the native file.
- Invalidated: a partial write,
H5Dset_extentor a failed cache operation drops the dataset's image, so reads never see stale data.
1. Build it
$ cmake -S . -B build -DCLIO_CTE_ENABLE_HDF5_VOL=ON \
-DHDF5_ROOT=/path/to/the/hdf5/your/application/uses
$ cmake --build build -j"$(nproc)"
$ ls build/bin/libclio_hdf5_vol.so
$ ldd build/bin/libclio_hdf5_vol.so | grep hdf5 # must be the application's libhdf5HDF5 1.14 or newer is required. If CMake finds no suitable HDF5 it only warns and skips the connector, so check that the library exists. The connector comes with Spack (+vol, on by default), a CMake source build and the Docker image; see Install.
2. Start a runtime with a CTE pool
$ export CLIO_SERVER_CONF=$PWD/context-transfer-engine/adapter/config/clio_hdf5_quickstart.yaml
$ build/bin/clio-run start &clio_hdf5_quickstart.yaml is a small configuration (a 256 MB RAM tier, no persistence) that starts anywhere. For real workloads, start from context-runtime/config/clio_default.yaml, add your tiers, and rename its CTE pool to clio_cte_core: clients look the pool up by that exact name, and the default file's cte_main misses. Export the same CLIO_SERVER_CONF in the application's environment.
3. Select the connector
$ export HDF5_PLUGIN_PATH=$PWD/build/bin
$ export HDF5_VOL_CONNECTOR=clio
$ ./my_hdf5_app # or python, h5dump, any HDF5 programOptions can follow the name, in the semicolon-separated grammar other HDF5 connectors use. The recognised keys are cache (boolean) and chunk_size (bytes); an unknown key or a malformed value fails the open instead of being ignored.
$ export HDF5_VOL_CONNECTOR="clio cache=1;chunk_size=1048576"under_vol and under_info are accepted but have no effect yet: the connector always sits directly on the native connector and cannot be stacked over another pass-through connector.
Or select it in code
Include clio_vol.h (in context-transfer-engine/adapter/hdf5_vol/), link libclio_hdf5_vol.so, and put the connector on a file-access property list:
#include <hdf5.h>
#include "clio_vol.h"
hid_t vol = H5VL_clio_register();
clio_vol_info_t info = {0}; /* zeroed fields mean "use the default" */
info.under_vol_id = H5VL_NATIVE;
info.chunk_size = 1 << 20; /* optional: 1 MiB cache chunks */
hid_t fapl = H5Pcreate(H5P_FILE_ACCESS);
H5Pset_vol(fapl, vol, &info);
hid_t file = H5Fcreate("/scratch/run1/out.h5", H5F_ACC_TRUNC, H5P_DEFAULT, fapl);Always zero the struct. cache_enabled left at CLIO_VOL_CACHE_UNSET lets the environment decide; switching the tier off from code takes an explicit CLIO_VOL_CACHE_OFF.
4. An end-to-end example with h5py
Write a file in one session, then read it in later sessions. The file name is an ordinary path; the connector does not use the clio:: marker.
import h5py, numpy as np
with h5py.File("/scratch/run1/field.h5", "w") as f:
f["temperature"] = np.random.rand(1024, 1024)import h5py
with h5py.File("/scratch/run1/field.h5", "r") as f:
t = f["temperature"][...] # whole-dataset read
print(t.mean())$ export CLIO_REQUIRE_RUNTIME=1 CLIO_VOL_TRACE=$PWD/trace
$ export CLIO_VOL_ADMIT_COST=0 # demo only: stage even if the local disk is faster
$ mkdir -p trace
$ python write.py
$ python read.py # first read after the write: native, stages the image
$ python read.py # served from the CTE tier
$ grep -o '"read_bytes_from_cache": [0-9]*' trace/field.h5.*.access.jsonThe access summary of the last run should show bytes read from the cache. CLIO_VOL_ADMIT_COST=0 is there because on a local disk the file is already in the page cache, and the connector's cost gate (see Tuning) would correctly decide that caching cannot win. Leave it unset in production.
The first read after a write is always native, by design: at close the connector withholds the coherence stamp while the file's modification time is younger than one timestamp granule (10 ms by default), and a writing session always closes inside that window. The read-back stores a stamp, and the session after it can hit.
Confirm it is working
Correct data proves nothing: with no runtime, no CTE pool or the cache off, the connector quietly falls back to the native file and still returns correct data. Three tools tell the cases apart:
CLIO_REQUIRE_RUNTIME=1makes the open fail when the runtime or CTE pool cannot be reached, instead of falling back. Set it in tests, benchmarks and CI.CLIO_VOL_TRACE=<dir>writes<file>.<pid>.access.jsonl(one record perH5Dread/H5Dwrite) and, at file close, a<file>.<pid>.access.jsonsummary.read_bytes_from_cacheagainstread_bytes_from_nativeis the hit rate; thecoherenceblock (matched,mismatched,absent,ambiguous) explains the misses.scripts/clio-hdf5-doctor --smokechecks the environment, prints the fix for each problem, and round-trips a file through the connector.
When the runtime cannot be reached the connector prints [clio-vol] CLIO runtime unavailable; running as a pure pass-through to the native VOL (cache disabled) to stderr.
Tuning
CLIO_VOL_ADMIT- When data enters the tier:
read-miss(default),write, orsecond-access(stage a dataset only after it has missed twice). The default becomeswritewhenCLIO_STAMP_SETTLE_MAX_NSis set. - Cost gate
- On by default: a transfer is staged only if the native read measured slower than the tier is predicted to be, so caching is skipped on a fast local disk. The model starts from
CLIO_VOL_TIER_FIXED_US(60 µs per request) andCLIO_VOL_TIER_MBPS(1200) and re-estimates both from its own cache hits.CLIO_VOL_ADMIT_COST=0stages unconditionally. CLIO_VOL_CHUNK_SIZE- Blob size for dataset images, default 65536. A partial read fetches every chunk it touches, so this is the cost floor of a small read. It overrides
chunk_sizefrom the connector string or the info struct. CLIO_VOL_MAX_SERVE_BYTES- Datasets larger than this (default 1 GiB) are not served from the cache for partial reads, because serving one assembles the whole image in memory.
CLIO_VOL_MIN_STAGE_BYTES- Do not stage images smaller than this. Default 0.
CLIO_VOL_TIER_RETRY_MS- Cache blobs are written as droppable, so the CTE may reclaim them. When a put still fails because the tier is full, staging pauses for this long (default 5000 ms) and then probes again. The native write is never slowed.
CLIO_STAMP_GRANULARITY_NS- Timestamp granularity the coherence stamp assumes: 10 ms by default, 1 s on Windows. Raise it on filesystems with coarse timestamps (some NFS mounts, FAT).
CLIO_VOL_STAMP_GRANULARITY_NSis accepted as the older name. CLIO_STAMP_SETTLE_MAX_NS- Opt in to waiting, at close, until the file's timestamp has settled so the stamp is not withheld. Only safe for single-writer pipelines. Off (0) by default.
Guarantees and limits
- Flush and close are barriers.
H5Fflush,H5DflushandH5Fclosewait for all in-flight cache writes before returning. - Between sessions, changes are caught. The coherence stamp (device, inode, size, modification time and chunk size) is checked at open; anything but an exact match drops the file's cache. Modifying the file from another process while it is open is undefined, as with native HDF5.
- Collective reads are served from the tier like independent ones; their native fallbacks run as independent I/O.
- Partial reads assemble the whole image, so their cost grows with the dataset, not the selection.
- h5py drives dataset I/O through the connector, but some of its other code paths assume the native connector.
- When not to use it: a file on a local disk that fits in the page cache. A tier hit then replaces a page-cache hit with a runtime round trip. Measure against
CLIO_VOL_CACHE=0, which keeps the connector loaded with the tier off and needs no runtime.
Where to go next
- HDF5 VFD, for workloads the VOL connector passes through.
- Configuration reference: every variable with its default.
- HDF5 connector design. The repository's
context-transfer-engine/adapter/HDF5_QUICKSTART.mdcovers the same setup with a troubleshooting table.