Conversation
…table completion Cache fuzzy completion candidates (databases and tables) with a 30-second TTL to avoid repeated network calls when triggering fuzzy finders multiple times. Cache invalidation triggers: - TTL expiry (30 seconds) - Session change via USE/DETACH (session pointer comparison) - DDL execution (schema generation counter on Session) Fixes #514 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary of ChangesHello @apstndb, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the performance and user experience of the fuzzy finder feature by introducing a robust caching mechanism. By storing frequently accessed database and table completion candidates in a time-limited cache, it eliminates redundant network requests, leading to faster response times. The cache is intelligently invalidated upon schema modifications or session changes, ensuring data consistency without manual intervention. Highlights
Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Code Metrics Report📊 View detailed coverage report (available for 7 days)
Details | | main (e4b5fb0) | #517 (5b29b0a) | +/- |
|---------------------|----------------|----------------|-------|
- | Coverage | 68.1% | 68.0% | -0.2% |
| Files | 55 | 55 | 0 |
| Lines | 5929 | 5959 | +30 |
+ | Covered | 4043 | 4053 | +10 |
- | Code to Test Ratio | 1:1.2 | 1:1.2 | -0.1 |
| Code | 13611 | 13683 | +72 |
+ | Test | 16960 | 17037 | +77 |
+ | Test Execution Time | 1m17s | 1m4s | -13s |Code coverage of files in pull request scope (65.0% → 64.2%)
Reported by octocov |
There was a problem hiding this comment.
Code Review
This pull request introduces a well-designed TTL-based caching mechanism for fuzzy finder candidates, which should significantly improve performance by reducing network calls. The implementation is clean and the cache invalidation logic correctly handles session changes, TTL expiry, and schema modifications via DDL. The addition of unit tests for the cache validation logic is also a great practice.
However, I've identified a critical data race on the new schemaGeneration field in the Session struct. The increment and read operations are not atomic, which could lead to incorrect cache behavior or panics in concurrent scenarios (e.g., fuzzy finder used during an async DDL). I've provided a suggestion to resolve this using the sync/atomic package, which is idiomatic for this use case.
Use sync/atomic for SchemaGeneration read and IncrementSchemaGeneration write to ensure thread safety as a defensive measure. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a TTL-based caching mechanism for fuzzy finder candidates, specifically for database and table completions, to reduce network calls and improve performance. The implementation correctly handles cache invalidation based on TTL, session changes, and schema modifications triggered by DDL statements. The use of an atomic counter for tracking schema generation is appropriate for ensuring thread safety. The new caching logic is also validated with a comprehensive set of unit tests. The changes are well-implemented and I have no issues to report.
|
/gemini summary |
Summary of ChangesThis pull request significantly enhances the performance and user experience of the fuzzy finder feature by introducing a robust caching mechanism for database and table completion candidates. By storing frequently accessed suggestions in a time-limited cache, it eliminates redundant network requests, leading to faster response times. The cache is intelligently invalidated upon schema modifications or session changes, ensuring data consistency without manual intervention. Highlights
Changelog
Activity
|
Summary
Add TTL-based caching for fuzzy completion candidates (databases and tables) to avoid repeated network calls when triggering fuzzy finders multiple times. Cached results are reused within a 30-second window unless invalidated by session changes or DDL execution.
Key Changes
schemaGeneration uint64field toSessionwithSchemaGeneration()/IncrementSchemaGeneration()accessors, providing a lightweight signal for schema-dependent cache invalidationfuzzyCacheEntrystruct with TTL + session pointer + schema generation validity checks; cache database and table candidates onfuzzyFinderCommand; short-circuitresolveCandidates()on cache hit (skips loading indicator and network call)TestFuzzyCacheEntryValidtable-driven test covering nil entry, session change, TTL expiry, valid cache, and stale schema generationCache Invalidation Triggers
time.Now().After(expiresAt)schemaGenerationcounter mismatchTest Plan
make checkpasses (test + lint + fmt-check)Fixes #514