Skip to content
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

Work directly on the storage when uploading over webdav #12006

Merged
merged 6 commits into from
Apr 15, 2015

Conversation

icewind1991
Copy link
Contributor

Not going trough the entire filesystem stack for the part files during uploading saves a good amount of work and database queries.

In my local test instance this saves 24 queries for a regular upload and 89 queries when uploading to a shared folder.

cc @DeepDiver1975 @PVince81

@PVince81
Copy link
Contributor

PVince81 commented Nov 6, 2014

Wow, sounds promising 😄

@icewind1991
Copy link
Contributor Author

Hmm, thinking about it this currently bypasses encryption, either need to add some special case for it (yuk) or finally refactor encryption as a storage wrapper

@DeepDiver1975
Copy link
Member

 Test_OC_Connector_Sabre_File.testSimplePutFails
 Stacktrace

Test_OC_Connector_Sabre_File::testSimplePutFails
Failed asserting that exception of type "PHPUnit_Framework_Error_Warning" matches expected exception "\Sabre\DAV\Exception". Message was: "stream_copy_to_stream() expects parameter 1 to be resource, string given".

 Test_OC_Connector_Sabre_File.testSimplePutFailsOnRename
 Stacktrace

Test_OC_Connector_Sabre_File::testSimplePutFailsOnRename
Failed asserting that exception of type "PHPUnit_Framework_Error_Warning" matches expected exception "\Sabre\DAV\Exception". Message was: "stream_copy_to_stream() expects parameter 1 to be resource, string given".

 Test_OC_Connector_Sabre_File.testUploadAbort
 Stacktrace

Test_OC_Connector_Sabre_File::testUploadAbort
Failed asserting that exception of type "PHPUnit_Framework_Error_Warning" matches expected exception "\Sabre\DAV\Exception\BadRequest". Message was: "stream_copy_to_stream() expects parameter 1 to be resource, string given".

 Test_Encryption_Webdav.testWebdavPUT
 Stacktrace

Test_Encryption_Webdav::testWebdavPUT
Failed asserting that false is true.

/var/jenkins/workspace/pull-request-analyser-ng-simple@5/label/vm-slave-02/apps/files_encryption/tests/webdav.php:140

@DeepDiver1975
Copy link
Member

Hmm, thinking about it this currently bypasses encryption, either need to add some special case for it (yuk) or finally refactor encryption as a storage wrapper

I'd vote against a special case - what would be the effort to implement encryption as a storage wrapper?
I assume we can remove much more special cases as of today in the code - right?
And further more having a look at https://github.com/owncloud/core/pull/12086/files I assume we can even get a performance gain.

@schiesbn what's your opinion on the encryption storage wrapper?

@karlitschek @craigpg we should definitly invest some time to follow this path as this has a direct impact on the sync performance and opens up a path to solve chunked upload (in general and for external storage maybe - see #4997 (comment))

@PVince81
Copy link
Contributor

Note: moving encryption to a storage wrapper is likely to break a lot of stuff, as we need to make sure that all the numerous places that relied on hooks still works with the storage wrapper. This will need some research. @schiesbn what do you think ?

We've struggled at lot to make encryption stable and avoid lots of bugs in special situations, so need to make sure these will still be there after the move. If the unit tests coverage we have now for encryption is broad enough, then it might help ensure this.

@PVince81
Copy link
Contributor

@icewind1991 @schiesbn maybe raise a ticket to do the necessary research, but I feel like this is out of scope for OC8.

@DeepDiver1975
Copy link
Member

@icewind1991 @schiesbn maybe raise a ticket to do the necessary research, but I feel like this is out of scope for OC8.

increasing performance (including chunked upload performance and related issue in the area of the desktop client) are a goal for OC8 - this approach here looks really promissing and - as far as I can tell - is the basis for improving chunked upload - see #4997 (comment)

But @PVince81 is right - this is a critical decision regarding encryption and we need @schiesbn and @icewind1991 collaborating on this

@schiessle
Copy link
Contributor

I didn't had a detailed look at the storage wrapper yet. As far as I understand it it would replace the proxies. I think it depends how large the changes to the encryption code are. I don't want to risk any instability if it isn't absolutely necessary. Failures in encryption often results in data lose so I don't want to throw out code which matured over the last two releases airy.

I'm also not sure if it is possible to write the chunks directly to the file. This would mean that the chunks needs to be encrypted on the fly and placed at the right spot. But encrypted files have a different size which is not linear across the file. So the uploaded chunks would need to match the chunk size we need for encryption or need to be a multiple of it.

All probably doable, but I'm skeptical that we can do it for OC8 with the current time frame and the other stuff we have on the table.

@DeepDiver1975 DeepDiver1975 mentioned this pull request Dec 8, 2014
22 tasks
@DeepDiver1975 DeepDiver1975 added this to the 8.1-next milestone Dec 22, 2014
@DeepDiver1975
Copy link
Member

Requires adoption of encryption -> OC8.1

@jknockaert
Copy link
Contributor

@schiesbn I think that the code I developed for #12909 has support for writing chunks to existing encrypted streams. The stream_write I wrote can definitely handle that; stream_open would have to be updated. Not sure how it would fit in with the storage wrapper suggested here.

@LukasReschke LukasReschke changed the title Work directly on the storage when uploading over webdav [WIP] Work directly on the storage when uploading over webdav Feb 24, 2015
@DeepDiver1975
Copy link
Member

@icewind1991 @schiesbn rebased ... let's see

@DeepDiver1975
Copy link
Member

@icewind1991 4 failung unit tests:

There were 4 errors:

1) Test\Connector\Sabre\File::testSimplePutFails
stream_copy_to_stream() expects parameter 1 to be resource, string given

/home/deepdiver/Development/ownCloud/core-autotest/lib/private/connector/sabre/file.php:124
/home/deepdiver/Development/ownCloud/core-autotest/tests/lib/connector/sabre/file.php:34

2) Test\Connector\Sabre\File::testPutSingleFileShare
fopen(/dev/shm/data-autotest/): failed to open stream: Is a directory

/home/deepdiver/Development/ownCloud/core-autotest/lib/private/files/storage/local.php:256
/home/deepdiver/Development/ownCloud/core-autotest/lib/private/files/storage/wrapper/wrapper.php:284
/home/deepdiver/Development/ownCloud/core-autotest/lib/private/files/storage/wrapper/wrapper.php:284
/home/deepdiver/Development/ownCloud/core-autotest/lib/private/files/storage/wrapper/wrapper.php:284
/home/deepdiver/Development/ownCloud/core-autotest/lib/private/files/storage/wrapper/wrapper.php:284
/home/deepdiver/Development/ownCloud/core-autotest/lib/private/files/storage/wrapper/wrapper.php:284
/home/deepdiver/Development/ownCloud/core-autotest/lib/private/connector/sabre/file.php:117
/home/deepdiver/Development/ownCloud/core-autotest/tests/lib/connector/sabre/file.php:59

3) Test\Connector\Sabre\File::testSimplePutFailsOnRename
stream_copy_to_stream() expects parameter 1 to be resource, string given

/home/deepdiver/Development/ownCloud/core-autotest/lib/private/connector/sabre/file.php:124
/home/deepdiver/Development/ownCloud/core-autotest/tests/lib/connector/sabre/file.php:94

4) Test\Connector\Sabre\File::testUploadAbort
stream_copy_to_stream() expects parameter 1 to be resource, string given

/home/deepdiver/Development/ownCloud/core-autotest/lib/private/connector/sabre/file.php:124
/home/deepdiver/Development/ownCloud/core-autotest/tests/lib/connector/sabre/file.php:171

@icewind1991
Copy link
Contributor Author

Jenkins: #15514

@karlitschek
Copy link
Contributor

This would be super sweet to get in for 8.1 :-)

@MorrisJobke
Copy link
Contributor

@th3fallen @schiesbn @DeepDiver1975 So this now works with encryption 2.0?

@MorrisJobke
Copy link
Contributor

@icewind1991 Is this still WIP? Otherwise change the title and add the correct label ;)

@DeepDiver1975 DeepDiver1975 changed the title [WIP] Work directly on the storage when uploading over webdav Work directly on the storage when uploading over webdav Apr 9, 2015
@DeepDiver1975
Copy link
Member

@th3fallen @schiesbn @DeepDiver1975 So this now works with encryption 2.0?

yes

@PVince81
Copy link
Contributor

Let me know when you're done so I can retest and rereview. Thanks.

@icewind1991
Copy link
Contributor Author

Should be done given jenkins isn't sick today

@PVince81
Copy link
Contributor

@icewind1991 give him his pills

@@ -71,7 +71,7 @@ class File extends Node implements IFile {
* different object on a subsequent GET you are strongly recommended to not
* return an ETag, and just return null.
*
* @param resource $data
* @param resource|string $data
Copy link
Contributor

Choose a reason for hiding this comment

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

you forgot to remove the comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@PVince81
Copy link
Contributor

Uploads with cadaver, pyocclient test suite and sync client upload worked.
Note: pyocclient test suite fails due to encryption bugs, will rerun later on master once all encryption PRs are merged.

👍

@scrutinizer-notifier
Copy link

A new inspection was created.

@icewind1991
Copy link
Contributor Author

@MorrisJobke @DeepDiver1975 please review

@ghost
Copy link

ghost commented Apr 14, 2015

Refer to this link for build results (access rights to CI server needed):
https://ci.owncloud.org//job/pull-request-analyser-ng-simple/11514/
🚀 Test PASSed.🚀
chuck

@MorrisJobke
Copy link
Contributor

👍

MorrisJobke added a commit that referenced this pull request Apr 15, 2015
Work directly on the storage when uploading over webdav
@MorrisJobke MorrisJobke merged commit e33e5b4 into master Apr 15, 2015
@MorrisJobke MorrisJobke deleted the dav-put-storage branch April 15, 2015 01:08
@PVince81
Copy link
Contributor

Raised #15647 to do the same in chunking mode.

This PR only affects files uploaded without chunking.

@PVince81
Copy link
Contributor

Regression: folder size propagation doesn't happen any more: #18006

@PVince81
Copy link
Contributor

This this change improve performance significantly ?

@DeepDiver1975
Copy link
Member

In my local test instance this saves 24 queries for a regular upload and 89 queries when uploading to a shared folder.

^ should make a difference - afaik we had a blackfire graph ...

@PVince81
Copy link
Contributor

PVince81 commented Aug 3, 2015

Was the benchmark done before or after fixing the regressions ?
I'm pretty sure that if we fix the last regression (correctFolder #18006) it will increase the number of SQL queries again.

Maybe the correctFolder logic should be done asynchronously (and debounced) eventually.

@lock lock bot locked as resolved and limited conversation to collaborators Aug 11, 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.

8 participants