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

Change where nd2 data gets copied. #853

Merged
merged 1 commit into from
May 4, 2022
Merged

Change where nd2 data gets copied. #853

merged 1 commit into from
May 4, 2022

Conversation

manthey
Copy link
Member

@manthey manthey commented May 4, 2022

We are using the dask interface with nd2 to avoid loading all of a file into memory. When we read anything other then an entire frame, the default is to copy the entire frame in memory and THEN apply whatever index and step is being used. The nd2 library docs caution that if copy isn't done, there can be a segfault. Instead, use our own lock, get the frame data, subset it with our index and step and THEN copy it; since this is in a singular lock, it won't have any greater risk that the nd2 library. Since the copy only applies to the actual data we are using, much less memory is copied.

In a simple example with a file with large tiles, this saves close to 2 seconds per tile.

We are using the dask interface with nd2 to avoid loading all of a file
into memory.  When we read anything other then an entire frame, the
default is to copy the entire frame in memory and THEN apply whatever
index and step is being used.  The nd2 library docs caution that if copy
isn't done, there can be a segfault.  Instead, use our own lock, get the
frame data, subset it with our index and step and THEN copy it; since
this is in a singular lock, it won't have any greater risk that the nd2
library.  Since the copy only applies to the actual data we are using,
much less memory is copied.

In a simple example with a file with large tiles, this saves close to 2
seconds per tile.
@manthey manthey force-pushed the nd2-lock-and-copy branch from 05f0c9a to 401ac3d Compare May 4, 2022 14:45
@manthey manthey merged commit 2eccfeb into master May 4, 2022
@manthey manthey deleted the nd2-lock-and-copy branch May 4, 2022 15:10
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.

1 participant