Repository navigation
Report when the search index is not saved for size - #25
Open
Leo-Y-Zhang wants to merge 1 commit into
Open
Leo-Y-Zhang wants to merge 1 commit into
Leo-Y-Zhang wants to merge 1 commit into
Conversation
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
When an index would exceed
SGREP_CACHE_MAX_BYTES,build()insrc/index.rsreturnedOk(None)at either of its two size checks without any output. Every later query then rebuilt from scratch, and from the outside that looks exactly like a working cache (#20 measured 10-23 s per query against 0.1 s when the index fits).Both exits now print one line on stderr through a small helper, in the style of the file's existing
sgrep: could not ...messages:The first check runs before embedding and uses the existing estimate, so its line says "estimated"; the second reports the serialized size. stdout and exit codes are unchanged, and nothing is printed when the index is saved, when the limit is 0, or with
--no-cache.sgrep --helpnow documents the variable:The README's cache section says the skip is reported on stderr.
Before and after
A git-initialised folder with one file,
SGREP_CACHE_DIR=<fresh> SGREP_CACHE_MAX_BYTES=100 sgrep shipping <folder>:maina.txt:1-1/shipping oldneedle.sgrep-index.lock.sgrep-index.lockTests
New checks in
tests/cache_lifecycle.py, using itsrecord()pattern (plus acall_output()helper that also returns stderr and the exit code):Against a binary built from
main, the three checks that need the new behaviour fail (two on the missing notice, one on--help); the four guards pass on both. With the change, every check in the receipt isok: true.Gate (README "Development" block, clean
rust:1-bookwormcontainer)cargo build --release --locked: ok;cargo fmt --check: cleantests/cache_lifecycle.py: 15/15 checks ok (8 existing + 7 new)tests/e2e.py: ok, 31 checkstests/hybrid.py: ok, 25 checkstests/cache.py --online: ok, 16 checksFixes #20 for asks (1) and (2). Ask (3), saving a partial index when the full one is over the cap, changes what the cache stores, so I've left it for a separate proposal.