-
Notifications
You must be signed in to change notification settings - Fork 15
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
Slow when opening pictures on slow file systems (e.g., remote file systems) #363
Comments
Thanks for your interest in vimiv! Unfortunately there is currently no such option, and I don't quite see how this would be implemented unless we add a simple setting. But of course it would be nicer to actually improve the performance in general, so we don't need any workarounds. In principle the thumbnails are created in parallel, so this should not delay startup, but all files in the current (the one of the first image) directory are checked if they are images or not which could be the cause of the delay. I did some quick checks and found the performance to be pretty bad on slow file systems in general. The checking of all of the files becomes a significant part of the loading time (> 30 %) once there are around 100 images in the working directory. But even without this there are some parts that are surprisingly slow, profile attached for reference. Startup profile
If you would like to test how much of an impact the checking of all files has in your case, and are willing to hack the code, you could change the def _load_directory(self, directory: str) -> None:
"""Load supported files for new directory."""
self._dir = directory
return # Quick hack to avoid checking the files in the current directory
self._images, self._directories = self._get_content(directory)
self.loaded.emit(self._images, self._directories) In case this already improves the performance "enough" for your use-case, we could think about adding a setting for this as a workaround. Obviously this is not beautiful, but very easy to do. Finding a proper way to speed vimiv up requires more thinking, as already mentioned in #124.. |
Thank you for your detailed reply! I tried your suggestion and it reduces the startup time from 1 minute to 3 seconds for a remote directory mounted with SSHFS containing 240 pictures. The question is, what is lost when skipping this check or can it maybe be done in the background? BTW, also when closing vimiv-qt, there is a significant delay --- maybe for similar reasons? EDIT: It seems that also the delay when closing the application is gone with your function including the quick hack. |
Loading the content in the current directory:
A useful library is one of the main features for vimiv in my opinion, and is actually the reason why I started writing it in the first place. I wanted a proper "ranger-like" way to navigate my image library integrated into an image viewer with vim-like keybindings. Now this is of course not needed for the use-case "open one image and open it fast" and this issue has also came up previously, but given this sets vimiv apart I am quite resilient to disabling it. Loading the directory in the background could work, I just never felt this is necessary as I almost always run vimiv from a fast SSD and the overhead felt over-the-top compared to the possible benefits. Looking at your results I certainly have to reconsider 😆 I will take a look into this, but I can make no promises as it may be more complicated than I can think of now. |
In #451 you can see that stat() calls are quite expensive and can be reduced. From the call graph pictures you can also see that the imghdr.what() is slow on remote file systems. Maybe adding a config option to detect images purely based on file endings might be a solution, since that would remove the expensive open() from files.is_image(). I'm aware that this proposal probably causes other issues (e.g. what happens if vimiv tries to display an unsupported file; worse image detection; ...), but it would probably be a compromise I'd find acceptable. |
Is there any way to disable thumbnails generation to alleviate this issue when only one specific image is being open on a slow FS? |
When open one of many image in a directory of a slow file system (for example, remote file systems such as NFS, or SSHFS),
vimiv
takes a long time to start. I think this is because it caches many files in the directory, and not only the file to be opened. Is there a way to check if a file system is slow, and act accordingly? Many times, I only want to open a single file, and do not care about creating thumbnails for all other files in the directory.Thanks for you help!
The text was updated successfully, but these errors were encountered: