sgup432 commented on code in PR #15124:
URL: https://github.com/apache/lucene/pull/15124#discussion_r2357174971


##########
lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java:
##########
@@ -426,10 +425,8 @@ public void clear() {
   }
 
   private static long getRamBytesUsed(Query query) {
-    return LINKED_HASHTABLE_RAM_BYTES_PER_ENTRY
-        + (query instanceof Accountable accountableQuery
-            ? accountableQuery.ramBytesUsed()
-            : QUERY_DEFAULT_RAM_BYTES_USED);
+    long queryRamBytesUsed = RamUsageEstimator.sizeOf(query, 0);
+    return LINKED_HASHTABLE_RAM_BYTES_PER_ENTRY + queryRamBytesUsed;

Review Comment:
   Seems like I was doing 
   ```
   long queryRamBytesUsed = RamUsageEstimator.sizeOf(query, 0);
   ```
   
   `long sizeOf(Query q, long defSize) ` Here defSize represents the shallow 
size of the query, and if 0 is passed, it calculates the shallow size during 
runtime which was doing a lot of object allocations(adding to higher CPU%) and 
therefore adding to latency.
   
   I changed to `RamUsageEstimator.sizeOf(query, 32);`, Here 32 is a rough 
shallow bytes for a term/boolean query which I calculated manually by calling 
that method
   
   After running with above change, performance improved but still 2.5x slower 
than the baseline.
   ```
   Benchmark                               Mode  Cnt        Score        Error  
Units
   QueryCacheBenchmark.concurrentPutOnly  thrpt   15  1608680.127 ± 229218.026  
ops/s
   ```



-- 
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]

Reply via email to