Skip to content

Make the auto-save mutation threshold configurable (--auto-save-mutations) - #90

Merged
Shengyu Fu (shengyfu) merged 1 commit into
microsoft:mainfrom
dpelksnitis:configurable-auto-save
Aug 17, 2026
Merged

Make the auto-save mutation threshold configurable (--auto-save-mutations)#90
Shengyu Fu (shengyfu) merged 1 commit into
microsoft:mainfrom
dpelksnitis:configurable-auto-save

Conversation

@dpelksnitis

Copy link
Copy Markdown
Contributor

Summary

tgrep serve auto-saves the in-memory index to disk once a fixed 5000 accumulated mutations pile up (AUTO_SAVE_MUTATIONS). Under sustained filesystem churn — a large VCS sync, a big build, mass file operations — that threshold is crossed repeatedly, firing frequent full-index saves that each briefly pause indexing.

Change

Expose the threshold as --auto-save-mutations <N> on serve (default unchanged at 5000), threaded through ServerState to the auto-save loop. Raising it reduces save frequency during heavy churn, trading a larger unsaved-work window (recovered by the stale check on next start) for fewer mid-activity pauses.

cargo fmt --all --check, cargo clippy --all-targets, and cargo test pass.

`tgrep serve` saves the in-memory index to disk after a fixed 5000
accumulated mutations. Under heavy filesystem churn (e.g. a large sync) this
can fire frequent full-index saves, each of which briefly pauses indexing.

Expose the threshold as `--auto-save-mutations <N>` (default 5000) so it can
be raised to trade save frequency for a larger unsaved-work window on crash.
Copilot AI review requested due to automatic review settings July 22, 2026 21:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes tgrep serve’s auto-save trigger threshold configurable via a new --auto-save-mutations <N> flag (defaulting to the existing behavior of 5000), allowing operators to reduce frequent full-index saves during high filesystem churn.

Changes:

  • Added --auto-save-mutations <N> to the serve command CLI options (validated as u32 >= 1).
  • Threaded the configured threshold through serve::run into ServerState.
  • Updated the auto-save loop to use state.auto_save_mutations instead of the fixed constant.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
tgrep-cli/src/serve.rs Plumbs the configurable threshold into ServerState and uses it in the auto-save trigger condition.
tgrep-cli/src/main.rs Adds the --auto-save-mutations CLI flag for tgrep serve and passes it to serve::run.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dpelksnitis

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree company="Epic Games"

@shengyfu

Copy link
Copy Markdown
Member

Dan Elksnitis (@dpelksnitis), thanks for your contribution!

@shengyfu
Shengyu Fu (shengyfu) merged commit d609585 into microsoft:main Aug 17, 2026
6 checks passed
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.

3 participants