prudhvigodithi commented on code in PR #16306:
URL: https://github.com/apache/lucene/pull/16306#discussion_r4725009493
##########
lucene/core/src/java/org/apache/lucene/search/UsageTrackingQueryCachingPolicy.java:
##########
@@ -90,7 +90,27 @@ private static boolean shouldNeverCache(Query query) {
return false;
}
- private final FrequencyTrackingRingBuffer recentlyUsedFilters;
+ /**
+ * Maximum number of stripes the usage history is split into. Stripes are
sized so that they hold
+ * between {@link #MIN_HISTORY_PER_STRIPE} and twice as many entries, which
keeps the linear scan
+ * in {@link Stripe#frequency} short for any history size up to {@code
MAX_STRIPES * 32}.
+ */
+ private static final int MAX_STRIPES = 1024;
+
+ /**
+ * Minimum number of entries per stripe. A query can never appear more often
in its stripe than
+ * the stripe has entries, so this must stay comfortably above {@link
#minFrequencyToCache}.
+ */
+ private static final int MIN_HISTORY_PER_STRIPE = 16;
Review Comment:
I tested this by replaying query streams through `LRUQueryCache` with one
hot query taking 10–50% of traffic and yes the hot query fills most of its
stripe, so the other queries in that stripe never reach 5 uses and never get
cached. With 16-entry stripes, 8–67% of those queries were never cached.
That's also what made `testBooleanQueries` fail on CI. Queries in other stripes
weren't affected, and the overall hit rate stayed within ±0.6pp of the stock
policy.
Fix tested is I raised the minimum stripe size from 16 to 32, so the default
is now 8 stripes × 32. That roughly halves the problem, and hit rates stay
level with stock.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]