-
Notifications
You must be signed in to change notification settings - Fork 58
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
Enhancement: Multithreading #162
Comments
There is such a thing being tested: https://ownyourbits.com/2019/06/29/understanding-and-improving-nextcloud-previews/ |
Hi @Gatak Thank you so much for sharing the link. I've found this to be a nice and interesting PoC. I'm going to hit the author to get further details and to ask him to open an issue here at the official branch of Preview Generator app, so devs can check if his contrub is worth to be merged with the current project, which I hope it will, as the results seems quite promising. I'm currently creating the thumbs via cron job with occ preview:generate-all command, but as he spots, this creates a bunch of different-sized thumbs on a monothread basis, which is painfully slow if you have an active community uploading pics everytime, as most of us have. I'll let you know how the whole thing develops |
@jkingcis You're right. I think many many users would really benefit from this work. Especially on low-end devices such as routers, Raspberry Pi's etc. I was thinking that perhaps it would be possible to create a bash script to generate the thumbs outside of Nextcloud and then use What would be needed to create the thumbs? I In the Would NC create the DB entries automatically when running This is an extract from
|
@Gatak that would indeed be a bit hacky but it could be a bit faster. If you see my benchmarks, even using imagick with many threads per resize the bottleneck is in the PHP-db part so it speeds things up a bit but if we use the "multiprocess approach" (PR #166) then it is way faster. I think your suggestion could be even faster if it were implemented say in C but it would require more maintenance to be kept in sync with potential changes in the NC previews engine, more programming effort, and harder to distribute (since is compiled) and not that much faster. Probably not worth it IMO. |
@nachoparker Absolutely not an easy task this. I do not have much coding experience, but I'm thinking to avoid the contention with mysql/mariadb/php, that the preview files could be generated with a imagemagick bash script, and then one proceeds to updated the database with all the files afterwards. |
Said script would need to be aware of what previews already exist, also what is the configured jpeg quality and so on. Before you know it we are replicating the functionality from the NC previews engine and then we need to keep it in sync. It is a good idea, but I think we would be better off trying to improve or provide more options in the NC / previewgen code itself. |
@nachoparker I agree. Creating an external Imagemagick script would need at least some database queries to get which thumbs have been already created, which would somewhat slow the things anyway. I think your multithreading/concurrent instances proposed in #166 will bring a huge timing improvement. Hope it reaches the official branch. In my company, I did a Bash script to check if another preview generation process was still running (because it'd run via cron job) to avoid launching a second process that could create inconsistency, and then run the prev generation itself every 10 mins. Because nowadays preview generation is painfully slow, the problem gets enhanced as the server is always generating previews as users upload pictures faster than the server is able to render them (not many pics imo, maybe 20-50 per hour). |
Before my changes it was not possible to run two instances anyway (the second one detects this and doesn't run). You can have a look at how we do it in NextCloudPi. 1h every night so it doesn't affect normal usage. |
Hi has this topic made it to the dev? |
What happens if I run like 5 instances of preview:generate_all, each for a different user? |
well? is it working ? |
So, I tried this just because I was looking for a faster way to test another issue I'm having with previews and it works! I'm running (well, just trying it out now actually, no long term experience with it) This gave me an idea, which I haven't tested yet. One could write a wrapper for generate-all which identifies directories within the nextcloud directory tree that contain images and queue them, running generate-all with the path argument with some amount of concurrency. Unfortunately that would only help with initial generating of previews since the pre-generate command does not accept a path argument. I don't really recommend any of that as a "solution" to multi-threading previews, as that should probably be supported in this software somehow instead, just sharing my findings. |
Hi,
Just being using preview generator for a while. Congrats for your excellent work. I've noticed that the occ process itself only uses one vCPU at a time. Considering that the task of generating previews is quite CPU-intensive, it might be interesting to get multithreading working, so the process could be much faster.
The text was updated successfully, but these errors were encountered: