You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2021/02/24 18:30:32 UTC

[GitHub] [lucene-solr] pawel-bugalski-dynatrace commented on pull request #2429: LUCENE-9791 Allow calling BytesRefHash#find concurrently

pawel-bugalski-dynatrace commented on pull request #2429:
URL: https://github.com/apache/lucene-solr/pull/2429#issuecomment-785282649


   > The problem is this change doesn't just impact find() like the description states, but also other things like add() getting called by TermsHashPerField, a hot spot of indexer. I don't think we should rely on oracle's C2 EA to not create monster amounts of garbage, this is too important of a spot.
   
   In that case we can easily implement `equals` without allocation.
   ```
   private boolean equals(int id, BytesRef b) {
     final int textStart = bytesStart[id];
     final byte[] bytes = pool.buffers[textStart >> BYTE_BLOCK_SHIFT];
     int pos = textStart & BYTE_BLOCK_MASK;
     final int length;
     final int offset;
     if ((bytes[pos] & 0x80) == 0) {
       // length is 1 byte
       length = bytes[pos];
       offset = pos + 1;
     } else {
       // length is 2 bytes
       length = (bytes[pos] & 0x7f) + ((bytes[pos + 1] & 0xff) << 7);
       offset = pos + 2;
     }
     return Arrays.equals(
         bytes,
         offset,
         offset + length,
         b.bytes,
         b.offset,
         b.offset + b.length);
   } 
   ```


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

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



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