Uh oh!
There was an error while loading. Please reload this page.
Improve delay in accessing WebDAV folders on external storage - #38418
Improve delay in accessing WebDAV folders on external storage#38418luka-nextcloud wants to merge 2 commits into
Conversation
| } | ||
| $fileDetail = $response[$file]; | ||
| $file = basename($file); | ||
| $this->statCache->set($file, $fileDetail); |
There was a problem hiding this comment.
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.
@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.
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
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
f4fd659 to
daabaf4Compareluka-nextcloud
commented
May 26, 2023
@juliushaertl Please check again, thanks. |
Uh oh!
There was an error while loading. Please reload this page.
daabaf4 to
e405549CompareUh oh!
There was an error while loading. Please reload this page.
efae6c8 to
811f317Comparejuliusknorr
commented
May 29, 2023
811f317 to
a17857dCompareluka-nextcloud
commented
May 30, 2023
@juliushaertl I've updated PR & description, please check. |
juliusknorr
commented
Jun 5, 2023
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 |
luka-nextcloud
commented
Jun 7, 2023
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
f8445d7Comparejuliusknorr
commented
Jun 13, 2023
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 . '/'); |
icewind1991
commented
Jun 14, 2023
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. |
come-nc
commented
Jun 15, 2023
But the caching may help with other operations as well no? |
juliusknorr
commented
Jun 16, 2023
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. |
Alexandero89
commented
Jun 19, 2023
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. |
icewind1991
commented
Jun 22, 2023
There is also a different propfind cache already which this is duplicating |
icewind1991
commented
Jun 22, 2023
#38945 implements |
juliusknorr
commented
Jun 29, 2023
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