-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Optimize PUT - don't fetch and update checksum again, reunse the one from part file #27532
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
|
@mrow4a, thanks for your PR! By analyzing the history of the files in this pull request, we identified @DeepDiver1975, @PVince81 and @IljaN to be potential reviewers. |
|
@DeepDiver1975 Any reasoning behind this ? I cannot scratch my head for a use case, and I adjusted test to test the feature |
|
Ready for review, needs more integration tests for checksums and PUT in general, smashbox it maybe? |
| } | ||
|
|
||
| if ($view) { | ||
| $this->emitPostHooks($exists); |
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.
There is $this->fileView->touch below... This might change the behavior if the hooks are expected to run after that touch.
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.
In previous versions https://github.com/owncloud/core/blob/stable8.2/lib/private/connector/sabre/file.php#L202 it was like in the link above, not sure what reasoning was behind moving it there @DeepDiver1975
| } | ||
|
|
||
| /** | ||
| * Remove .path extension from a file 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.
"remove .path extension" 👀
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.
Honestly, this is copy-paste from another function. We might think about creating separate class serving each layer in the code for partial files
core/lib/private/Files/Cache/Scanner.php
Line 461 in f10d105
| public static function isPartialFile($file) { |
core/lib/private/Encryption/Util.php
Line 252 in e4e9864
| public function stripPartialFileExtension($path) { |
Currently it is really spread over the code, which is bad. @DeepDiver1975 @jvillafanez What do you think?
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 only wanted to change the wording: it should be ".part" not ".path" 😆
There should be only a function to handle this, maybe a class for all the string-based path manipulation, but this is currently out of scope.
|
Has this been tested with big file chunking (old and / or new)? Are external storages included for the checksums? |
|
I think new and old chunking code uses different functions, e.g. old chunking uses core/apps/dav/lib/Connector/Sabre/File.php Line 106 in 0496a82
External storages I did not test manualy, but it should not be a case, since it is lower layer (or at least should be and upper layer should not be aware of lower). Will tests it. @SergioBertolinSG is integration test for that, as @jvillafanez points out? |
|
There are tests using local storage https://github.com/owncloud/core/blob/master/tests/integration/features/checksums.feature#L135 |
|
@SergioBertolinSG and external? |
Only local set up as external storage. |
|
@DeepDiver1975 Needs to review it carefully I think when he finds the time. @jvillafanez What about creating "PartialFilesUtils" class for the issues mentioned above? |
|
"PartialFilesUtils" suggests something only for dealing with part files, but I'd like to have something more generic. String-based path manipulations, which could include part file handling; without any FS access nor VFS access. |
|
@DeepDiver1975 Is this scope of 10.0 to fix checksuming related performance? |
lib/private/Files/Cache/Scanner.php
Outdated
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.
Seems to me some kind of workaround for some purpose, probably for what I have erased to work
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.
from my understanding this is necessary if the file was changed on disk which is detected by the scanner.
in this case the checksum has to be removed
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 just went with debugger, first time the PUT gets there is with
core/apps/dav/lib/Connector/Sabre/File.php
Line 204 in 186595c
| $storage->getUpdater()->update($internalPath); |
core/lib/private/Files/Cache/Scanner.php
Line 204 in 186595c
| $data['fileid'] = $this->addToCache($file, $newData, $fileId); |
Next time it gets there is in
core/apps/dav/lib/Connector/Sabre/File.php
Line 215 in 186595c
| if ($this->fileView->touch($this->path, $request->server['HTTP_X_OC_MTIME'])) { |
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 any thoughts?
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 cannot think where cleaning of checksum might be usefull, first call goes through
core/lib/private/Files/Cache/Scanner.php
Line 200 in 186595c
| $newData = $data; |
core/lib/private/Files/Cache/Scanner.php
Line 180 in 186595c
| if (empty($cacheData['etag'])) { |
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.
Can you retest with an external storage ? Then change a file directly on external storage and run occ files:scan. In this case, the checksum in oc_filecache must disappear since the file changed and we didn't recompute it yet.
If this still works correctly then maybe there is yet another code paths that achieves the same result... strange
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.
also beware, when testing uploads, always test these:
- old endpoint, new file upload
- old endpoint, upload + overwrite
- old endpoint, new file chunked upload
- old endpoint, chunked upload + overwrite
- repeat above with new endpoint
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.
please make sure these are covered by integration tests + checksums to make sure this PR doesn't break anything
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.
It will "cache" checksum for the original file (for which .part file is created)
lib/private/Files/Cache/Scanner.php
Outdated
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.
from my understanding this is necessary if the file was changed on disk which is detected by the scanner.
in this case the checksum has to be removed
|
There should be integration tests already about resetting the checksum when an external storage file change. Strange that #27532 (comment) did not trigger it. |
|
For all Optimize PUT - this, #28021 and #28003 (comment) - I need proper smashbox and integration tests, and check if they verify what I do here. I will finish working on tests and verifying. |
|
Rebased. master contains the integration tests I requested... |
|
Note: this has not been backported to is taken out in Just noting here in case someone in future does a backport of this PR. You will get some conflict there. |
|
@phil-davis @DeepDiver1975 @PVince81 I can see, in stable10 this is still not there. We still do there unnecessarily UPDATE - the checksumming information is not being reused from part file info, and requires to be additionally queried and updated. Should I have a look at the conflict, or we kill this change? |
|
Hmm, seems this to work would need to wait for #28003 due to removed conflic line - the mentioned PR removes the scan which cleared the checksum. |
|
Hmm, it does not, since 523cd34 already solved it but detecting "real file change" |
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |

Back to the roots, but smarter https://github.com/owncloud/core/blob/stable8.2/lib/private/connector/sabre/file.php#L212
-3 SELECT, -1 UPDATE (!)

