Skip to content

Optimize PUT - don't fetch and update checksum again, reunse the one from part file#27532

Merged
PVince81 merged 1 commit into
masterfrom
optimize_put_4
Jul 5, 2017
Merged

Optimize PUT - don't fetch and update checksum again, reunse the one from part file#27532
PVince81 merged 1 commit into
masterfrom
optimize_put_4

Conversation

@mrow4a

@mrow4a mrow4a commented Mar 29, 2017

Copy link
Copy Markdown
Contributor

Back to the roots, but smarter https://github.com/owncloud/core/blob/stable8.2/lib/private/connector/sabre/file.php#L212

  • Unit tests

-3 SELECT, -1 UPDATE (!)
selection_116
selection_117

@mrow4a mrow4a added this to the 10.0 milestone Mar 29, 2017
@mention-bot

Copy link
Copy Markdown

@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.

@mrow4a

mrow4a commented Mar 29, 2017

Copy link
Copy Markdown
Contributor Author

@DeepDiver1975 Any reasoning behind this ?
selection_118

I cannot scratch my head for a use case, and I adjusted test to test the feature

@mrow4a

mrow4a commented Mar 30, 2017

Copy link
Copy Markdown
Contributor Author

Ready for review, needs more integration tests for checksums and PUT in general, smashbox it maybe?

Comment thread apps/dav/lib/Connector/Sabre/File.php Outdated
}

if ($view) {
$this->emitPostHooks($exists);

Copy link
Copy Markdown
Member

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.

@mrow4a mrow4a Mar 31, 2017

Copy link
Copy Markdown
Contributor Author

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

Comment thread lib/private/Files/Stream/Checksum.php Outdated
}

/**
* Remove .path extension from a file path

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"remove .path extension" 👀

Copy link
Copy Markdown
Contributor Author

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

public static function isPartialFile($file) {

public function stripPartialFileExtension($path) {

Currently it is really spread over the code, which is bad. @DeepDiver1975 @jvillafanez What do you think?

Copy link
Copy Markdown
Member

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.

@jvillafanez

Copy link
Copy Markdown
Member

Has this been tested with big file chunking (old and / or new)? Are external storages included for the checksums?

@mrow4a

mrow4a commented Mar 31, 2017

Copy link
Copy Markdown
Contributor Author

I think new and old chunking code uses different functions, e.g. old chunking uses

return $this->createFileChunked($data);

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?

@SergioBertolinSG

Copy link
Copy Markdown
Contributor

@mrow4a

mrow4a commented Mar 31, 2017

Copy link
Copy Markdown
Contributor Author

@SergioBertolinSG and external?

@SergioBertolinSG

Copy link
Copy Markdown
Contributor

@SergioBertolinSG and external?

Only local set up as external storage.

@mrow4a

mrow4a commented Mar 31, 2017

Copy link
Copy Markdown
Contributor Author

@DeepDiver1975 Needs to review it carefully I think when he finds the time. @jvillafanez What about creating "PartialFilesUtils" class for the issues mentioned above?

@jvillafanez

Copy link
Copy Markdown
Member

"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.

@mrow4a

mrow4a commented Apr 13, 2017

Copy link
Copy Markdown
Contributor Author

@DeepDiver1975 Is this scope of 10.0 to fix checksuming related performance?

@PVince81 PVince81 modified the milestones: 10.0.1, 10.0 Apr 26, 2017
@DeepDiver1975 DeepDiver1975 modified the milestones: 10.0.1, 10.1 May 17, 2017
Comment thread lib/private/Files/Cache/Scanner.php Outdated

Copy link
Copy Markdown
Contributor Author

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

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
Contributor Author

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

$storage->getUpdater()->update($internalPath);
, and
$data['fileid'] = $this->addToCache($file, $newData, $fileId);
$newData has following contents
selection_289

Next time it gets there is in

if ($this->fileView->touch($this->path, $request->server['HTTP_X_OC_MTIME'])) {
and it has following content
selection_290

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DeepDiver1975 any thoughts?

Copy link
Copy Markdown
Contributor Author

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

$newData = $data;
, and second goes through
if (empty($cacheData['etag'])) {

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Contributor

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

Comment thread lib/private/Files/Stream/Checksum.php Outdated

Copy link
Copy Markdown
Contributor Author

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)

Comment thread lib/private/Files/Cache/Scanner.php Outdated

Copy link
Copy Markdown
Member

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

@PVince81

Copy link
Copy Markdown
Contributor

There should be integration tests already about resetting the checksum when an external storage file change. Strange that #27532 (comment) did not trigger it.

@mrow4a

mrow4a commented Jun 21, 2017

Copy link
Copy Markdown
Contributor Author

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.

@PVince81

PVince81 commented Jul 4, 2017

Copy link
Copy Markdown
Contributor

Rebased. master contains the integration tests I requested...

@PVince81 PVince81 merged commit be92925 into master Jul 5, 2017
@PVince81 PVince81 deleted the optimize_put_4 branch July 5, 2017 14:56
@DeepDiver1975 DeepDiver1975 modified the milestones: 10.1, development Oct 10, 2017
@phil-davis

Copy link
Copy Markdown
Contributor

Note: this has not been backported to stable10
I happened to notice because of conflicts raised in backporting #30580 - that PR changed some indent of lines in Scanner.php e.g.

	// Reset the checksum if the data has changed
	$newData['checksum'] = '';

is taken out in master by this PR. But remains in stable10

Just noting here in case someone in future does a backport of this PR. You will get some conflict there.

@mrow4a

mrow4a commented May 6, 2018

Copy link
Copy Markdown
Contributor Author

@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?

@mrow4a mrow4a changed the title Optimize PUT - dont fetch and update checksum again, reunse the one f… Optimize PUT - don't fetch and update checksum again, reunse the one from part file May 6, 2018
@mrow4a

mrow4a commented May 6, 2018

Copy link
Copy Markdown
Contributor Author

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.

@mrow4a

mrow4a commented May 6, 2018

Copy link
Copy Markdown
Contributor Author

Hmm, it does not, since 523cd34 already solved it but detecting "real file change"

@mrow4a

mrow4a commented May 6, 2018

Copy link
Copy Markdown
Contributor Author

@PVince81 should I create backport PR and check everything again? Probably needs #31082 this first to resolve the conflict

@lock

lock Bot commented Jul 31, 2019

Copy link
Copy Markdown

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.

@lock lock Bot locked as resolved and limited conversation to collaborators Jul 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants