You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I discovered a issue with sharing in combination with encryption. If you share a folder containing 6 files with 4 users the share operation will take 24 seconds and runs 2500 queries !!!!
The problem seems to be that every time we write a file- or share-key the cache propagator propagates the changes to all parents although the cache updater already calls the propagator for each parent.
although the cache updater already calls the propagator for each parent.
That's not the case, there are 2 propagation steps, correcting folder sizes and propagating mtimes/etags, they are done separate because they have different requirements
The problem is that the encryption code makes 48 filessystem calls with an average folder depth of 8.
Since there is no knowledge in the filesystem layer about how things are grouped the only way to handle that is to do 48 * 8 * 2 = 786 cache updates (the remaining queries are cache reads from what I can tell)
The problem is that the encryption code makes 48 filessystem calls with an average folder depth of 8.
We still need to find a solution how to improve this. On the encryption level there is not much we can do about it. We need to write a file-key for each file and a share key for each user and create the folder before we can create the files. I don't see how this can be improved on the encryption side, we perform the absolute minimum of operations in order to update the keys.
I also don't really understand how the 786 cache updated leads to 2578 queries at the end. According to the graph they all come from OC\File\Cache\Cache::update, something which shouldn't be triggered by a read operation
That's not the case, there are 2 propagation steps, correcting folder sizes and propagating mtimes/etags, they are done separate because they have different requirements
Just thinking: Couldn't this for example be done in a way that we first collect the data for mtime/etag and folder size in two steps but then perform the actual db update in one step once we have collected all the new values?
According to the graph they all come from OC\File\Cache\Cache::update
The graph is lying, if you click on executeAudited you see that it has 6 callers, the graph only shows callers which are significant in time and since updates are way more expensive (~87% for 786 updates, and ~5% for the remaining ~1800 reads)
We still need to find a solution how to improve this. On the encryption level there is not much we can do about it. We need to write a file-key for each file and a share key for each user and create the folder before we can create the files. I don't see how this can be improved on the encryption side, we perform the absolute minimum of operations in order to update the keys.
Currently the only way to improve it is to bypass the view, work directly on the storage and call the updater yourself when you're done doing all operations. Since the crypt code knows how it will be using the filesystem it doesn't need to keep the cache uptodate during every step, just needs to make sure it's consistent at the end.
I've been thinking about adding some sort of "operation grouping" api to the filesystem to make things like this easier, something like
$view->grouped(function($view){
$view->doSomething();
$view->doMore();
});
Where the cache updates will only happen once the entire group is done
The graph is lying, if you click on executeAudited you see that it has 6 callers, the graph only shows callers which are significant in time and since updates are way more expensive (~87% for 786 updates, and ~5% for the remaining ~1800 reads)
So it seems that we still need to optimize the ~95%, even if it is "only" 786 queries from ~2500.
If we could update each file cache entry only once instead of twice we could already reduce the time by almost 50% (still thinking if something like this could be possible #18359 (comment)). It would be still way to much but a step in the right direction.
I also checked the encryption code once more and I don't see where the read opertions come from, we don't do any of them while writing the keys. I tried to cache some file_exists()/is_dir() calls which are used relatively often (https://github.com/owncloud/core/blob/master/lib/private/encryption/keys/storage.php#L306), but this doesn't make much sense because at least for the local storage this are only file system operations and no db operations. Maybe some of the read operations come from the update process and probably some from the sharing code? But it is probably not worth thinking hard about optimizing 1,9% of this issue, let us better try to get the 95% down.
I've been thinking about adding some sort of "operation grouping" api to the filesystem to make things like this easier, something like...
could be a step in the right direction. Any chance we can see something like this for 8.2 or 8.3?
Is this about etag / size propagation when writing to "files_encryption" or to "files" ?
Because if this is happening outside of "files" we can probably skip such updates as we don't need etags there.
It's all updates, size, etag and mtime. According to @icewind1991 every file/folder is touched twice. Once for to update the size and once to update the mtime and etag
Activity
icewind1991 commentedon Aug 17, 2015
That's not the case, there are 2 propagation steps, correcting folder sizes and propagating mtimes/etags, they are done separate because they have different requirements
icewind1991 commentedon Aug 17, 2015
The problem is that the encryption code makes 48 filessystem calls with an average folder depth of 8.
Since there is no knowledge in the filesystem layer about how things are grouped the only way to handle that is to do 48 * 8 * 2 = 786 cache updates (the remaining queries are cache reads from what I can tell)
schiessle commentedon Aug 17, 2015
We still need to find a solution how to improve this. On the encryption level there is not much we can do about it. We need to write a file-key for each file and a share key for each user and create the folder before we can create the files. I don't see how this can be improved on the encryption side, we perform the absolute minimum of operations in order to update the keys.
I also don't really understand how the 786 cache updated leads to 2578 queries at the end. According to the graph they all come from OC\File\Cache\Cache::update, something which shouldn't be triggered by a read operation
schiessle commentedon Aug 17, 2015
Just thinking: Couldn't this for example be done in a way that we first collect the data for mtime/etag and folder size in two steps but then perform the actual db update in one step once we have collected all the new values?
icewind1991 commentedon Aug 17, 2015
The graph is lying, if you click on
executeAuditedyou see that it has 6 callers, the graph only shows callers which are significant in time and since updates are way more expensive (~87% for 786 updates, and ~5% for the remaining ~1800 reads)icewind1991 commentedon Aug 17, 2015
Currently the only way to improve it is to bypass the view, work directly on the storage and call the updater yourself when you're done doing all operations. Since the crypt code knows how it will be using the filesystem it doesn't need to keep the cache uptodate during every step, just needs to make sure it's consistent at the end.
I've been thinking about adding some sort of "operation grouping" api to the filesystem to make things like this easier, something like
schiessle commentedon Aug 18, 2015
So it seems that we still need to optimize the ~95%, even if it is "only" 786 queries from ~2500.
If we could update each file cache entry only once instead of twice we could already reduce the time by almost 50% (still thinking if something like this could be possible #18359 (comment)). It would be still way to much but a step in the right direction.
I also checked the encryption code once more and I don't see where the read opertions come from, we don't do any of them while writing the keys. I tried to cache some file_exists()/is_dir() calls which are used relatively often (https://github.com/owncloud/core/blob/master/lib/private/encryption/keys/storage.php#L306), but this doesn't make much sense because at least for the local storage this are only file system operations and no db operations. Maybe some of the read operations come from the update process and probably some from the sharing code? But it is probably not worth thinking hard about optimizing 1,9% of this issue, let us better try to get the 95% down.
could be a step in the right direction. Any chance we can see something like this for 8.2 or 8.3?
PVince81 commentedon Aug 18, 2015
Is this about etag / size propagation when writing to "files_encryption" or to "files" ?
Because if this is happening outside of "files" we can probably skip such updates as we don't need etags there.
schiessle commentedon Aug 18, 2015
It's all updates, size, etag and mtime. According to @icewind1991 every file/folder is touched twice. Once for to update the size and once to update the mtime and etag
schiessle commentedon Aug 31, 2015
@michaelstingl for your information
37 remaining items
PVince81 commentedon Feb 29, 2016
I don't want to merge #22733 now, it's too risky (moved to 9.0.1).
#22648 seems to be an oversight from another perf fix you did before, so we need to get that one in too for 9.0 to get some benefit. Is that correct ?
icewind1991 commentedon Feb 29, 2016
(all comparisons are made against stable8.2)
Just #22648 ~19%
icewind1991 commentedon Feb 29, 2016
I think you're mixing up the 2, #22733 is a fairly small fix that I missed before, #22648 I agree is to risky
PVince81 commentedon Feb 29, 2016
Yeah, mixed up sorry.
MorrisJobke commentedon Mar 1, 2016
MorrisJobke commentedon Mar 1, 2016
Only #22648 is not merged and will not get into 9.1 -> moving this issue to 9.1 too, because the 9.0 issues are resolved.
MorrisJobke commentedon Mar 1, 2016
@PVince81 Or should we create a new issue?
PVince81 commentedon Mar 1, 2016
I'm fine keeping this issue.
[-]change propagator updates parent to often[/-][+]change propagator updates parent too often[/+]icewind1991 commentedon May 3, 2016
Can we close this issue with #22648 merged?
lock commentedon Aug 4, 2019
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.