Tony-X commented on PR #12688:
URL: https://github.com/apache/lucene/pull/12688#issuecomment-1857380213

   ## Non-trivial amount of allocations for?  .... building IndexInput slice 
descriptions !?
   
   `jdk.internal.misc.Unsafe#allocateUninitializedArray()`. This was not 
trivial to find out why. But again with the raw JFR report, we can analyze the 
call tree. It turn out that in the [`buildSlice()` 
implementation](https://github.com/apache/lucene/blob/main/lucene/core/src/java21/org/apache/lucene/store/MemorySegmentIndexInput.java#L451)
 of `MemorySegmentIndexInput` we call 
[`IndexInput#getFullSliceDescription()`](https://github.com/apache/lucene/blob/main/lucene/core/src/java/org/apache/lucene/store/IndexInput.java#L128)
 which creates new String. And `allocateUninitializedArray` is called to 
allocate the bytes for the String. 
   
   AFAIK, the description is only used for debugging and tracking purposes. I 
didn't expect it'd cause that much of allocation. So I made a change to pass 
null when building the description so those allocations are gone. 
   
   
   ```
   Before 
   
   PERCENT       HEAP SAMPLES  STACK
   10.39%        12103M        java.lang.Long#valueOf()
   9.91%         11543M        
org.apache.lucene.facet.taxonomy.IntTaxonomyFacets#initializeValueCounters()
   8.91%         10383M        
jdk.internal.misc.Unsafe#allocateUninitializedArray()
   
   After
   PERCENT       HEAP SAMPLES  STACK                                            
                                                                                
  [37/1812]
   25.97%        32791M        java.lang.Long#valueOf()
   7.58%         9571M         
org.apache.lucene.facet.taxonomy.IntTaxonomyFacets#initializeValueCounters()
   5.13%         6482M         org.apache.lucene.util.FixedBitSet#<init>()
   
   ```
   


-- 
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: issues-unsubscr...@lucene.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to