-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Do not generate unnecessary max preview file #17028
Conversation
Signed-off-by: Samuel CHEMLA <chemla.samuel@gmail.com>
Signed-off-by: Samuel CHEMLA <chemla.samuel@gmail.com>
This pull request provides a 9x speed improvement on my setup when uploading photos from web browser |
I am not a fan of this. The max preview is there for a reason. First of all it is often requested as well at some point (when opening in the viewer for example). But mostly because otherwise we have to load in the huge original image file every time we need to generate a different preview size. Some other things I noticed
|
As stated in #16963, I upload from the webpage. In my setup, files are on a cifs share with decent performances (but indeed, there is no cache on network storage). I measured the time to upload 20 JPEG images (8MB each). |
Hi, |
Thanks @phpbg for investigating 👍 There are some reports about the slow image preview generation around so its good to look at different approaches or possible optimizations. Like @rullzer I don't see a huge performance improvement with my development setup. I used https://www.pexels.com/photo/photography-of-person-walking-on-road-1236701/ for my benchmarks. Copied the image 50x times and uploaded it. Repeated the test three times. Start: Press open in the file picker dialog
Feel free to repeat the test and share your results 🥇 |
I had: I wonder how is your server configured ? FPM ? static vs dynamic ? My server gets completely overloaded without patch, and i think it makes much longer response times...
We should also measure getting previews of a different size after the first previews are generated, to check @rullzer remark about re-reading original image vs reading -max preview |
I run the above tests with Nginx and PHP-FPM (pm = dynamic, pm.max_children = 5).
Here the results for your configuration. I assigned two cores and 4096mb memory to my development box. Guess the box is not able to handle so much requests at the same time. |
With my camerarawpreviews app it would certainly take longer time without the max-preview image. To support external storage, the RAW file is copied to a temporary file and then read. Depending on the speed of the external storage and general IO speeds will determine how much extra time this will take per image. Maybe generating the max-preview in the background in cron would be a better idea? Or perhaps on upload? |
Are the thumbnails encrypted when encryption is on? Because in such case you probably don't want an unencrypted -max preview file... I guess in the end we should: What do you think? |
I would try that. Guess there are good reason why it's not done by default. There are hooks/events in place for upload a file. I think we could do that as app.
I think we should improve the situation in general. There are many setups around with different stacks. Some have better cpu others faster io. Not sure if there is a perfect way. Just opened a folder with around 700 images on my production instance and yes it's bad 😟 |
I know it's an old PR, but the topic is still completely unresolved. I think this PR perfectly makes sense, so only the actually required preview is generated. I don't get the argument to generate the max size preview to speed up further preview generations:
So I clearly vote for a preview-on-demand only implementation, which does not trigger any preview, as long as it is not requested by an app or viewer which uses that exact preview size. For anyone who uses the web interface to view image galleries, instead of doing this on a client, the preview generator app is mostly mandatory anyway, to get a smooth experience, which is then fine as it runs in background. Another aspect of this is huge |
Not sure, it's not exactly the same part of this topic, respectively mixes many topics and approaches together, many correct things have been mentioned without any concrete result. This PR ships a solution for a specific part of the issue, which looks good to me, and generally the IMO right approach to generate only what is specifically required in each situation, when using the web UI. The whole topic around previews is generally scattered across a large number of PRs, issues and forum threads and to me it looks like PRs that address a specific part of it are the most realistic way to enhance the situation for now. Sad that this one does not work, although I didn't understand yet why that is. |
I tested this pr a while ago and could not reproduce the performance improvements. Yep it's a bit faster without the max preview but the next time you need another preview it's necessary to open the original file again. |
That will simply depend on network speed vs hardware performance:
With a max preview, the next preview will only be faster generated, when:
While the downsides are assured to be there (in significance of course depending on hardware), the benefits are only there when those three assumptions are met. And finally, when I open the image viewer via web UI, it is okay when a single large preview is then generated on demand, or the original loaded when it is smaller. When (up)loading many images it is where the significant delay and hanging server may happen, at least on weaker machines. |
See #16963
Hi, this is a big one for me, please provide feedback and test.
The preview code probably need some refactoring, but I just focused on fixing the issue.
There are a few open TODO items, but I wanted some feedback before proceeding...