Bỏ qua đến nội dung chính

Tối ưu tốc độ

Sync chậm có 4 nguyên nhân chính, từ frequent → rare:

  1. Disk read source (Syncthing đọc file để hash)
  2. Hash CPU (SHA-256 từng block)
  3. Network bandwidth
  4. File watcher overhead
Terminal window
# Web UI → folder card → check progress
# Nếu Local State đang scan → bottleneck #1 hoặc #2
# Nếu Syncing % chậm progress → bottleneck #3
# Nếu "Out of Sync" mãi không clear → bottleneck #4

Most common issue.

Windows Syncthing process
Đọc file qua \\wsl.localhost\ (9P bridge) ← BOTTLENECK
WSL ext4 filesystem

Symptom: scan rate ~20-50 MB/min cho WSL folders.

Fix: Cài Syncthing native trong WSL — xem Setup WSL. Speedup ~120x.

Folders với nhiều files nhỏ (vd .git/objects/, node_modules/) — overhead per-file > content transfer.

Numbers thực tế:

  • 70,000 files × ~1ms open/hash/close = 70 giây pure overhead
  • Network may be idle most of time waiting for file ops

Fix:

# Build artifacts (huge file count)
**/node_modules
**/.next
**/dist
**/build
# Git internals (many small objects)
**/.git/objects/pack
**/.git/lfs
# Caches
**/.cache
**/__pycache__

Syncthing hash SHA-256 mỗi block 128KB. Trên CPU yếu (vd Atom, ARM low-end), hash speed ~50-100 MB/s.

Check Syncthing log:

[CEXGR] INFO: Single thread SHA256 performance is 368 MB/s
[CEXGR] INFO: Hashing performance is 307.73 MB/s

→ Đó là max throughput hash trên máy này.

Fix:

  • Hardware: SSD + modern CPU = 300+ MB/s
  • Settings: increase Max File Pull Concurrency (Settings → Advanced → Folder Settings)

LAN gigabit theoretical 125 MB/s, practical 80-100 MB/s sau TCP overhead.

Check actual rate:

Terminal window
# Web UI → Remote Devices → device card → Download Rate / Upload Rate

Nếu rate << bandwidth (vd LAN gigabit nhưng chỉ 5 MB/s):

  • Bottleneck KHÔNG phải network
  • Likely là disk read source hoặc small file overhead

Symptom: edit file → Syncthing không detect → phải Force Rescan manually.

Causes:

  • Cross-OS access (\wsl.localhost) — file events lost
  • Network mounts (CIFS, NFS) — watch fail
  • WSL2 native ext4 — work OK
  • Windows NTFS native — work OK

Fix:

  • Set Rescan Interval ngắn hơn (Web UI → folder edit → Advanced → Rescan Interval): default 3600s (1h), set 60-300s
  • Hoặc disable Watch for Changes + rely on rescan

Syncthing maintain database ~/.config/syncthing/index-v0.14.0.db/ (Linux) hoặc %APPDATA%\Syncthing\ (Windows). Database growth có thể slow over time.

Fix nếu Syncthing càng chạy càng chậm:

Terminal window
# Stop Syncthing
pkill -f syncthing
# Backup config
cp -r ~/.config/syncthing ~/.config/syncthing.bak
# Reset index database (sẽ re-scan all folders)
rm -rf ~/.config/syncthing/index-v0.14.0.db
# Restart
syncthing serve --no-browser &

⚠ Re-scan all folders sẽ tốn time tương tự initial scan. Chỉ làm khi cần.

Default Syncthing compression: Metadata Only. Cho text-heavy folders, switch sang All Data có thể giảm bandwidth 30-50%:

Web UI → Edit Device → Advanced → Compression: All Data

⚠ Trade-off CPU usage tăng cho compression. Acceptable cho small files, bad cho large media.

Settings → Advanced → Folder Settings:
Max Folder Concurrency: 4 (default 0 = unlimited)
Pull Order: Random (default) hoặc Newest First (cho time-sensitive)
Disable Sparse Files: false (default)
Settings → Advanced → Connections:
Max Send/Receive Rate: 0 (unlimited) hoặc throttle nếu chia sẻ network

Em đã measure trên setup AIWS production (mid-range workstation + LAN gigabit):

FolderPath typeFilesSizeInitial scanSync rate
~/.claude/Native NTFS1,989104 MB30s~50 MB/s
D:/Public LAN Folder/Native NTFS31,4848.3 GB3 min~80 MB/s
~/projects/ (Win 9P)Cross-OS 9P70,6401 GB scanned❌ never finished46 KiB/s
/home/x/projects/ (WSL native)Native ext4107,5886.11 GB95s~5 MB/s small files

Insights:

  • Native paths >> cross-OS
  • Small file overhead dominate trên 6.11 GB / 107k files (avg ~60KB/file → too many syscalls)
  • LAN bandwidth không phải bottleneck cho code projects (chủ yếu small files)