Menu

#1602 mtp-getfile takes 10 seconds to finish, go-mtpfs only 0.5s

open
nobody
None
1
2016-08-28
2016-08-28
b2f9h203
No

For some reason mtp-getfile and mtp-connect --getfile and also mtp-connect are very slow. Why? Is this a bug?

time mtp-connect --getfile 3158 IMG_20160826_093251.jpg
    libmtp version: 1.1.12

    Device 0 (VID=12d1 and PID=1082) is a Huawei Ascend P8 .
    Android device detected, assigning default bug flags
    Get file 3158
    Getting 3158 to IMG_20160826_093251.jpg
    Unknown options: IMG_20160826_093251.jpg 

    real    0m10.146s
    user    0m0.244s
    sys 0m0.356s

When trying with go-mtpfs it only takes 500ms to mount the mtp device and transfer the file, compared to 10 seconds which mtp-connect needs. So it doesn't seem to be a hardware limited problem.

fusermount -u mtp && time ( go-mtpfs mtp & sleep 0.1s && cp 'mtp/SD card/DCIM/Camera/IMG_20160826_094255.jpg' . )
2016/08/28 15:27:27 FUSE mounted

real    0m0.503s
user    0m0.000s
sys 0m0.004s

Discussion

  • Marcus Meissner

    Marcus Meissner - 2016-08-28

    go-mtpfs might have a different directory read strategy. libmtp tries to get all fileinformations on startup.

    does copying a second file in the same instances also have thisdelay?

    this seems worthy investigating

     
  • b2f9h203

    b2f9h203 - 2016-08-28

    What do you mean with same instance? Something like this?:

    time mtp-connect --getfile 116 test1.mp3 --getfile 117 test2.mp3 --getfile 118 test3.mp3
    

    In that case, yes it is just as fast as copying only one file:

    libmtp version: 1.1.12
    
    Device 0 (VID=12d1 and PID=1082) is a Huawei Ascend P8 .
    Android device detected, assigning default bug flags
    Get file 116
    Getting 116 to test1.mp3
    Get file 11786391 of 2986391 (100%)
    Getting 117 to test2.mp3
    Get file 11828069 of 6528069 (100%)
    Getting 118 to test3.mp3
    Unknown options: test1.mp3 test2.mp3 test3.mp3 
    
    real    0m10.670s
    user    0m0.264s
    sys     0m0.396s
    

    I'm not sure why "Getting 117" suddenly changes to "Get file 11786391".

    Btw: When omitting the target, the file is written to a file named WM_LINK_LANGUAGE=c++:

    mtp-connect --getfile 116
        libmtp version: 1.1.12
    
        Device 0 (VID=12d1 and PID=1082) is a Huawei Ascend P8 .
        Android device detected, assigning default bug flags
        Get file 116
        Getting 116 to WM_LINK_LANGUAGE=c++
        Progress: 2986391 of 2986391 (100%)
    

    Lastly, I by chance noticed, that mtp-filetree list all the files on the internal drive with almost no latency, then it stops, waits for several (10?) seconds at the line Storage: Internal storage and then prints the rest. I think this is caused by the number of files:

    mtp-filetree
        Device 0 (VID=12d1 and PID=1082) is a Huawei Ascend P8 .
        Attempting to connect device(s)
        Android device detected, assigning default bug flags
        Device: (NULL)
        Storage: SD card
        2875 DCIM
        [124 lines]
        3184 test.txt
        Storage: Internal storage 
        [Here it waits several seconds]
        1 Music
        [9790 lines]
    
     
  • Marcus Meissner

    Marcus Meissner - 2016-08-28

    yes, it means it probably caches in all file information of the whole device on first call (likely per storage medium) .

     

Anonymous
Anonymous

Add attachments
Cancel