[ 
https://issues.apache.org/jira/browse/LUCENE-10145?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17424051#comment-17424051
 ] 

Robert Muir commented on LUCENE-10145:
--------------------------------------

If you use the jdk Arrays method, it uses the mismatch which will get fancy as 
Uwe says. The problem is it doesn't start getting fancy unless the length 
exceeds a certain threshold (8):

https://github.com/openjdk/jdk/blob/739769c8fc4b496f08a92225a12d07414537b6c0/src/java.base/share/classes/jdk/internal/util/ArraysSupport.java#L170

So for the case of 4 (ints), the JDK method compares byte-by-byte, and it makes 
sense [~jpountz] change would be faster. For the case of 8, it may use the 
fancy stuff but then you have a lot of overhead since the code in use must 
handle arbitrary lengths.

> Use VarHandles to speedup byte[] comparisons in some cases
> ----------------------------------------------------------
>
>                 Key: LUCENE-10145
>                 URL: https://issues.apache.org/jira/browse/LUCENE-10145
>             Project: Lucene - Core
>          Issue Type: Improvement
>            Reporter: Adrien Grand
>            Priority: Minor
>             Fix For: main (9.0)
>
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> I noticed that using Long#compareUnsigned on longs read via VarHandles is 
> significantly faster than calling compareUnsigned directly. There are cases 
> when this could be leveraged easily such as BKDWriter, which often keeps 
> comparing 4-bytes or 8-bytes across byte[] arrays.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

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

Reply via email to