-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Limit number of concurrent preview generations #18210
Conversation
I installed my Nextcloud instance inside a linux container with 3 cores and 2GB RAM allocated. The host has 4 cores @ 1.6GHz and 8GB RAM in total. Without proper restrictions on how many preview generations can happen at a time, a scroll load of 50 pictures eats up all 2GB memory and causes the kernel OOM killer to kick in. Sometimes the MySQL process is also killed, rendering the website being out of service for a while. After applying limits on concurrent preview generations ( |
@kesselb why wasn't this PR considered for Nextcloud 18? |
No one had time to look into I guess. I like the idea in general. Code style is a bit off (we use camelCase here). Probably we could deduplicate the code a bit. Needs some testing of course. Some feedback and questions:
I think it's a good way using a lock. Most of these "improve preview generation" pull requests had in common that they improve the situation for one use case (I remember a pull request where the author announce 200% performance boost. Some tests later it boils down only for nfs based filesystem). As always: Feel free to patch your instance and report back your experiences. |
@kesselb Maybe I am off here. But cannot this be mostly solved by limited how many concurrent previews are opened in the web UI? Like lazy loading and max 2-3 concurrent previews at a time? Of course that will not fix having many clients connecting at the same time. |
@dbw9580 please rebase |
18eeb79
to
02256c8
Compare
@skjnldsv done. Also deduplicated the code. |
Any update here? |
Hi devs, is there anything I can do to help get this PR merged? |
Not much! :) |
I'm not sure how that could work with clustered envs, like if there is more than one application server. I assume it wouldn't lock across servers but always be scoped to each server, right? |
True. I don't think semaphores can work across OS boundaries.
2021年1月7日 22:22, 22:22,在 Christoph Wurst <notifications@github.com> 已写:
I'm not sure how that could work with clustered envs, like if there is
more than one application server. I assume it wouldn't lock across
servers but always be scoped to each server, right?
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Restarted drone |
Seems like the unit tests are not ok with this |
https://github.com/nextcloud/server/actions/runs/3387563288/jobs/5628546406 I see the error is a network connection issue. How is this related to my change? |
@dbw9580 it is not this test that is the problem. The nodb drone test is the problem which runs in a timeout. See e.g. https://drone.nextcloud.com/nextcloud/server/25183/9/4 If you have any idea how to fix that, help would be really appreciated! :) |
I see the nodb test is stuck at 61%, how can I find out exactly which test is running into a problem? |
Seems like it hangs at |
BTW, @dbw9580 can you please fix DCO? Then we can merge this if the tests should run through :) |
@dbw9580 so the tests finally pass now. Please fix DCO and then I am merging this. Thank you! :) |
Signed-off-by: Bowen Ding <dbw9580@live.com> Signed-off-by: szaimen <szaimen@e.mail.de>
@szaimen rebased and signed off the commit, PTAL. |
Thank you very much! The tests pass now and everything looks good! Merging! :) |
Thanks for your first pull request and welcome to the community! Feel free to keep them coming! If you are looking for issues to tackle then have a look at this selection: https://github.com/nextcloud/server/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22 |
@szaimen thank you for the review and all the efforts for making the merge happen! looking forward to seeing this in the next release! |
@dbw9580 thanks for your incredible patience with this! It took a long time, but I'm also super happy it got in! |
Fixes #15075
I added two semaphores to limit concurrent access to CPU resources. One is to guard the CPU-intensive calls to
GeneratorHelper::getThumbnail
and several image manipulation operations inGenerator::generatePreview
. The other is aroundPreviewManager::getPreview
.The second semaphore is necessary because without it the responses see a significant delay in delivery. This is the waterfall graph of a page load of 30 pictures, without the second semaphore guarding
![Screenshot_20191204_180403](https://user-images.githubusercontent.com/6999708/70141889-f3f3b600-16d2-11ea-9df2-eea08a27a151.png)
PreviewManager::getPreview
, andpreview_concurrent_new
set to4
:You can see most thumbnails are loaded within the last 6 seconds.
This is how it looks with
![Screenshot_20191204_185025](https://user-images.githubusercontent.com/6999708/70141918-04a42c00-16d3-11ea-9751-9f34e1ee00eb.png)
preview_concurrent_new
set to4
, andpreview_concurrent_all
set to8
:The loading process is much more gradual and smoother.