perf: optimize sync with mtime-based change detection and configurable interval#268
Open
troshab wants to merge 1 commit intozilliztech:masterfrom
Open
perf: optimize sync with mtime-based change detection and configurable interval#268troshab wants to merge 1 commit intozilliztech:masterfrom
troshab wants to merge 1 commit intozilliztech:masterfrom
Conversation
…e interval Two improvements to the background sync mechanism: 1. Use mtime+size to skip unchanged files during sync. Instead of reading and SHA-256 hashing every file on each sync cycle, stat() each file first and only hash files where mtime or size changed. For a 17k-file codebase with 0 changes: ~200ms (stat only) vs ~10s (read+hash all). File stats are persisted in the snapshot alongside content hashes, with backward compatibility for old snapshots (falls back to full hash on first run). 2. Make sync interval configurable via SYNC_INTERVAL_SECONDS env var (default: 60s, was hardcoded 300s). Minimum 10s to prevent excessive polling. The shorter default is practical now that per-cycle cost is dramatically lower with mtime optimization. Closes zilliztech#267
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two improvements to the background file sync mechanism:
1. mtime+size based change detection
Instead of reading and SHA-256 hashing every file on each sync cycle, the synchronizer now:
stat()each file to get mtime + size (~100x faster than read+hash)Impact for a 17k-file codebase with 0 changes: ~200ms (stat only) vs ~10s (read+hash all).
File stats are persisted in the snapshot alongside content hashes. Old snapshots without stats are handled gracefully (falls back to full hash on first run after upgrade).
2. Configurable sync interval via
SYNC_INTERVAL_SECONDSSYNC_INTERVAL_SECONDSenvironment variableTest plan
pnpm buildcompiles without errorsfileStatsfield)SYNC_INTERVAL_SECONDS=30changes the sync intervalCloses #267