Add additional caching in the RootCollection and SMB classes #37451
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Optimize access to the SMB storage. The focus has been to optimize the usage of the
opendir
in the SMB storage because there were several calls to theopendir
method:opendir
method was overriding the class cache. This was a problem because theFileInfo
objects has an internal cache for the dos mode. By overriding the cache, we were forced to request again the dos mode to the external SMB server.Now we're checking the cache and prioritize that information, which should have the dos mode already cached.
FilesHome
object were being created. This was likely disturbing the caching mechanism in the dav layer, causing additional calls to the backend (at least one additional call to theopendir
method in the SMB backend)Now we're returning the same node instance when asked in order to reuse the cache mechanism.
With these changes, it's expected to have only 2 calls to the SMB's
opendir
method. These 2 calls come from the automatic scan that happen when we get the cache entry (the first one), and when we actually ask for the folder contents (the second one).Related Issue
https://github.com/owncloud/enterprise/issues/4007
Motivation and Context
How Has This Been Tested?
Manually checking the curl timings. The following results come from the same local environment using 4e04c49 (current master) as base.
The performance improvement should be noticeable for the SMB connection. Other backends should also get some benefit due to the cache in the RootCollection.php file, although not tested.
Screenshots (if appropriate):
Number of calls before this PR:
Number of class after this PR:
Types of changes
Checklist: