-
Notifications
You must be signed in to change notification settings - Fork 4.1k
feat: Enhance autocomplete cache with async initialization and improved eviction logic #8367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Enhance autocomplete cache with async initialization and improved eviction logic #8367
Conversation
…ed eviction logic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 issues found across 3 files
Prompt for AI agents (all 3 issues)
Understand the root cause of the following 3 issues and fix them.
<file name="core/autocomplete/util/AutocompleteLruCache.ts">
<violation number="1" location="core/autocomplete/util/AutocompleteLruCache.ts:218">
After close(), we need to clear the singleton so future get() calls reinitialize a fresh cache; otherwise callers receive an instance whose DB connection is already closed and whose flush timer never restarts.</violation>
</file>
<file name="core/autocomplete/util/AutocompleteLruCache.test.ts">
<violation number="1" location="core/autocomplete/util/AutocompleteLruCache.test.ts:4">
Mocking `async-mutex` removes the real Mutex implementation, so `cache.put` fails when it tries to call `this.mutex.acquire()`.</violation>
<violation number="2" location="core/autocomplete/util/AutocompleteLruCache.test.ts:638">
`jest.doMock("sqlite", …)` runs after AutocompleteLruCache imported `open`, leaving `open` as the default auto-mock and causing `AutocompleteLruCache.get()` to crash with an undefined database handle.</violation>
</file>
React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issues found across 2 files
|
@Ayyanaruto appreciate this contribution! |
|
Pleasure is all mine |
|
🎉 This PR is included in version 1.5.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 1.31.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 1.35.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
|
🎉 This PR is included in version 1.6.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Based on discussion #8315 Implement asynchronous initialization for the autocomplete cache and refine eviction logic to optimize performance and memory usage. This update ensures a more efficient handling of cached entries with SQLite persistence.
Summary by cubic
Initialize the autocomplete cache asynchronously and move lookups to an in-memory LRU with periodic SQLite persistence. This improves startup, speeds up cache hits, and tightens eviction for better memory usage.