New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 712121 link

Starred by 1 user

Issue metadata

Status: Archived
Owner:
Closed: Jul 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 2
Type: Bug

Blocked on:
issue 462989
issue 716309



Sign in to add a comment

Copying selected files from MTP is very slow if you keep many files selected

Project Member Reported by satorux@chromium.org, Apr 17 2017

Issue description

What steps will reproduce the problem?
1. Open a MTP folder with ~1900 of image files
2. Sort by Size
3. Select most of the files and press Ctrl-C (ex. empty temp files aren't selected) 
4. Open a new Files app window, and press Ctrl-V in Downloads

What is the expected result?

The selected files are copied quickly, like less than a second per file.

What happens instead of that?

The selected files are copied very slowly: it took about 30 seconds per file.

Please provide any additional information below. Attach a screenshot if
possible.

yawano@ suggested I close the first window with ~1900 files selected on MTP. In about 30 seconds (probably still busy with handling requests in the queue), the file copy sped up significantly to less than one second per file.

Then I opened a new window and navigate to the MTP folder in question. The file copy remained fast, but it got slower again after I selected the files I originally selected.
 
Labels: -OS-Linux

Comment 2 by tetsui@chromium.org, Apr 18 2017

Status: Started (was: Assigned)

Comment 3 by tetsui@chromium.org, Apr 21 2017

Each time file copy finishes, GetFileInfo for all the selected files is sent. This leads to N^2 unnecessary GetFileInfo calls in total, thus this problem is caused.

I wrote the fix to stop firing events when the selected files are not changed https://crrev.com/2828373003/, but not sure if it is the right way to fix it because there is also Metadata cache.

Comment 4 by fukino@chromium.org, Apr 21 2017

Metadata/thumbnail are supposed to be cached.
I'd like to know why they are not cached / caches are not used.
There might be an issue whose scope is not limited to MTP...
Cc: mtomasz@chromium.org
+mtomasz who may remember something about the metadata cache. :)
I don't really remember much, over the fact that the cache should workh here. hirono@ may know more, as he rewrote the metadata cache at some moment.

Comment 7 by fukino@chromium.org, Apr 21 2017

One theory for thumbnails is that the number of thumbnails or each size of the thumbnail is too big to fit in the cache.

Comment 8 by tetsui@chromium.org, Apr 21 2017

I verified on Pixel that at least one of the listeners of CHANGE_THROTTLED is causing this. However, going further is time-consuming because of the following reason.

I thought this bug is also reproducible on workstation as fukino-san said #4, but the main factor causing the slow down seems to be different between workstation and real Chromebook.

Besides, other CHANGE_THROTTLED listeners are also not lightweight, thus I think having both this change and fixing metadata cache miss would be better.
One important case that was not be covered in https://crrev.com/2828373003/ is selecting many files and deleting.

Comment 9 by hirono@chromium.org, Apr 21 2017

For metadata miss, adding console.log(/* for stack */ new Error()) to these methods may be useful to see which operation actually invalidates metadata caches.

MetadataModel#notifyEntriesCreated
MetadataModel#notifyEntriesRemoved
MetadataModel#notifyEntriesChanged

Blockedon: 462989
Project Member

Comment 11 by bugdroid1@chromium.org, Apr 26 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/6e537c987f4d8cc6fcfda8f80b4c3216663371d4

commit 6e537c987f4d8cc6fcfda8f80b4c3216663371d4
Author: tetsui <tetsui@google.com>
Date: Wed Apr 26 07:50:16 2017

Reuse FileTasks when entries are not changed.

fileManagerPrivate.getFileTasks is slow.
However, every time a file is copied during multi file copy, the method
was called via CHANGE_THROTTLED event listener.
This CL stops creating FileTasks again when file entries for the
previous FileTasks are same as the current ones.
Other possible solution to this problem is to change C++ interface of
fileManagerPrivate.getFileTasks to support incremental update of
FileTasks.

BUG= 462989 , 712121 
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation

Review-Url: https://codereview.chromium.org/2833413003
Cr-Commit-Position: refs/heads/master@{#467264}

[modify] https://crrev.com/6e537c987f4d8cc6fcfda8f80b4c3216663371d4/ui/file_manager/file_manager/common/js/util.js
[modify] https://crrev.com/6e537c987f4d8cc6fcfda8f80b4c3216663371d4/ui/file_manager/file_manager/foreground/js/file_tasks.js
[modify] https://crrev.com/6e537c987f4d8cc6fcfda8f80b4c3216663371d4/ui/file_manager/file_manager/foreground/js/task_controller.js

Project Member

Comment 12 by bugdroid1@chromium.org, Apr 26 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/3cba6ce1c4b98fb56f02556984813be8697b7729

commit 3cba6ce1c4b98fb56f02556984813be8697b7729
Author: tetsui <tetsui@google.com>
Date: Wed Apr 26 08:38:09 2017

Reuse File objects in FileTransferController.

FileEntry.file is slow operation internally queries file metadata.
However, FileTransferController calls FileEntry.file for all the
selected files each time CHANGE_THROTTLED event is fired.
CHANGE_THROTTLED is fired every time a file is copied
during multi file copy.
In some slow storage devices which do not support parallel requests
such as MTP connected ones, this severely slows down file copy.

BUG= 712121 
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation

Review-Url: https://codereview.chromium.org/2843683002
Cr-Commit-Position: refs/heads/master@{#467270}

[modify] https://crrev.com/3cba6ce1c4b98fb56f02556984813be8697b7729/ui/file_manager/file_manager/foreground/js/file_transfer_controller.js

Blockedon: 716309
Cc: weifangsun@chromium.org
Question on this one - Is this behavior specific to MTP devices or the general copy/paste workflow in Files app for a large # of files?

Note a related recent user post on reddit - https://www.reddit.com/r/chromeos/comments/6cr8gr/chrome_os_file_manager_crashes_when_i_plug_in_a/
This is a general problem, and the problem is especially severe on slow storage devices.

FYI: I'm working on the blocking item.  http://crbug.com/716309  https://crrev.com/2856533003/
Project Member

Comment 16 by bugdroid1@chromium.org, Jun 1 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/e32d7951cd631cbeccd84b0ce874a41c9ee12faa

commit e32d7951cd631cbeccd84b0ce874a41c9ee12faa
Author: tetsui <tetsui@chromium.org>
Date: Thu Jun 01 08:31:52 2017

Add background-wide file metadata cache.

Several background classes needs file metadata to perform their tasks.
However, Metadata cache was only available to foreground classes. Also,
lifetime of foreground metadata cache is tied to windows, so we have to
maintain separate Least Recently Used cache in the background.
As having separate cache for several background classes is inefficient,
we are going to have global cache class that is shared among them.
This has huge performance impact on slow storage devices such as MTP
conencted ones.

TEST=manually tested.
BUG= 716309 , 712121 
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation

Review-Url: https://codereview.chromium.org/2856533003
Cr-Commit-Position: refs/heads/master@{#476228}

[modify] https://crrev.com/e32d7951cd631cbeccd84b0ce874a41c9ee12faa/ui/file_manager/file_manager/background/js/background_scripts.js
[modify] https://crrev.com/e32d7951cd631cbeccd84b0ce874a41c9ee12faa/ui/file_manager/file_manager/background/js/compiled_resources2.gyp
[modify] https://crrev.com/e32d7951cd631cbeccd84b0ce874a41c9ee12faa/ui/file_manager/file_manager/background/js/duplicate_finder_unittest.html
[modify] https://crrev.com/e32d7951cd631cbeccd84b0ce874a41c9ee12faa/ui/file_manager/file_manager/background/js/file_operation_manager.js
[modify] https://crrev.com/e32d7951cd631cbeccd84b0ce874a41c9ee12faa/ui/file_manager/file_manager/background/js/file_operation_manager_unittest.html
[modify] https://crrev.com/e32d7951cd631cbeccd84b0ce874a41c9ee12faa/ui/file_manager/file_manager/background/js/file_operation_util.js
[modify] https://crrev.com/e32d7951cd631cbeccd84b0ce874a41c9ee12faa/ui/file_manager/file_manager/background/js/import_history.js
[modify] https://crrev.com/e32d7951cd631cbeccd84b0ce874a41c9ee12faa/ui/file_manager/file_manager/background/js/import_history_unittest.html
[modify] https://crrev.com/e32d7951cd631cbeccd84b0ce874a41c9ee12faa/ui/file_manager/file_manager/background/js/import_history_unittest.js
[modify] https://crrev.com/e32d7951cd631cbeccd84b0ce874a41c9ee12faa/ui/file_manager/file_manager/background/js/media_scanner.js
[modify] https://crrev.com/e32d7951cd631cbeccd84b0ce874a41c9ee12faa/ui/file_manager/file_manager/background/js/media_scanner_unittest.html
[add] https://crrev.com/e32d7951cd631cbeccd84b0ce874a41c9ee12faa/ui/file_manager/file_manager/background/js/metadata_proxy.js
[modify] https://crrev.com/e32d7951cd631cbeccd84b0ce874a41c9ee12faa/ui/file_manager/file_manager/common/js/importer_common.js
[modify] https://crrev.com/e32d7951cd631cbeccd84b0ce874a41c9ee12faa/ui/file_manager/file_manager/common/js/importer_common_unittest.html
[modify] https://crrev.com/e32d7951cd631cbeccd84b0ce874a41c9ee12faa/ui/file_manager/file_manager/common/js/importer_common_unittest.js

Status: Fixed (was: Started)
Project Member

Comment 18 by bugdroid1@chromium.org, Jul 6 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/5474326ed3852a9e39a625af8c3b4f1b46ac7854

commit 5474326ed3852a9e39a625af8c3b4f1b46ac7854
Author: yamaguchi <yamaguchi@chromium.org>
Date: Thu Jul 06 09:24:15 2017

Revert of Reuse FileTasks when entries are not changed. (patchset #3 id:40001 of https://codereview.chromium.org/2833413003/ )

Reason for revert:
We'd like to revert this patch because this seem to have caused regression  crbug.com/738803 .
2973003002 needs to be merged before this CL in order to revert another dependent change first.

Original issue's description:
> Reuse FileTasks when entries are not changed.
>
> fileManagerPrivate.getFileTasks is slow.
> However, every time a file is copied during multi file copy, the method
> was called via CHANGE_THROTTLED event listener.
> This CL stops creating FileTasks again when file entries for the
> previous FileTasks are same as the current ones.
> Other possible solution to this problem is to change C++ interface of
> fileManagerPrivate.getFileTasks to support incremental update of
> FileTasks.
>
> BUG= 462989 , 712121 
> CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation
>
> Review-Url: https://codereview.chromium.org/2833413003
> Cr-Commit-Position: refs/heads/master@{#467264}
> Committed: https://chromium.googlesource.com/chromium/src/+/6e537c987f4d8cc6fcfda8f80b4c3216663371d4

TBR=fukino@chromium.org,tetsui@google.com
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG= 462989 , 712121 , 738803 

Review-Url: https://codereview.chromium.org/2966163005
Cr-Commit-Position: refs/heads/master@{#484512}

[modify] https://crrev.com/5474326ed3852a9e39a625af8c3b4f1b46ac7854/ui/file_manager/file_manager/common/js/util.js
[modify] https://crrev.com/5474326ed3852a9e39a625af8c3b4f1b46ac7854/ui/file_manager/file_manager/foreground/js/file_tasks.js
[modify] https://crrev.com/5474326ed3852a9e39a625af8c3b4f1b46ac7854/ui/file_manager/file_manager/foreground/js/task_controller.js

Status: Assigned (was: Fixed)
Reopening this issue because we reverted the change for another  issue 738803 .
Project Member

Comment 20 by bugdroid1@chromium.org, Jul 11 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/de06552d022a46e64a63a0ce601cfc463710ec17

commit de06552d022a46e64a63a0ce601cfc463710ec17
Author: Tetsui Ohkubo <tetsui@chromium.org>
Date: Tue Jul 11 05:57:13 2017

Fix double click regression and restore MTP related fixes.

MTP related fixes caused regression on the behavior when multiple files
selected are double-clicked.
These MTP related fixes were reverted in:
* https://codereview.chromium.org/2973003002/
* https://codereview.chromium.org/2966163005/

This CL restores these reverted CLs while fixes double click regression.

BUG= 462989 , 712121 , 731483 , 738803 
TEST=
unit: out/Debug/browser_tests '--gtest_filter=FileManagerJsTest.TaskController'
* Verified it fails with the original patches.
manual:
* Transfer files on MTP while selecting many source files.
* Transfer files on MTP while opening context menu.
* Double click multiple selected files.

Change-Id: If61e5f306f821d0bf096c068b01866ce1cfd38c9
Reviewed-on: https://chromium-review.googlesource.com/562912
Reviewed-by: Naoki Fukino <fukino@chromium.org>
Commit-Queue: Tetsui Ohkubo <tetsui@chromium.org>
Cr-Commit-Position: refs/heads/master@{#485534}
[modify] https://crrev.com/de06552d022a46e64a63a0ce601cfc463710ec17/ui/file_manager/file_manager/common/js/util.js
[modify] https://crrev.com/de06552d022a46e64a63a0ce601cfc463710ec17/ui/file_manager/file_manager/foreground/js/file_tasks.js
[modify] https://crrev.com/de06552d022a46e64a63a0ce601cfc463710ec17/ui/file_manager/file_manager/foreground/js/task_controller.js
[modify] https://crrev.com/de06552d022a46e64a63a0ce601cfc463710ec17/ui/file_manager/file_manager/foreground/js/task_controller_unittest.js

Status: Fixed (was: Assigned)

Comment 22 by dchan@chromium.org, Jan 22 2018

Status: Archived (was: Fixed)

Sign in to add a comment