-
Notifications
You must be signed in to change notification settings - Fork 125
Migrate from Guava Cache to Caffeine #808
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
base: main
Are you sure you want to change the base?
Conversation
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.
Pull request overview
This PR migrates the caching implementation from Guava Cache to Caffeine, a modern caching library with better performance characteristics. The migration affects two main classes: TrinoRequestUser and BaseRoutingManager, where cache loading logic is simplified and exception handling is updated to catch RuntimeException instead of ExecutionException.
Key Changes:
- Replaced Guava Cache imports with Caffeine cache imports
- Simplified cache loading syntax using method references
- Updated exception handling from
ExecutionExceptiontoRuntimeException
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| gateway-ha/src/main/java/io/trino/gateway/ha/router/TrinoRequestUser.java | Updated imports and simplified cache builder initialization with method reference |
| gateway-ha/src/main/java/io/trino/gateway/ha/router/BaseRoutingManager.java | Migrated cache implementation, removed redundant cache insertion calls, and simplified cache loader using method reference |
| gateway-ha/pom.xml | Added Caffeine dependency version 3.2.3 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Peiyingy
left a comment
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.
LGTM! Thanks so much for making this change
ebyhr
left a comment
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.
In Trino, we intentionally avoid Caffeine (see trinodb/trino#10512 (comment)). Please hold off on this PR until we reach consensus.
|
@ebyhr I don't think the discussion from that issue is relevant here. GW cache doesn't have any invalidations to be concerned about. Even if we did have such concerns, GW is using the plain Guava cache, not Trino's EvictableCache, so (a) we are already not standardized, and (b) the behavior will at least be improved when moving from Guava to Caffeine. I see two options here:
Leaving things as-is only provides the illusion of standardization across Trino / GW .. |
Description
Migrate from Guava Cache to Caffeine.
Motivation:
#783 (comment)
Additional context and related issues
Removed the call to
setRoutingGroupForQueryId()andsetExternalUrlForQueryId()becausecache.get()already insert the value into the cache if absent.Release notes
(x) This is not user-visible or is docs only, and no release notes are required.