Skip to content

perf: Round 2 — Remove poll loop, fire-and-forget with retry, mtime skip-early, combined Redis FCALL#1

Merged
krisclarkdev merged 1 commit into
mainfrom
performance-improvements
Mar 13, 2026
Merged

perf: Round 2 — Remove poll loop, fire-and-forget with retry, mtime skip-early, combined Redis FCALL#1
krisclarkdev merged 1 commit into
mainfrom
performance-improvements

Conversation

@krisclarkdev

@krisclarkdev krisclarkdev commented Mar 13, 2026

Copy link
Copy Markdown
Owner

Summary

Major performance overhaul targeting the sync pipeline bottleneck identified via production Proxmox metrics (CPU 0.4%, IO 0.36% — hardware idle while sync took hours).

Changes

1. Remove poll_process_status (10-50x)

Eliminated the 2-second sleep poll loop entirely. Uploads now fire-and-forget: upload → attach to KB immediately.

2. Retry List Pattern

Failed background attaches are collected into a shared retry list and retried at the end of sync (Phase 1b).

3. mtime + size Skip-Early (100x re-syncs)

Check file metadata before hashing. If both match Redis, skip without reading the file.

4. Combined Redis FCALL (2-3x Redis)

New Lua 'check_and_compare' replaces separate check + verify calls. Single round-trip.

5. HMGET for Context Manager (2x)

Single HMGET per key instead of 2 HGETs.

Estimated Impact (13K files)

Scenario Before After Speedup
First sync ~4.5 hours ~8 min 34x
Re-sync (0 changes) ~5 min ~7 sec 43x
Re-sync (100 changes) ~15 min ~45 sec 20x

All 57 tests pass.

…ime+size skip-early, combined Redis FCALL, HMGET

1. Remove poll_process_status from sync pipeline entirely — fire-and-forget
   uploads skip the 2-second poll loop, attach to KB immediately
2. Retry list pattern: failed background attaches are collected and retried
   at the end of Phase 1 (Phase 1b), ensuring no files are silently dropped
3. mtime+size skip-early: check file metadata before hashing — if mtime and
   size match Redis, skip without reading the file (100x faster re-syncs)
4. Combined check_and_compare Lua FCALL: single Redis round-trip replaces
   separate check_file_exists + verify_file_hash calls (2-3x Redis speedup)
5. HMGET for Context Manager: single HMGET per key instead of 2 HGETs (2x)
6. Default max_concurrent_uploads raised from 5 to 20
7. upsert_sync_state now stores file_mtime and file_size in Redis
@krisclarkdev
krisclarkdev merged commit 4e855f2 into main Mar 13, 2026
2 checks passed
@krisclarkdev
krisclarkdev deleted the performance-improvements branch March 13, 2026 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant