chore(spanner): add key_recipe_cache - #6280
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces KeyRecipeCache, a thread-safe, concurrent cache for Spanner key recipes, separated by target type (tables, indexes, and queries) to enable zero-allocation lookups. The review feedback focuses on optimizing lock hold times and reducing lock contention within the cache. Specifically, it is recommended to perform deallocations of overwritten or cleared cache entries outside of the write lock by using std::mem::take and explicitly dropping the lock guard.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6280 +/- ##
========================================
Coverage 96.24% 96.25%
========================================
Files 280 281 +1
Lines 72146 72299 +153
========================================
+ Hits 69440 69593 +153
Misses 2706 2706 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
43e623e to
4b38fa2
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces KeyRecipeCache, a thread-safe, concurrent cache for Spanner key recipes (tables, indexes, and queries) backed by an RwLock over separate hash maps, along with comprehensive unit tests. The review feedback suggests refactoring the cache implementation by importing RwLockReadGuard and RwLockWriteGuard and introducing private helper methods read_store and write_store to centralize lock acquisition and error handling, which reduces code duplication across getter and setter methods.
4b38fa2 to
f88bee9
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a thread-safe KeyRecipeCache to store table, index, and query key recipes, enabling local binary routing key encoding. The cache is backed by an RwLock over separate hash maps to support concurrent, non-blocking reads, and includes comprehensive unit tests. The review feedback suggests renaming the getter methods (get_table_recipe, get_index_recipe, and get_query_recipe) to omit the get_ prefix, in accordance with the repository's style guide and idiomatic Rust conventions.
Adds a cache for KeyRecipe.