I have a very simple prototype that is mostly based upon examples from the “Learning the Basics” chapter, in particular the C++ version of “Create a chunked and compressed dataset”. Right now, this prototype is severely performance-bottlenecked by compressing the chunks.
With the setup I have at hand, a 50GB sample dataset can be written in around 40 seconds uncompressed, but writing the same dataset takes almost 4 minutes with byteshuffle and level 1 deflate. The time difference between using the built-in shuffle/deflate or the one from the blosc2 filter plugin is measurable, but not in order of magnitudes.
I found the document HDF5ImprovingIOPerformanceCompressedDatasets.pdf, which mostly suggests optimizing chunk sizes. While I concede that my chunk sizes aren’t super optimized, this doesn’t appear to be the main issue. The main issue is probably that the chunks are processed sequentially (compress/write 1 → compress/write 2 → compress/write 3 …), and hence available CPU cores are not utilized as they should be.
For writing a single chunk I currently use H5::DataSpace::selectHyperslab followed by H5::DataSet::write.
Some ideas:
- Do compression/decompression manually and use direct chunk access via H5Dwrite_chunk / H5Dread_chunk. This approach was suggested by someone from The HDF Group Staff ten years ago, see queuing-chunks-for-compression-and-writing. I am not sure how up-to-date that advice still is.
- Feed into selectHyperslab and write from multiple threads. Intuitively this feels suspicious. I would expect that the library ensures thread-safety in a way that probably prevents this approach from delivering huge performance benefits.
- Using the ParallelHDF5 approach and then feed into that from multiple threads. This seems to be primarily targeted towards multi-process applications and as such appears to be inherently overkill for single-process applications, but looks feasible in principle. The degree of potential performance benefits is again unclear.
If anyone can share experiences or recommendations, it would be greatly appreciated.