Skip to main content

Concurrent HDF5 and NetCDF4 reader (experimental)

Project description

Crates.io PyPI Documentation Build (rust) Build (python) codecov Rust nightly

HIDEFIX

This Rust and Python library provides an alternative reader for the HDF5 file or NetCDF4 file (which uses HDF5) which supports concurrent access to data. This is achieved by building an index of the chunks, allowing a thread to use many file handles to read the file. The original (native) HDF5 library is used to build the index, but once it has been created it is no longer needed. The index can be serialized to disk so that performing the indexing is not necessary.

In Rust:

use hidefix::prelude::*;

let idx = Index::index("tests/data/coads_climatology.nc4").unwrap();
let mut r = idx.reader("SST").unwrap();

let values = r.values::<f32>(None, None).unwrap();

println!("SST: {:?}", values);

or with Python using Xarray:

import xarray as xr
import hidefix

ds = xr.open_dataset('file.nc', engine='hidefix')
print(ds)

See the example for how to use hidefix for regular, parallel or concurrent reads.

Motivation

The HDF5 library requires internal locks to be thread-safe since it relies on internal buffers which cannot be safely accessed/written to from multiple threads. This effectively causes multi-threaded applications to use sequential reads, while competing for the locks. And also apparently cause each other trouble, perhaps through dropping cached chunks which other threads still need. It can be safely used from different processes, but that requires potentially much more overhead than multi-threaded or asynchronous code.

Some basic benchmarks

hidefix is intended to perform better when concurrent reads are made either to the same dataset, same file or to different files from a single process. For basic benchmarks the performance is on-par or slightly better compared to doing standard sequential reads than the native HDF5 library (through its rust-bindings). Where hidefix shines is once the multiple threads in the same process tries to read in any way from a HDF5 file simultaneously.

This simple benchmark tries to read a small dataset sequentially or concurrently using the cached reader from hidefix and the native reader from HDF5. The dataset is chunked, shuffled and compressed (using gzip):

$ cargo bench --bench concurrency -- --ignored

test shuffled_compressed::cache_concurrent_reads  ... bench:  15,903,406 ns/iter (+/- 220,824)
test shuffled_compressed::cache_sequential        ... bench:  59,778,761 ns/iter (+/- 602,316)
test shuffled_compressed::native_concurrent_reads ... bench: 411,605,868 ns/iter (+/- 35,346,233)
test shuffled_compressed::native_sequential       ... bench: 103,457,237 ns/iter (+/- 7,703,936)

Inspiration and other projects

This work is based in part on the DMR++ module of the OPeNDAP Hyrax server. The zarr format does something similar, and the same approach has been tested out on HDF5 as swell.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hidefix-0.11.0.tar.gz (9.2 MB view details)

Uploaded Source

Built Distributions

hidefix-0.11.0-cp39-abi3-win_amd64.whl (3.1 MB view details)

Uploaded CPython 3.9+ Windows x86-64

hidefix-0.11.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (9.2 MB view details)

Uploaded CPython 3.9+ manylinux: glibc 2.17+ x86-64

hidefix-0.11.0-cp39-abi3-macosx_11_0_arm64.whl (1.5 MB view details)

Uploaded CPython 3.9+ macOS 11.0+ ARM64

File details

Details for the file hidefix-0.11.0.tar.gz.

File metadata

  • Download URL: hidefix-0.11.0.tar.gz
  • Upload date:
  • Size: 9.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.14

File hashes

Hashes for hidefix-0.11.0.tar.gz
Algorithm Hash digest
SHA256 2d8f8a3db10ed24b3797682dc103285f4114e5d916a4bf3e95e1e1dc679c6bbf
MD5 64d8febe8fad5d988390512f1b6e1e23
BLAKE2b-256 8325337f631befc19cb556576947b7a21d354b78fe7806e11ed0c477e8f8b6c9

See more details on using hashes here.

File details

Details for the file hidefix-0.11.0-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: hidefix-0.11.0-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 3.1 MB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.14

File hashes

Hashes for hidefix-0.11.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 1b869915b1badb54d3482d3d1da8f8cc55c2dd098097d0007d68a6c1620ec238
MD5 7d0b24c72a140d8078915e87d0c39d9c
BLAKE2b-256 f9616cd99c0833171a19b77fcec25d8a2b62b28f4da7708e1f8f07d49650d62d

See more details on using hashes here.

File details

Details for the file hidefix-0.11.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for hidefix-0.11.0-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ffa9651d440c93c2db568d8e620b5e1eedec2fd17118ce70662f2c99381f15fa
MD5 24b6740a73ea415d6498a66072423527
BLAKE2b-256 2e8e2943fb200d44e4dd359c2d847972c2560c0d634cfb3e65fcb5ba5baa0374

See more details on using hashes here.

File details

Details for the file hidefix-0.11.0-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for hidefix-0.11.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 686259678bd72d277a6e3bb2631142a9d52e9361f8d377af6b4bc0ee77732d23
MD5 e5bceac027d86a43ec523bcd82bd085c
BLAKE2b-256 97439c815e6c170b7872cb9e5da1e389f1340e2beb9bd0dbed7eff6056ac9a2f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page