bigdataviewer / bigdataviewer-core

ImgLib2-based viewer for registered SPIM stacks and more
BSD 2-Clause "Simplified" License
33 stars 35 forks source link

Allow finer control of caches in image loaders #137

Open NicoKiaru opened 2 years ago

NicoKiaru commented 2 years ago

Adds a CacheOverrider interface and implementations of this interface in:

Adds a constructor in VolatileGlobalCellCache with a LoaderCache argument.

Together these modifications allow to get a finer control over the caching mechanism used when loading a dataset. In practice, using a BoundedSoftRefLoaderCache with a fixed number a cells instead of a SoftRefLoaderCache can lead to very significant performance improvement. Cached cells can be released: 1 - before the RAM gets full, 2 - more efficiently (and aggressively) than when SoftRefs are released by the garbage collector.

This PR maintains backward compatibility and does not modify the default behaviour (SoftRefLoaderCache).

NicoKiaru commented 2 years ago

Converted to draft because I needed to double check that changing the cache a posteriori does not bring unexpected issues (I can confirm the performance improvement, but not exactly the way it's done in the PR)

NicoKiaru commented 2 years ago

Works fine, so I'm removing the draft status

NicoKiaru commented 2 years ago

Hi @tpietzsch,

Do you think you could your opinion on this PR ? Do you think it's in good shape or is there something with the modifications which does not look nice to you ?