srowen commented on a change in pull request #14762:
URL: https://github.com/apache/spark/pull/14762#discussion_r776920110
##########
File path:
common/unsafe/src/main/java/org/apache/spark/unsafe/array/ByteArrayMethods.java
##########
@@ -40,24 +40,41 @@ public static int roundNumberOfBytesToNearestWord(int
numBytes) {
}
}
+ private static final boolean unaligned = Platform.unaligned();
/**
* Optimized byte array equality check for byte arrays.
* @return true if the arrays are equal, false otherwise
*/
public static boolean arrayEquals(
Object leftBase, long leftOffset, Object rightBase, long rightOffset,
final long length) {
int i = 0;
- while (i <= length - 8) {
- if (Platform.getLong(leftBase, leftOffset + i) !=
- Platform.getLong(rightBase, rightOffset + i)) {
- return false;
+
+ // check if stars align and we can get both offsets to be aligned
+ if ((leftOffset % 8) == (rightOffset % 8)) {
Review comment:
I think the idea was to avoid unaligned access even where it is
possible, as it used to be faster. I'm not sure it matters much now. Maybe more
on ARM. If there's evidence it's actually faster to skip this and not align,
OK. Otherwise without being sure I'd leave it at trying to align
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]