--fast-list gets quadratic when filters exclude many files
Before you start
- I have searched the forum and the existing issues for this problem.
- I have tested with the latest beta or stable release and can still reproduce the problem.
- This is a reproducible bug, not a usage question (questions belong on the forum).
Associated forum post URL
No response
What is the problem you are having with rclone?
with --fast-list, walkRDirTree in fs/walk/walk.go calls DirTree.Find for every excluded object (and every object below --max-depth) to check whether its parent directory is already in the tree. Find scans the parent's entries one by one under the ListR callback lock, so this goes quadratic in two layouts: many excluded files next to many kept files in one directory, and many directories that each hold an excluded file on a bucket remote (say --exclude .DS_Store on S3), where the parent fills up with synthetic dirs. with --exclude-if-present it also runs a FileExists per excluded object instead of once per directory
a benchmark calling walkRDirTree with --exclude "*.tmp" on master 9dc8b71: 100k kept + 100k excluded files in the root take 12.7 s, 100k dirs with one kept and one excluded file each take 28.5 s. a sync --fast-list between two memory remotes in one process, already in sync, with the second layout takes 2m42s. it's the same kind of problem as 07133b892, whose message says any caller of DirTree.Find can be slow. I have a fix (a map of directories already added or checked in walkRDirTree, dirtree untouched) that brings these to 0.17 s, 0.37 s and about 2 s, and can send a PR if the approach sounds right
rclone version
rclone v1.76.0-DEV
- os/version: Microsoft Windows 11 Pro 25H2 25H2 (64 bit)
- os/kernel: 10.0.26200.9550 (x86_64)
- os/type: windows
- os/arch: amd64
- go/version: go1.26.0
- go/linking: dynamic
- go/tags: noneOperating system
Windows
Which cloud storage system are you using?
memory backend for the measurements, the layouts above matter on any bucket remote with ListR (S3 etc)
Output of rclone config redacted
no config, on the fly :memory: remotesThe command you were trying to run
rclone sync src: dst: --fast-list --exclude "*.tmp"A log from the command with the -vv flag
nothing useful in it, the time is CPU spent building the directory treeAnything else?
No response
Source: rclone/rclone