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

Improve interactive OME-Zarr viewing performance in napari #45

Closed
jluethi opened this issue May 18, 2022 · 6 comments
Closed

Improve interactive OME-Zarr viewing performance in napari #45

jluethi opened this issue May 18, 2022 · 6 comments
Assignees
Labels
Backlog Backlog issues we may eventually fix, but aren't a priority

Comments

@jluethi
Copy link
Collaborator

jluethi commented May 18, 2022

Loading large, multi-well OME-Zarr projects into napari and browsing them interactively is still on the slower side. Here is an overview of what we're doing to improve that and what we can still try.

Things that we have already found to improve this:

  • Setting environmental variable NAPARI_ASYNC=1 before launching napari: Loading still a bit slow, but interface doesn't freeze while loading
  • Having the zarr files use compression (was already on by default), see here: Enable compression of Zarr files #28

Things we are working on:

Remaining issues:

Potentially contributing:

@jluethi
Copy link
Collaborator Author

jluethi commented May 18, 2022

I compared our performance with that for a test dataset that the ome-zarr devs use here:
ome/ome-zarr-py#195
napari --plugin napari-ome-zarr https://uk1s3.embassy.ebi.ac.uk/idr/zarr/v0.1/plates/422.zarr -vvv
(does not work with our version of the plugin, but if one installs the branch of that pull request, it works)

It opens faster (lower-res pyramids available), but browsing is fairly similar to our performance, so I would say that our OME hierarchy probably isn't the major factor slowing us down, it may come down mostly to the speed of the connection and the aggressiveness with which napari loads pyramid levels (and the apparently very limited caching of such levels it seems to do, e.g. zooming out typically needs to load the layers freshly).
They also don't have missing wells, so unclear whether that is an important influence

@jluethi jluethi added the High Level Overview planning issues label May 18, 2022
@jluethi
Copy link
Collaborator Author

jluethi commented May 23, 2022

Having more pyramids should make initial loading faster, right? No!
I went from 5 levels of pyramids (initial loading of plate ~ 4 min via VPN) to 10 levels of pyramids (initial loading of plate ~25 min via the same VPN connection)
=> looks like there are issues with too many pyramid levels or too many directories or such when loading ome zarr files into napari.
I've installed a dev version of the ome-zarr plugin (with their ome/ome-zarr-py#195 pull request for pyramid loading) and will start profiling this to get an idea where the issue could be (/understand what's going on).

@jluethi
Copy link
Collaborator Author

jluethi commented May 27, 2022

Improved chunking (see here: #32) massively improves interactive performance. We went from a chunking scheme where every original field of view had its own pyramid, thus there were the same number of files on every pyramid level. This took some 3+ minutes to load the plate and zooming was quite slow.

Now we have rechunked pyramids, such that the chunks stay approximately constant in size and thus there are fewer and fewer files, the lower the resolution of the pyramid becomes. This loads the 23 well plate in ~15s!
Also, interactive zooming seems somewhat improved. It's still quite slow to load full-res images, but faster than before.

Learnings:
Having tiny chunks is a performance hit in interactive browsing. Also, wonder how well the interactive browsing in general will scale with the number of files in the zarr container.

@jluethi
Copy link
Collaborator Author

jluethi commented Jun 2, 2022

We just talked with Kevin Yamauchi today (napari core dev). There is actually a large restructuring of the whole lazy-loading process currently in the works in the napari team, with Andy Sweet in the lead apparently. We'll try to attend some relevant napari community meetings to show our use case and get some ideas on whether they already work on things that will make our life easier :)

@jluethi jluethi moved this from Ready to TODO in Fractal Project Management Jun 13, 2022
@jluethi jluethi moved this from TODO to Backlog in Fractal Project Management Jun 13, 2022
@jluethi jluethi moved this from Backlog to On Hold in Fractal Project Management Jun 14, 2022
@jluethi jluethi removed this from the Improve OME-Zarr viewing milestone Jun 15, 2022
@jluethi jluethi self-assigned this Jul 12, 2022
@jluethi jluethi added the Backlog Backlog issues we may eventually fix, but aren't a priority label Aug 4, 2022
@jluethi jluethi added External Library and removed High Level Overview planning issues labels Aug 30, 2022
@jluethi
Copy link
Collaborator Author

jluethi commented Aug 30, 2022

Yes, the PR implementing these changes improves visualization performance quite a bit. It doesn't change the actual loading speeds that much, but makes the interface fully responsive during all movement and thus improves the experience of browsing the dataset. Had a few rounds of tests & improvements with Andy Sweets to get rid of some bugs, very optimistic about this implementation now.
See here: napari/napari#4905

I think it's worth using that PR when we want to test performance and it may make for better demos :)

I'd say we can close this for the time being. Let's wait for the PR to make its way into napari and for sharding to come to Zarr to improve the performance further :)
https://forum.image.sc/t/storing-large-ome-zarr-files-file-numbers-sharding-best-practices/70038

@jluethi jluethi closed this as completed Aug 30, 2022
Repository owner moved this from On Hold to Done in Fractal Project Management Aug 30, 2022
@jluethi jluethi moved this from Done to Done Archive in Fractal Project Management Oct 5, 2022
jacopo-exact added a commit that referenced this issue Nov 16, 2022
…s_for_web_client

Various updates for web client
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backlog Backlog issues we may eventually fix, but aren't a priority
Projects
None yet
Development

No branches or pull requests

2 participants