Skip to content

casefs: 1s cache expiry makes pulling into large directories on Android ~100x slower than with caseSensitiveFS=true #10945

Open

Description

@malteish

What happened?

Pulling a folder with many files per directory to Android is extremely slow with the default caseSensitiveFS=false. Enabling caseSensitiveFS for that folder on the Android device made it about 100× faster. Nothing else changed: same connection, same files, same devices, measured minutes apart.

Setup

  • Sender: Linux, send-only folder. Receiver: Android 17 (Pixel 8 Pro, Syncthing-Fork), receive-only folder under shared storage (/storage/emulated/<user>/Pictures/..., i.e. Android's FUSE layer).
  • Folder: ~62k files (JPG/PNG, avg ~400 KB), 88 directories. Largest directory has 13,385 files; others have 6,160 and many around 1,000–1,500.
  • Same LAN, TCP connection; the sender's disk, CPU and Wi‑Fi were verified not to be the bottleneck.

Measurements (on the sender, from /rest/db/completion and outBytesTotal in /rest/system/connections, sampled over 60–90 s)

caseSensitiveFS on receiver Files/min Throughput
false (default), several samples over ~30 min ~15–21 65–120 KiB/s
true, 60 s sample 2,162 11.5 MiB/s
true, 60 s sample a few minutes later 1,724 10.9 MiB/s

Most items the receiver still needed at the time were in the 13,385-file directory. A different folder with ≤ 6 files per directory synced quickly on the same device with the default setting.

Likely cause

In lib/fs/casefs.go, cached directory listings expire after caseCacheTimeout = time.Second. On Android's FUSE storage, listing a directory with thousands of entries is slow, and writing a single file there also takes well over a second. So by the next operation the listing has expired, and each pulled file pays for at least one full re-listing of the directory (temp file create/open, rename and stat all go through checkCase). The comment in newCaseNode already mentions this case ("e.g. dirs with many children on android").

#10830 (in v2.1.7) keeps the cache up to date for Syncthing's own operations, but as its description says, "the 1s expiry is unchanged". On Android that expiry is still the bottleneck.

Possible improvements

  • Make the expiry adaptive, e.g. a multiple of how long DirNames took for that directory, so slow listings stay cached longer.
  • Or, since chore(fs): optimise casefs caching performance #10830 already updates the cache for Syncthing's own changes, rely on the watcher/scan to invalidate it for outside changes instead of a fixed 1 s timeout.

Turning off caseSensitiveFS is the workaround, but it gives up the protection against case-only name clashes. It is also only available under Actions → Advanced, so most Android users won't find it.

Expected: pulling many small files into a large directory on Android with the default caseSensitiveFS=false should be roughly as fast as with it enabled, as #10830 achieved on desktop.

Syncthing version

v2.1.7 (Android receiver, Syncthing-Fork 2.1.7.0); sender v1.30.0

Platform & operating system

Android 17 arm64 (receiver); Linux amd64 (sender)

Activity

  1. 0then0 commented on Nov 6, 2026

    @0then0

    I measured this on a Pixel 8 running Android 17. Each run received the same 128 files (400 KiB each) into a directory with 13,385 existing entries in shared storage. The receiver ran from adb shell, with Syncthing traffic over USB. I timed the pull after the initial scan and added no artificial delays.

    • main, caseSensitiveFS=false: 76.5 s, 10 full directory listings from casefs, 9 of them due to cache expiry. DirNames took 67.0 s in total.
    • Adaptive expiry, caseSensitiveFS=false: 19.5 s, 2 full listings, 1 due to expiry. DirNames took 10.8 s in total.
    • Control, caseSensitiveFS=true: 8.4 s, no listings from casefs.

    The experimental build caches successful listings for 10× the listing time, clamped to 1–5 seconds. Cache hits and Syncthing’s own file operations don’t extend that deadline. All three runs completed without errors. This was one run per configuration.
    Would a bounded adaptive expiry be an approach you’d consider for casefs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions