vimiv-qt icon indicating copy to clipboard operation
vimiv-qt copied to clipboard

Lazy Loading Overhaul

Open buzzingwires opened this issue 1 year ago • 19 comments

Included in this pull request are a number of changes to the way images are loaded by vimiv, with special focus on lazy loading. The code is most certainly not ready to be merged with the upstream project. Tests need to be written for it, the code generally needs to be cleaned up and the style made consistent, and any ideas that don't work well with the vision for upstream vimiv must be removed.

The rationale for these changes is primarily to accommodate the author's niche and specific use case. That is browsing sets of thousands of images, while minimizing memory usage and redundant disk IO. These images are typically sorted externally and fed in through stdin, so their order must be maintained.

The intention was to make all changes opt-in by means of configuration variables, the default values of which would maintain the original behavior of the software. These changes are already seeing use in my personal fork, so I will not be offended if they are turned down.

The following configuration variables are added to change the behavior of the software:

thumbnail.save : If set to False, thumbnails will not be cached to the drive.

thumbnail.max_ahead : Only this number of thumbnails after the current selection will be loaded. Changing the selection will modify the range of loaded thumbnails accordingly. If zero, load unlimited, as is the default.

thumbnail.max_behind : Like thumbnail.max_ahead, but for thumbnails preceding the current selection.

thumbnail.max_count : Thumbnails will not be unloaded unless the number of them exceeds this. Note, that this does not cause thumbnails to be forcibly unloaded, so this variable should probably be renamed. Anyway, set to 0 to immediately unload out of range thumbnails.

image.id_by_extension : If set to True, use the extension to assume the filetype, instead of reading with imghdr. This prevents large sets of images from being all opened when starting.

image.imghdr_fallback : If set to True and an image fails to load by a reader guessed by image.id_by_extension, try using imghdr to find an appropriate reader. In light of the pending replacement of imghdr, this should perhaps be renamed.

sort.image_order and sort.directory_order also now have a passthrough sort option, which will maintain the order that images were provided to vimiv from the command line or stdin. Will probably remove sort.directory_order, since it's unlikely to be very useful. And I don't think it works properly.

buzzingwires avatar Jul 04 '23 09:07 buzzingwires