Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[InMemoryDataset redesign] Read many slices at once with the HDF5 C API #378

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

crusaderky
Copy link
Collaborator

This is an alternative to #370 after it's been found out that virtual datasets perform very poorly in libhdf5.

Add a function to quickly read potentially thousands of slices from HDF5 into a numpy array, or between numpy arrays. This new function remains dormant for now and will be used in a later PR by a variant of StagedChangesArray from #370.

@crusaderky crusaderky force-pushed the h5multiread branch 4 times, most recently from 624332d to bb6291f Compare October 3, 2024 00:38
@crusaderky crusaderky self-assigned this Oct 3, 2024
@crusaderky crusaderky changed the title [WIP] Read many slices at once with the HDF5 C API [InMemoryDataset redesign] Read many slices at once with the HDF5 C API Oct 3, 2024
Copy link
Collaborator

@peytondmurray peytondmurray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this - the tests seem comprehensive, and I think there's only one place where we might need a lock. Otherwise this looks great! 🚀

@@ -11,6 +11,16 @@ py.install_sources(
subdir: 'versioned_hdf5',
)

# Adapted from https://numpy.org/doc/2.1/reference/random/examples/cython/meson.build.html
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

"""Implements read_many_slices data transfer when fast transfer cannot be performed.

This happens when:
1. src is a h5py.Dataset but h5py.Dataset._fast_read_ok returns False.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need a with phil lock here in the case where src is an h5py.Dataset.



def test_read_many_slices_not_fast_read_ok(h5file):
"""src is a h5py dataset that doesn't support fast read"""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be good to outline somewhere in the docs when a dataset supports fast reading, since there is a significant difference in performance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants