Summary
This issue is probably caused by Android allowing access to the internal storage via FUSE (Filesystem in USErspace), as the internal storage itself is just a subdirectory of the /data
partition.
Test conditions
These tests have been performed on LineageOS 14.1 (Android 7.1.2), via the Termux terminal emulator, using a directory called test
which contained 9414 files whose size ranged from one to five bytes. The underlying /data
partition was formatted as ext4
.
I am not affiliated to either Termux or its author.
First test
The commands used were
cd /sdcard
time cp -r test test2
Which returned an elapsed time of
real
1m10.477s
user
0m0.595s
sys
0m3.360s
The directory test2
was deleted after confirming the results.
Second test
The commands used were
su
cd /data/media/0
time cp -r test test2
Basically, what I did here was to move to the /data
subdirectory which contains the actual internal storage. The results of this test follow.
0m07.06s real
0m00.14s user
0m06.18s system
Conclusions
Given the huge discrepancy in the time elapsed while copying data on FUSE and while doing the same on ext4 directly, I assume that the culprit be the overhead generated by FUSE itself.