# Local test with many small files Measured on 2026-11-05/06 with Ceph 21.2.0. Two independent lab clusters, each with one MON/MGR/MDS and one file-backed 4 GiB BlueStore OSD on the same host; four copy workers. Each file contains 128 bytes of deterministic data that is not all zeros. Half of the files are in one large directory, the other half spread over 50 directories. In addition: 100 hardlink names and 100 symlinks. Changes: 1 % each of contents, deletions, renames, new files, mode/xattr changes and xattr removals. The 2,000-file runs also contain numeric owners and access/default ACLs. ## Comparison with 2,000 files | Phase | Before | After | MDS requests before | MDS requests after | |---|---:|---:|---:|---:| | Initial run, two states | 490.2 s | 55.2 s | 115,132 | 87,437 | | Catch-up round | 52.2 s | 21.2 s | 52,677 | 38,911 | | Final round | 30.1 s | 24.1 s | 59,350 | 41,074 | In the final run: 30.8 % fewer MDS requests, 20.0 % shorter runtime. Both variants wrote 0 payload bytes there. The catch-up round wrote 12,928 bytes for 101 files in both variants. Measured maximum process RSS across the phases: 93.7 MiB before, 76.4 MiB after. Ceph daemons, CLI children and the application client are not included. The old version showed MDS read lock waits in the initial run. Other earlier runs took about 99 s there. The large difference in the initial run is therefore no general promise of a speedup. The comparison interrupted overnight and its restart are not included as a comparison measurement. ## Completed test with 10,000 files, before optimization | Phase | Duration | Payload written | |---|---:|---:| | Initial run, two states | 554.4 s | 1,280,000 bytes | | Catch-up round | 459.3 s | 64,128 bytes | | Final round | 84.1 s | 0 bytes | The independent application client compared a total of 50,500 regular file paths including hardlinks, live and in four historical states, plus symlinks and metadata. All checks passed. This additional test check takes 600.7 s and is not part of the measured duration of `finalize`. Remount and application restart are not included either. The copier reached 135.4 MiB process RSS. Journal and index took 1.59 MiB at the end. Before the cleanup, Ceph reported about 271.2 MiB of additional raw usage at the source and 726.6 MiB at the target. These values also include internal overhead and journal and BlueFS/RocksDB growth. ## Implemented changes - A complete local path inventory of the immutable source snapshot for pruning and the check for surplus paths; repeated source `stat` calls per target path are gone. Incomplete inventories prevent pruning. - No repeated index write transactions for identical inode rows. - No repeated `setattr` calls for already identical owner, mode and mtime; the target stat is reused during verification. - Data buffers sized to the file size or verification length, at most 4 MiB per buffer. - `AT_STATX_DONT_SYNC` only for immutable snapshot paths; live target paths keep normal synchronization semantics. Ceph's own [mirror uses the same snapshot access](https://github.com/ceph/ceph/blob/main/src/tools/cephfs_mirror/PeerReplayer.cc). ## Limits and reproduction MDS requests are not physically measured disk IOPS. The runs are single measurements on a shared host, without guaranteed cache conditions. Full metadata passes remain; 200 million files still need change planning that skips unchanged subtrees. The results are no release for that scale. ```sh make dev-smallfiles-test # smaller test with MDS counters: FILES=2000 REPORT_DIR=/tmp/cephmig-smallfiles-report make dev-smallfiles-test ``` On success, the test programs remove their own subvolumes, snapshots, claims and local state files. Ceph may report freed space with a delay. Raw data, binary hashes and details are in [smallfiles-local.json](smallfiles-local.json). In addition, the Go tests with the race detector and `go vet` for the native build passed, as did the complete native functional test with large/sparse files, blockdiff, historical snapshots, ACLs, quotas, hardlinks to symlinks/FIFOs, cancellation and SIGKILL resume. The fixtures of the successful run were removed.