Tối ưu tốc độ
Xác định nút cổ chai
Phần tiêu đề “Xác định nút cổ chai”Sync chậm có 4 nguyên nhân chính, từ frequent → rare:
- Disk read source (Syncthing đọc file để hash)
- Hash CPU (SHA-256 từng block)
- Network bandwidth
- File watcher overhead
Quick diagnostic
Phần tiêu đề “Quick diagnostic”# 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 #4Nút cổ chai cross-OS (Windows ↔ WSL)
Phần tiêu đề “Nút cổ chai cross-OS (Windows ↔ WSL)”⚠ Most common issue.
Windows Syncthing process ↓ Đọc file qua \\wsl.localhost\ (9P bridge) ← BOTTLENECK ↓ WSL ext4 filesystemSymptom: scan rate ~20-50 MB/min cho WSL folders.
Fix: Cài Syncthing native trong WSL — xem Setup WSL. Speedup ~120x.
Quá nhiều file nhỏ
Phần tiêu đề “Quá nhiều file nhỏ”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__Sync 1 large folder thay vì 10 small folders nếu cùng pattern. Reduce metadata overhead.
CPU hash là nút cổ chai
Phần tiêu đề “CPU hash là nút cổ chai”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)
Băng thông mạng
Phần tiêu đề “Băng thông mạng”LAN gigabit theoretical 125 MB/s, practical 80-100 MB/s sau TCP overhead.
Check actual rate:
# Web UI → Remote Devices → device card → Download Rate / Upload RateNế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
File watcher không tin cậy
Phần tiêu đề “File watcher không tin cậy”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
Indexing database
Phần tiêu đề “Indexing database”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:
# Stop Syncthingpkill -f syncthing
# Backup configcp -r ~/.config/syncthing ~/.config/syncthing.bak
# Reset index database (sẽ re-scan all folders)rm -rf ~/.config/syncthing/index-v0.14.0.db
# Restartsyncthing serve --no-browser &⚠ Re-scan all folders sẽ tốn time tương tự initial scan. Chỉ làm khi cần.
Cài đặt nén
Phần tiêu đề “Cài đặt né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.
Tinh chỉnh nâng cao
Phần tiêu đề “Tinh chỉnh nâng cao”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ẻ networkBenchmark tốc độ thực tế
Phần tiêu đề “Benchmark tốc độ thực tế”Em đã measure trên setup AIWS production (mid-range workstation + LAN gigabit):
| Folder | Path type | Files | Size | Initial scan | Sync rate |
|---|---|---|---|---|---|
~/.claude/ | Native NTFS | 1,989 | 104 MB | 30s | ~50 MB/s |
D:/Public LAN Folder/ | Native NTFS | 31,484 | 8.3 GB | 3 min | ~80 MB/s |
~/projects/ (Win 9P) | Cross-OS 9P | 70,640 | 1 GB scanned | ❌ never finished | 46 KiB/s |
/home/x/projects/ (WSL native) | Native ext4 | 107,588 | 6.11 GB | 95s | ~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)
Bước tiếp theo
Phần tiêu đề “Bước tiếp theo”- Common issues — không phải performance issue
- Architecture — design choices ảnh hưởng performance