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 2022/12/10 15:41:39 UTC

[GitHub] [lucene] gf2121 opened a new pull request, #12006: Do int compare instead of ArrayUtil#compareUnsigned4 in LatlonPointQueries

gf2121 opened a new pull request, #12006:
URL: https://github.com/apache/lucene/pull/12006

   In LatLonPointQueries we encode query ints to bytes, and compare bytes by decode bytes back to int in `ArrayUtil#compareUnsigned4`. We can directly compare ints instead.


-- 
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-unsubscribe@lucene.apache.org

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


[GitHub] [lucene] iverase commented on pull request #12006: Do int compare instead of ArrayUtil#compareUnsigned4 in LatlonPointQueries

Posted by GitBox <gi...@apache.org>.
iverase commented on PR #12006:
URL: https://github.com/apache/lucene/pull/12006#issuecomment-1350678308

   > If it gives a good speedup, we could think about applying the same trick to other queries too, if we can do it without making things too ugly. For example LatLonPoint, IntPoint, etc currently all use byte[] comparison for their range/bounding-box queries.
   
   +1


-- 
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-unsubscribe@lucene.apache.org

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


[GitHub] [lucene] gf2121 commented on pull request #12006: Do int compare instead of ArrayUtil#compareUnsigned4 in LatlonPointQueries

Posted by GitBox <gi...@apache.org>.
gf2121 commented on PR #12006:
URL: https://github.com/apache/lucene/pull/12006#issuecomment-1345297296

   Thanks @rmuir for feedback! This is the current implementation of `ArrayUtil#compareUnsigned4`:
   
   ```
   public static int compareUnsigned4(byte[] a, int aOffset, byte[] b, int bOffset) {
     return Integer.compareUnsigned(
         (int) BitUtil.VH_BE_INT.get(a, aOffset), (int) BitUtil.VH_BE_INT.get(b, bOffset));
   }
   ```
   
   I think it's equivalent to
   ```
   public static int compareUnsigned4(byte[] a, int aOffset, byte[] b, int bOffset) {
     return Integer.compare(NumericUtils.sortableBytesToInt(a, aOffset), NumericUtils.sortableBytesToInt(b, bOffset));
   }
   ```
   
   Because they are both doing a varhandle get and compare unsigned. The point of this PR is to avoid the decoding of one side as the query values are consistent during the intersect. 
   
   I'll do some JMH benchmark to confirm if there is any speed up.


-- 
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-unsubscribe@lucene.apache.org

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


[GitHub] [lucene] gf2121 merged pull request #12006: Do int compare instead of ArrayUtil#compareUnsigned4 in LatlonPointQueries

Posted by GitBox <gi...@apache.org>.
gf2121 merged PR #12006:
URL: https://github.com/apache/lucene/pull/12006


-- 
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-unsubscribe@lucene.apache.org

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


[GitHub] [lucene] rmuir commented on pull request #12006: Do int compare instead of ArrayUtil#compareUnsigned4 in LatlonPointQueries

Posted by GitBox <gi...@apache.org>.
rmuir commented on PR #12006:
URL: https://github.com/apache/lucene/pull/12006#issuecomment-1345341579

   makes sense to me, as numericutils is basically just varhandle fetch with an xor. thanks for testing.


-- 
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-unsubscribe@lucene.apache.org

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


[GitHub] [lucene] gf2121 commented on pull request #12006: Do int compare instead of ArrayUtil#compareUnsigned4 in LatlonPointQueries

Posted by GitBox <gi...@apache.org>.
gf2121 commented on PR #12006:
URL: https://github.com/apache/lucene/pull/12006#issuecomment-1345303453

   Here is the JMH result:
   ```
   Benchmark                                      Mode  Cnt  Score   Error   Units
   ReadInts24Benchmark.compareUnsigned4          thrpt   10  0.224 ± 0.003  ops/us
   ReadInts24Benchmark.numericUtilDecode         thrpt   10  0.224 ± 0.006  ops/us
   ReadInts24Benchmark.numericUtilDecodeOneSide  thrpt   10  0.995 ± 0.006  ops/us
   ```
   
   * compareUnsigned4 is using `Integer.compareUnsigned((int) BitUtil.VH_BE_INT.get(a, aOffset), (int) BitUtil.VH_BE_INT.get(b, bOffset));`
   
   * numericUtilDecode is using `Integer.compare(NumericUtils.sortableBytesToInt(a, aOffset), NumericUtils.sortableBytesToInt(b, bOffset));`
   
   * numericUtilDecodeOneSide is using `aValue > NumericUtils.sortableBytesToInt(b, bOffset)`


-- 
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-unsubscribe@lucene.apache.org

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


[GitHub] [lucene] rmuir commented on pull request #12006: Do int compare instead of ArrayUtil#compareUnsigned4 in LatlonPointQueries

Posted by GitBox <gi...@apache.org>.
rmuir commented on PR #12006:
URL: https://github.com/apache/lucene/pull/12006#issuecomment-1345293418

   @gf2121 does this execute faster? I think originally the reason `byte[]` was compared, was that it avoided having to "decode" values with `NumericUtils.sortableBytesToInt`.
   
   But, maybe this `NumericUtils.sortableBytesToInt` method has become faster now that it is implemented with varhandle.


-- 
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-unsubscribe@lucene.apache.org

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


[GitHub] [lucene] gf2121 commented on pull request #12006: Do int compare instead of ArrayUtil#compareUnsigned4 in LatlonPointQueries

Posted by GitBox <gi...@apache.org>.
gf2121 commented on PR #12006:
URL: https://github.com/apache/lucene/pull/12006#issuecomment-1350639546

   This brings a small jump for Distance Filter LatLonPoint task. http://people.apache.org/~mikemccand/geobench.html


-- 
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-unsubscribe@lucene.apache.org

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