-
Notifications
You must be signed in to change notification settings - Fork 2.1k
[objectstorage] Cache stat while fetching objectstore object metadata #31958
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #31958 +/- ##
============================================
+ Coverage 64.06% 64.08% +0.01%
- Complexity 18306 18313 +7
============================================
Files 1192 1192
Lines 69135 69163 +28
Branches 1277 1277
============================================
+ Hits 44292 44320 +28
Misses 24471 24471
Partials 372 372
Continue to review full report at Codecov.
|
f057ac6 to
df769f0
Compare
|
this is likely not enough, you also need logic to invalidate the entries whenever other file operations are called. remember that many high level file operations might involve more than a single low level FS operation here's an example stat cache that was added for external storage: https://github.com/owncloud/core/blob/v10.0.8/lib/private/Files/Storage/DAV.php#L78 and https://github.com/owncloud/core/blob/v10.0.8/lib/private/Files/Storage/CacheableFlysystem.php#L32 |
|
@PVince81 the stat cache gets set and invalidated in the same function - getMetadata. There is no other place in code to set the cache - so cache will leave only for duration of that function |
|
so are we assuming that all file operations like $objectStore->unlink() and $objectStore->rename() will call |
|
@PVince81 so your suggestion is to have a look how stat cache is realized in other implementations? |
that or think about stat cache invalidation for every file operation that go through the storage |
62721aa to
3c6186a
Compare
|
@PVince81 @DeepDiver1975 @butonic @tomneedham all tests passing - I also updated the PR description with the context. I made a stat caching similar to the one for dav. |
|
We are gluing things to different places, where the right place would be the filecache. That #28166 requires touching core all over the place is caused by other places bypassing the filecache. We can patch around that, but the problem does not go away that way. Fix the places the bypass the filecache first. I don't have the energy to look into filecache related PRs, sorry. |
|
@butonic this does not touch filecache at all. It is a layer below, storage stat cache - please look a description. It is used ONLY when using storage calls, the same as for filesystem, no filecache involved here. |
|
@butonic and to mention further, this PR is only to make objectstore work with similar performance as filesystem, no filecache "caching" is here in place, I just cache results of the filesystem calls wrapped by objectstorage |
| $stat = $cacheEntry->getData(); | ||
| if ($cacheEntry->getMimeType() != 'httpd/unix-directory') { | ||
| // Only set stat cache for objects | ||
| $this->objectStatCache->set($path, $stat); |
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.
@DeepDiver1975 @butonic note that I only cache stat calls for objects metadata, not a file-tree (filecache trees)
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.
additionally, file need to exists to be cached (I don't cache e.g. false)
| return null; | ||
| } | ||
|
|
||
| private function rmObjects($path) { |
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.
why has this method been moved down ? this makes it difficult to review as now we can't see whether you made change to it
if you want to reformat a file please do so in a separate commit
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.
You can also use diff -> split. But I can do it in separate commit, should I?
|
I agree with @mrow4a that a stat cache on the storage class is useful to avoid repeated real-storage access as higher level OC code tends to repeat operations (like file_exists, etc). We already use this approach for other storages like DAV, Dropbox, etc. |
DeepDiver1975
left a comment
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.
I'm fine in merging this to master and get an understanding how this works.
We shall rebase and rerun the tests ....
|
@DeepDiver1975 reviewed again, and rebased |
|
@DeepDiver1975 @PVince81 any decision on this? |
butonic
left a comment
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.
I like the conservative approach. It at least caches stuff for objectstorage.
Co-Authored-By: DeepDiver1975 <[email protected]>
8d4b57e to
544070c
Compare
CappedMemoryCache is used now as requested .... moving on .....
544070c to
e436abb
Compare
|
@DeepDiver1975 @butonic I will keep an eye on smashbox with objectostrage tests for this change. |
Problem Description
The same logic for calling stat in objectstore compared to filesystem implementation is inefficient.
This is due to the fact that objectstore does not implement any filesystem functionality which stores information about file, and thus needs to resort to using filecache.
Solution
This PR implements stat cache similar to filesystem to temporarly cache results between calls to filesystem. Each request to modify filesystem clears the stat cache. Additionaly, we store only cache for objects, not for file tree (directories).
How did I test
I did:
Master:

Obj Stat:

This PR thus cuts 20% of read queries required for objectstore.
Related PRs
Due to the fact there is no decision on introducing "cache of filecache", this PR is just fixing the code logic.
@PVince81 @DeepDiver1975 @butonic