Skip to content

Make sure to filter filecache subfolders in sql query instead of memory#36565

Merged
micbar merged 1 commit intomasterfrom
issue_e2925_del_filter
Jan 28, 2020
Merged

Make sure to filter filecache subfolders in sql query instead of memory#36565
micbar merged 1 commit intomasterfrom
issue_e2925_del_filter

Conversation

@mrow4a
Copy link
Copy Markdown
Contributor

@mrow4a mrow4a commented Dec 11, 2019

Related issue: https://github.com/owncloud/enterprise/issues/2925
Goal: avoid having peaks in memory for large directory contents

While deleting directories with a lot of files inside usingview->unlink, we do not need to put in memory unnecessarily records. Filter for directories when only subdirs needed.

Example:

  • we have folder with 50k files and 100 subfolders
  • some parent function already loaded all 50100 records in memory
  • now we are going to run unlink on that folder contents
  • previously, all 50100 records were in memory in unlink
  • now, only 100 records are in memory unlink
  • resulting peak memory is 50200 instead of 100200

@mrow4a mrow4a self-assigned this Dec 11, 2019
@codecov
Copy link
Copy Markdown

codecov bot commented Dec 11, 2019

Codecov Report

Merging #36565 into master will increase coverage by 0.00%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master   #36565   +/-   ##
=========================================
  Coverage     64.69%   64.69%           
- Complexity    19114    19116    +2     
=========================================
  Files          1269     1269           
  Lines         74808    74816    +8     
  Branches       1327     1327           
=========================================
+ Hits          48395    48403    +8     
  Misses        26022    26022           
  Partials        391      391           
Flag Coverage Δ Complexity Δ
#javascript 54.09% <ø> (-0.01%) 0.00 <ø> (ø)
#phpunit 65.87% <100.00%> (+<0.01%) 19116.00 <5.00> (+2.00) ⬇️
Impacted Files Coverage Δ Complexity Δ
core/js/sharedialoglinkexpirationview.js 76.19% <0.00%> (-0.38%) 0.00% <0.00%> (ø%)
lib/private/Files/Cache/Cache.php 97.64% <0.00%> (+0.06%) 106.00% <0.00%> (+2.00%) ⬇️
lib/private/Share20/Manager.php 96.30% <0.00%> (ø) 273.00% <0.00%> (ø%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 920de6f...5dd63aa. Read the comment docs.

@mrow4a
Copy link
Copy Markdown
Contributor Author

mrow4a commented Dec 11, 2019

I will probably add 1 more unit test

@mrow4a mrow4a force-pushed the issue_e2925_del_filter branch from 52b1c19 to f6e8efd Compare December 16, 2019 22:10
@mrow4a mrow4a marked this pull request as ready for review December 16, 2019 22:10
@jvillafanez
Copy link
Copy Markdown
Member

Code looks good but we need to fix the tests.

@mrow4a
Copy link
Copy Markdown
Contributor Author

mrow4a commented Dec 17, 2019

yes I noticed that my test that I wrote failed because of some wrapping logic

@mrow4a mrow4a force-pushed the issue_e2925_del_filter branch from f6e8efd to c7aff85 Compare December 18, 2019 19:07
@mrow4a mrow4a force-pushed the issue_e2925_del_filter branch from c7aff85 to 54a4def Compare January 14, 2020 18:30
$this->assertTrue(true);
}

public function testFolderContentsFilter() {
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 don't really like this...
If the problem is that the parent test is calling a private method, can we adjust that test to call a public one ensuring that the call goes through the code we want? If needed, add 2 different tests, one per case.

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.

@jvillafanez I actually did as some other examples above in that test case. I am not sure if this is relevant to build testcase here.

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.

My worry is that, if we ever need to change the implementation in the CacheJail class, we might assume that there are tests, and due to the test passing we could think the code works even though it might be broken.

I think it's easier to call a public method in the CacheTest, and then copy & paste the test to adjust the expectations, if needed, in the rest of the implementations

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.

@jvillafanez ok now I remember why I commented with not supported as parent CacheTest calls private method of Cache class. Because if I try to call this private function I get exceptions on connection being null.

Please note that this function under test is private! It is called from public function remove, that currently has no unit tests.

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.

What if you test the public functions that call that private function instead?

I'm not sure if it's a better alternative that we mark the test as skipped or incomplete instead.

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.

Ok I will test public function remove, but it means also we cannot test filtering mechanism itself (coverage will however be happy)

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.

@mrow4a
Copy link
Copy Markdown
Contributor Author

mrow4a commented Jan 24, 2020

@micbar release note for this PR in #36602

@mrow4a mrow4a force-pushed the issue_e2925_del_filter branch from 54a4def to cc5bd22 Compare January 27, 2020 20:13
@micbar micbar requested a review from jvillafanez January 28, 2020 06:21
@micbar
Copy link
Copy Markdown
Contributor

micbar commented Jan 28, 2020

@mrow4a code style, double empty line

@mrow4a mrow4a force-pushed the issue_e2925_del_filter branch from cc5bd22 to 5dd63aa Compare January 28, 2020 07:46
@micbar micbar merged commit 9fd6f90 into master Jan 28, 2020
@delete-merged-branch delete-merged-branch bot deleted the issue_e2925_del_filter branch January 28, 2020 10:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants