I’ve been wondering if Google’s new Linux Terminal on Android could help solve Syncthing’s performance issues with large numbers of small files.
One suspected bottleneck is Android’s Storage Access Framework (SAF), which adds overhead when accessing files. Folders within the Linux VM can now be mounted on the host with the latest quarterly Android release. These are not subjected to SAF for apps within the VM while still being accessible for normal Android apps.
Since Linux applications running inside Google’s Linux VM don’t use SAF to access their own Linux filesystem, could running the native Linux version of Syncthing inside it bypass this bottleneck?
It might be worth experimenting with and benchmarking. Has anyone tried this?
Syncthing apps normally use the MANAGE_EXTERNAL_STORAGE (“All files”) permission, which allows accessing the internal storage via /storage/emulated/<user ID> instead of SAF. It lets Syncthing access files by path the same way it would on a desktop OS, but it’s not the device’s real filesystem. It goes through a FUSE mount provided by Android’s MediaProvider system component and is indeed quite slow for metadata operations. I think this is likely what you’re referring to.
(This is distinct from SAF, which is an entirely different set of APIs for accessing files by URIs instead of paths. As far as I’m aware, my own BasicSync app and SyncUp are the only Android Syncthing apps that support this in addition to the MANAGE_EXTERNAL_STORAGE method. It requires much deeper integration with Syncthing and is substantially slower than MANAGE_EXTERNAL_STORAGE. It is near unusable without some form of metadata caching, which both apps do.)
Android’s Linux terminal/VM app also uses MANAGE_EXTERNAL_STORAGE for shared storage between Android and the VM. If you set up Syncthing within the VM to access shared storage, it won’t be any faster than a native Syncthing app. If you sync to a directory within the VM’s own storage though, it’ll likely be quite a bit faster for lots of small files.
You didn’t read my post carefully. The last Android QPR released a feature to mount the internal filesystem of the Linux VM on the host. SyncThing in the VM has native access (no SAF) to the Linux filesystem. You can then share Linux folders with Android apps normally through SAF. SAF is only a problem for SyncThing, not other apps.
Ah sorry, yes, I misread. Sync performance to the Linux filesystem will almost certainly be faster.
Whether accessing the VM files via SAF is good enough probably depends on the app. The implementation of the new SAF provider in 17 QPR2 is not the best. They implemented it as a wrapper around an SFTP session to the guest, but it doesn’t support streaming (despite the protocol supporting it). Reading a file on the host requires the entire file to be copied from the guest to the host first. Writing a file buffers the entire contents on the host before it is transferred to the guest.
They did at least implement support for file change notifications though, which is nice.
I was just reading about this terminal program in my newsreader. Am I correct in my understanding that this is an application only available to Pixel owners?
I have a Samsung phone and I just got Android 17 but I don’t have a terminal app that runs outside the boundaries of the SAF.
On Android, on my phone and tablet, I rely on a program called rsaf that is an Android implementation of Rclone. Rclone allows you to mount cloud storage services and make them available through the Storage Access Framework on Android (so that essentially any application that you have on your phone that supports SAF can see any of the files you have on any of your cloud drives).
Here’s an example. I have an Android PDF scanner that’s nice but doesn’t have the ability to store PDFs directly to cloud drives. It has to choose a local folder and in my case the local folder that I choose is an RSAF folder to my cloud drive. The app thinks it’s saving the file to the local file system when actually it’s getting uploaded to the cloud.
If that sounds useful to anybody and you have a question, just let me know. RSAF, an implementation of Rclone for Android, is hosted on both GitHub and Fdroid.