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 2024/11/02 22:37:29 UTC

[PR] SWEEP: Replace J2N's TripleShift call with C# 11's unsigned right shift operator [lucenenet]

paulirwin opened a new pull request, #1007:
URL: https://github.com/apache/lucenenet/pull/1007

   - [X] You've read the [Contributor Guide](https://github.com/apache/lucenenet/blob/main/CONTRIBUTING.md) and [Code of Conduct](https://www.apache.org/foundation/policies/conduct.html).
   - [X] You've included unit or integration tests for your change, where applicable.
   - [X] You've included inline docs for your change, where applicable.
   - [X] There's an open issue for the PR that you are making. If you'd like to propose a change, please [open an issue](https://github.com/apache/lucenenet/issues/new/choose) to discuss the change or find an existing issue.
   
   Replaces calls to J2N's TripleShift method with the C# 11 unsigned right shift operator (`>>>`)
   
   Fixes #1006
   
   ## Description
   
   This more closely matches the Java code, and should improve performance by avoiding method calls and reducing this operation down to one opcode.
   


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


Re: [PR] SWEEP: Replace J2N's TripleShift call with C# 11's unsigned right shift operator [lucenenet]

Posted by "paulirwin (via GitHub)" <gi...@apache.org>.
paulirwin merged PR #1007:
URL: https://github.com/apache/lucenenet/pull/1007


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


Re: [PR] SWEEP: Replace J2N's TripleShift call with C# 11's unsigned right shift operator [lucenenet]

Posted by "paulirwin (via GitHub)" <gi...@apache.org>.
paulirwin commented on PR #1007:
URL: https://github.com/apache/lucenenet/pull/1007#issuecomment-2453224152

   Need to run better benchmarks to be sure, but this seems to result in about a 7% reduction in time to run all the tests on Linux and macOS. Results are negligible on Windows.


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


Re: [PR] SWEEP: Replace J2N's TripleShift call with C# 11's unsigned right shift operator [lucenenet]

Posted by "NightOwl888 (via GitHub)" <gi...@apache.org>.
NightOwl888 commented on code in PR #1007:
URL: https://github.com/apache/lucenenet/pull/1007#discussion_r1826935488


##########
src/Lucene.Net/Util/FixedBitSet.cs:
##########
@@ -641,7 +641,7 @@ public void Set(int startIndex, int endIndex)
             int endWord = (endIndex - 1) >> 6;
 
             long startmask = -1L << startIndex;
-            long endmask = (-1L).TripleShift(-endIndex); // 64-(endIndex&0x3f) is the same as -endIndex due to wrap
+            long endmask = (-1L) >>> -endIndex; // 64-(endIndex&0x3f) is the same as -endIndex due to wrap

Review Comment:
   The parentheses were added here to ensure the correct value (including the - sign) was passed to `TripleShift()`. They weren't in the original code. If we can get by without them, they can be removed.
   
   https://github.com/apache/lucene/blob/releases/lucene-solr/4.8.0/lucene/core/src/java/org/apache/lucene/util/FixedBitSet.java#L531
   



##########
src/Lucene.Net/Util/OpenBitSet.cs:
##########
@@ -466,7 +466,7 @@ public virtual void Clear(long startIndex, long endIndex) // LUCENENET TODO: API
             int endWord = (int)((endIndex - 1) >> 6);
 
             long startmask = -1L << (int)startIndex;
-            long endmask = (-1L).TripleShift((int)-endIndex); // 64-(endIndex&0x3f) is the same as -endIndex due to wrap
+            long endmask = (-1L) >>> ((int)-endIndex); // 64-(endIndex&0x3f) is the same as -endIndex due to wrap

Review Comment:
   The parentheses were added here to ensure the correct value (including the - sign) was passed to `TripleShift()`. They weren't in the original code. If we can get by without them, they can be removed.
   
   https://github.com/apache/lucene/blob/releases/lucene-solr/4.8.0/lucene/core/src/java/org/apache/lucene/util/OpenBitSet.java#L362



##########
src/Lucene.Net/Util/FixedBitSet.cs:
##########
@@ -602,7 +602,7 @@ public void Flip(int startIndex, int endIndex)
             */
 
             long startmask = -1L << startIndex;
-            long endmask = (-1L).TripleShift(-endIndex); // 64-(endIndex&0x3f) is the same as -endIndex due to wrap
+            long endmask = (-1L) >>> -endIndex; // 64-(endIndex&0x3f) is the same as -endIndex due to wrap

Review Comment:
   The parentheses were added here to ensure the correct value (including the - sign) was passed to `TripleShift()`. They weren't in the original code. If we can get by without them, they can be removed.
   
   https://github.com/apache/lucene/blob/releases/lucene-solr/4.8.0/lucene/core/src/java/org/apache/lucene/util/FixedBitSet.java#L499
   



##########
src/Lucene.Net/Util/Packed/BulkOperationPacked12.cs:
##########
@@ -1,7 +1,5 @@
 // this file has been automatically generated, DO NOT EDIT

Review Comment:
   Not applicable to this PR, but perhaps we should look into generating these as it was upstream so there is less code to maintain.



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


Re: [PR] SWEEP: Replace J2N's TripleShift call with C# 11's unsigned right shift operator [lucenenet]

Posted by "paulirwin (via GitHub)" <gi...@apache.org>.
paulirwin commented on code in PR #1007:
URL: https://github.com/apache/lucenenet/pull/1007#discussion_r1827081371


##########
src/Lucene.Net/Util/Packed/BulkOperationPacked12.cs:
##########
@@ -1,7 +1,5 @@
 // this file has been automatically generated, DO NOT EDIT

Review Comment:
   Split out as #1008 



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