continue icon indicating copy to clipboard operation
continue copied to clipboard

feat: Enhance autocomplete cache with async initialization and improved eviction logic

Open Ayyanaruto opened this issue 2 months ago • 2 comments

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.

  • New Features
    • Async singleton cache initialization that loads existing entries and starts a 30s flush timer.
    • In-memory longest-prefix matching with validation; timestamps updated on access.
    • LRU eviction in memory when capacity is exceeded, marking evicted keys for deletion.
    • Periodic flush persists dirty entries in a single transaction (upsert/delete) under a mutex, with graceful error handling.
    • CompletionProvider now awaits the cache on demand and disposes it cleanly via close().
    • Added comprehensive tests for cache operations, eviction, persistence, timer behavior, and resource cleanup.

Ayyanaruto avatar Oct 21 '25 10:10 Ayyanaruto

@Ayyanaruto appreciate this contribution!

RomneyDa avatar Nov 12 '25 20:11 RomneyDa

Pleasure is all mine

Ayyanaruto avatar Nov 13 '25 16:11 Ayyanaruto

:tada: This PR is included in version 1.5.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

sestinj avatar Nov 19 '25 04:11 sestinj

:tada: This PR is included in version 1.31.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

sestinj avatar Nov 19 '25 22:11 sestinj

:tada: This PR is included in version 1.35.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

sestinj avatar Nov 20 '25 21:11 sestinj

:tada: This PR is included in version 1.6.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

sestinj avatar Nov 20 '25 21:11 sestinj