You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "ChrisHegarty (via GitHub)" <gi...@apache.org> on 2024/07/05 17:45:43 UTC
[PR] Improve VectorUtil::xorBitCount perf on ARM [lucene]
ChrisHegarty opened a new pull request, #13545:
URL: https://github.com/apache/lucene/pull/13545
This commit improves the performance of `VectorUtil::xorBitCount` on ARM by ~4x.
This change is effectively a workaround for the lack of vectorization of `Long::bitCount` on ARM, see https://github.com/ChrisHegarty/hammingBench/. I'll get an issue filed against Hotspot for this.
On x64 there is no issue, the long variant of xorBitCount outperforms the int variant by ~15%.
Before (measures throughput in seconds, so bigger numbers are better)
```
Benchmark (dims) (nb) Mode Cnt Score Error Units
HammingDistanceBenchmark.xorBitCount 1024 1000000 thrpt 5 29.128 ± 5.697 ops/s
```
After
```
Benchmark (dims) (nb) Mode Cnt Score Error Units
HammingDistanceBenchmark.xorBitCount 1024 1000000 thrpt 5 115.430 ± 3.086 ops/s
```
--
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
Re: [PR] Improve VectorUtil::xorBitCount perf on ARM [lucene]
Posted by "ChrisHegarty (via GitHub)" <gi...@apache.org>.
ChrisHegarty commented on PR #13545:
URL: https://github.com/apache/lucene/pull/13545#issuecomment-2216914939
@uschindler Apologies, I didn't notice this when cherrypicking. Thanks for reverting (while I was sleeping ;-) )
--
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
Re: [PR] Improve VectorUtil::xorBitCount perf on ARM [lucene]
Posted by "uschindler (via GitHub)" <gi...@apache.org>.
uschindler commented on PR #13545:
URL: https://github.com/apache/lucene/pull/13545#issuecomment-2214846241
See: https://github.com/apache/lucene/commit/c8b4a76ecc93a98c779364b18f62c9b67552c192#diff-dd8d7417893f9b2fecaef29491b94d5daeaae6d496c4b21bb9633b4f7b060e59
--
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
Re: [PR] Improve VectorUtil::xorBitCount perf on ARM [lucene]
Posted by "uschindler (via GitHub)" <gi...@apache.org>.
uschindler commented on code in PR #13545:
URL: https://github.com/apache/lucene/pull/13545#discussion_r1669064660
##########
lucene/core/src/java/org/apache/lucene/util/VectorUtil.java:
##########
@@ -212,6 +212,14 @@ public static int int4DotProductPacked(byte[] unpacked, byte[] packed) {
return IMPL.int4DotProduct(unpacked, false, packed, true);
}
+ /**
+ * For xorBitCount we stride over the values as either 64-bits (long) or 32-bits (int) at a time.
+ * On ARM Long::bitCount is not vectorized, and therefore produces less than optimal code, when
+ * compared to Integer::bitCount. While Long::bitCount is optimal on x64. TODO: include the
+ * OpenJDK JIRA url
Review Comment:
Do you have the JIRA issue number already?
--
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
Re: [PR] Improve VectorUtil::xorBitCount perf on ARM [lucene]
Posted by "uschindler (via GitHub)" <gi...@apache.org>.
uschindler commented on PR #13545:
URL: https://github.com/apache/lucene/pull/13545#issuecomment-2214845553
Hi,
in the backport to 9.x the benchmark file was wrongly merged. It landed in the test directory. In 9.x we have no benchmark-jmh module in Gradle, so the file should have been left out while cherry-picking.
Can you remove the file in a followup commit?
--
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
Re: [PR] Improve VectorUtil::xorBitCount perf on ARM [lucene]
Posted by "ChrisHegarty (via GitHub)" <gi...@apache.org>.
ChrisHegarty merged PR #13545:
URL: https://github.com/apache/lucene/pull/13545
--
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
Re: [PR] Improve VectorUtil::xorBitCount perf on ARM [lucene]
Posted by "ChrisHegarty (via GitHub)" <gi...@apache.org>.
ChrisHegarty commented on code in PR #13545:
URL: https://github.com/apache/lucene/pull/13545#discussion_r1670333682
##########
lucene/core/src/java/org/apache/lucene/util/VectorUtil.java:
##########
@@ -212,6 +212,14 @@ public static int int4DotProductPacked(byte[] unpacked, byte[] packed) {
return IMPL.int4DotProduct(unpacked, false, packed, true);
}
+ /**
+ * For xorBitCount we stride over the values as either 64-bits (long) or 32-bits (int) at a time.
+ * On ARM Long::bitCount is not vectorized, and therefore produces less than optimal code, when
+ * compared to Integer::bitCount. While Long::bitCount is optimal on x64. TODO: include the
+ * OpenJDK JIRA url
Review Comment:
Oops. I just added it in https://github.com/apache/lucene/commit/4baaedaa67046adeed19cdc28a346c1ebc9e8b5d
https://bugs.openjdk.org/browse/JDK-8336000
--
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
Re: [PR] Improve VectorUtil::xorBitCount perf on ARM [lucene]
Posted by "uschindler (via GitHub)" <gi...@apache.org>.
uschindler commented on PR #13545:
URL: https://github.com/apache/lucene/pull/13545#issuecomment-2215482308
I reverted the addition of the file to 9.x branch: 86d080a4e0b4e53e0c9a3f2e2b120bff204c7276
--
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