-
-
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
Improve delay in accessing WebDAV folders on external storage #38418
Conversation
lib/private/Files/Storage/DAV.php
Outdated
$file = basename($file); | ||
$this->statCache->set($file, $fileDetail); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can use a separate cache like $this->propfindCache
for that to not mix up with existing behavior of the statCache.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@juliushaertl I don't think we really need a separate cache since function profind also uses stateCache to cache the profind response.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes though it represents just the existance of a file as a boolean and I think it would be wise not to mix different value types here and rather have a clean separation.
It seems that the usage of the cache actualy got lost with your recent changes
f4fd659
to
daabaf4
Compare
@juliushaertl Please check again, thanks. |
daabaf4
to
e405549
Compare
efae6c8
to
811f317
Compare
811f317
to
a17857d
Compare
@juliushaertl I've updated PR & description, please check. |
Can you double check that? When I was testing it the propfind was still duplicate as the second one didn't read the cached response from anywhere. I think it would make sense to reuse the internal |
You are right, I updated the screenshot again.
As I know, we have to use $this->client->propFind() since the target item (file, folder) is an external dir. The internal propFind is only for internal item (file,folder) |
…en dir Signed-off-by: Luka Trovic <luka@nextcloud.com>
a17857d
to
f8445d7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and works
I've pushed a small fixup commit to address an encoding issue with files with spaces, but otherwise this seemed good. Note that I'll revoke my initial question for reusing the first propfind as i think this one is intentional only done on the root without children (depth=0) as it would also get requested when listing the parent folder of the external storage mount. In this case it might be wise to only request relevant information. In case we want to optimize that this could easily be done through the following patchdiff --git a/lib/private/Files/Storage/DAV.php b/lib/private/Files/Storage/DAV.php
index 267f32a0e5b..cf031ac8c00 100644
--- a/lib/private/Files/Storage/DAV.php
+++ b/lib/private/Files/Storage/DAV.php
@@ -314,9 +314,11 @@ class DAV extends Common {
'{DAV:}getetag',
'{DAV:}quota-available-bytes',
]
- );
+ , 1);
$this->statCache->set($path, $response);
- $this->propfindCache->set($path, $response);
+ foreach ($response as $file => $responseData) {
+ $this->propfindCache->set($file, $responseData);
+ }
} catch (ClientHttpException $e) {
if ($e->getHttpStatus() === 404 || $e->getHttpStatus() === 405) {
$this->statCache->clear($path . '/'); |
I'm a bit hesitant (but not fully against) adding extra caching layers. The issue shown in the OP should also be solvable by implementing a more optimized version of The default implementation that is currently inherited is doing the "stat every file in the folder" that seems to be causing the issue. Changing it to "load the folder once and the metadata for each item" should give the same speedup in that case. |
But the caching may help with other operations as well no? |
I think the caching here makes sense for all cases here also if it is not just about iterating over the directory content. It especially helps as the previous code called a propfind on any call that would obtain file metadata like the getPermission which is likely to be called in a few other places, so I think caching in an ArrayCache for the scope of the current request is still the most sane approach here. |
Don´t know if its because of your commits, but i was testing your PR and checked the logs. Should be: "https://www.mycloud.com/remote.php/webdav/Backups/Android/Download/DCIM/OpenCamera/IMG_20210313_100632.jpg" So "$request->getAbsoluteUrl()" is returning something strange. |
There is also a different propfind cache already which this is duplicating |
#38945 implements |
Let's close this then as #38945 was merged |
Summary
Issue: loading time while open an external directory increases with the number of children (files, folders).
Root cause: profind function has been called for each child to fetch metadata/permissions and it seem unneccessary.
Update:
Before: calling of profind function for each child increases loading time; propfind duplicate call for parent dir
After: calling profind function reduced since profind response has been cached while calling opendir; no duplicate propfind call
TODO
Checklist