replace cached with moka for caching#4418
Conversation
There was a problem hiding this comment.
Code Review
This pull request replaces the cached crate with moka for strategy caching within the balance-overrides crate. It introduces a thread-safe Cache wrapper around moka::sync::Cache, eliminating the need for manual Mutex management in the approval and balance detectors. No critical issues found.
|
As this is a performance improvement (which we've discussed before) what would be your testing plan for this? Where would you put metrics before and after so that I could ship both to prod and measure between the two? |
5b3ed18 to
872c9a0
Compare
|
Good point. I put together a separate branch for benchmarking/instrumentation work so I didn’t have to bloat the main PR with experimental code. Branch: It includes:
The synthetic concurrent-read benchmark came out around:
Benchmark command: cargo test -p balance-overrides compare_moka_vs_mutex_cache -- --ignored --nocaptureThough I understand the real validation still needs to come from production metrics rather than the local benchmark itself. Do these sound like the right signals to monitor? |
Description
Replaces
cached::SizedCachewithmoka::sync::Cacheinbalance-overrides.cached::SizedCacherequired external synchronization viaMutex, whilemoka::sync::Cacheis internally concurrent and allows direct cache access without locking boilerplate.Changes
cache.rswrapper aroundmoka::sync::Cache<K, V>Mutex<SizedCache<K, V>>withCache<K, V>lock().unwrap()and migratedcache_get/cache_settocache.get()/insert()cachedand cleaned up related transitive dependencies.insert()calls