Repository navigation
Conversation
Reuse filter parameters for repeated calls to the same method. Keep separate bounded caches for client and server rules so dynamic method names cannot grow either cache without limit.
Use access order to evict the least recently used method. Synchronize map access and keep filter matching outside the lock because concurrent misses compute equivalent results.
Use ConcurrentHashMap for lookups so cache hits avoid the shared LRU lock. Serialize misses and maintain insertion order to bound each cache and reuse results from concurrent misses.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Cache log filter decisions by full RPC method name to avoid scanning the same rules on repeated calls. Client and server each have a separate FIFO cache capped at 1,024 entries.
Hits read from a
ConcurrentHashMapwithout acquiring the cache lock. On a miss, the cache rechecks the key under the lock, evaluates the filters, and evicts the oldest entry if the cache is full. The first matching rule still determines whether to log and which payload limits to use.Benchmark
Compared
master(bbadd4ebd) with FIFO (aa8c2d125) using JMH 1.37 on an Apple M3 Pro with JDK 21. Each scenario used one sharedConfigFilterHelperand eight rules, with the last rule matching. Hit scenarios repeatedly queried one warmed method. In miss scenarios, each thread cycled through 4,096 distinct methods, forcing a miss and eviction on every FIFO lookup in steady state.Repeated lookups benefit from caching, while sustained misses serialize rule matching and eviction on the shared cache lock. These measurements cover
logRpcMethod()in isolation.