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

Make __getitem__ for raw imageseries threadsafe #611

Merged
merged 2 commits into from
Jan 25, 2024

Conversation

psavery
Copy link
Collaborator

@psavery psavery commented Jan 25, 2024

This ensures that for multithreaded situations (such as writing out a frame cache), __getitem__ will be thread-safe. The change ensures that the frame will be obtained immediately after seeking, and no other thread can seek until the frame is obtained.

When I test the example Darren gave us (#608) on the master branch with no multithreading, it ran in 5m 37s. With this change, and using multithreading, it ran in 5m 13s. So the multithreading produced a minor speed increase.

Fixes: #608

This ensures that for multithreaded situations (such as writing out
a frame cache), `__getitem__` will be thread-safe. The change ensures
that the frame will be obtained immediately after seeking, and no other
thread can seek until the frame is obtained.

When I test the example Darren gave us (#608) on the master branch with
no multithreading, it ran in 5m 36.826s. With this change, and using
multithreading, it ran in 5m 12.811s. So the multithreading produced
a minor speed increase.

Fixes: #608

Signed-off-by: Patrick Avery <[email protected]>
Since we were not evaluating the outputs of the threads before, the
errors would not get propagated, leading to confusion.

Propagating the errors ensures that users can see (and report) when
they encounter an error.

Signed-off-by: Patrick Avery <[email protected]>
@psavery
Copy link
Collaborator Author

psavery commented Jan 25, 2024

@donald-e-boyce Can you look over this? Feel free to run some of your tests to see if you notice a performance impact caused by the thread locking.

Copy link
Collaborator

@donald-e-boyce donald-e-boyce left a comment

Choose a reason for hiding this comment

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

This all looks good, and I tested it and it runs well.

@donald-e-boyce donald-e-boyce merged commit 81bc561 into master Jan 25, 2024
6 checks passed
@psavery psavery deleted the raw-frames-threadsafe branch January 25, 2024 21:24
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.

Issue with Frame Cache Writing using Multiprocessing
2 participants