You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucenenet.apache.org by "paulirwin (via GitHub)" <gi...@apache.org> on 2026/04/28 18:48:13 UTC
[I] Optimize NumericUtils.Int64ToPrefixCodedBytes [lucenenet]
paulirwin opened a new issue, #1280:
URL: https://github.com/apache/lucenenet/issues/1280
See this line:
https://github.com/apache/lucenenet/blob/9a1bf2e04a21b48fcad633b1f0c9318c0a6a8d4c/src/Lucene.Net/Util/NumericUtils.cs#L163
This was found during code review to do an unnecessary `byte[]` allocation and memory read, when the upstream Java code is just:
https://github.com/apache/lucene/blob/f01152a5909fa6059f4f1d4aeb4e14968ef1d8c2/lucene/core/src/java/org/apache/lucene/util/NumericUtils.java#L146
I'm guessing this was due to that XOR'ed literal being outside the range of C#'s long, instead of wrapping around to long's min value like it does in Java, combined with unsigned right shift not being available at the time. We should be able to replace this with:
```c#
long sortableBits = val ^ long.MinValue;
```
... and the shifts below it to use the unsigned right shift assignment operator (`>>>=`) to match upstream.
Per the comment, this change should be benchmarked to see what the impact is, but removing the array allocation and memory read should be significant.
Filing this issue to track it, but I've already got a prototype locally and will PR this myself. Initial microbenchmark results of this method are 2-3x faster than beta 17, but I think there's even room to go further.
--
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: dev-unsubscribe@lucenenet.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Optimize NumericUtils.Int64ToPrefixCodedBytes [lucenenet]
Posted by "paulirwin (via GitHub)" <gi...@apache.org>.
paulirwin closed issue #1280: Optimize NumericUtils.Int64ToPrefixCodedBytes
URL: https://github.com/apache/lucenenet/issues/1280
--
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: dev-unsubscribe@lucenenet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org