From b529ef2a59c7df8f435ff7b1fc91362457180498 Mon Sep 17 00:00:00 2001 From: Roman Stoffel Date: Wed, 31 Jan 2024 18:13:08 +0100 Subject: [PATCH] Gamlerhart Last Update: Disabling GC (#636) * Disable The GC Cuts off sometimes up to 1 seconds of runtime on my machine. * Remove Confusing Byte-Order Parameter Bytes have no Byte-Order ;) * Provide More Memory to Run the 10K set * Fix Comparison Function --- calculate_average_gamlerhart.sh | 2 +- .../dev/morling/onebrc/CalculateAverage_gamlerhart.java | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/calculate_average_gamlerhart.sh b/calculate_average_gamlerhart.sh index c52a25bfb..7427ea657 100755 --- a/calculate_average_gamlerhart.sh +++ b/calculate_average_gamlerhart.sh @@ -15,5 +15,5 @@ # limitations under the License. # -JAVA_OPTS="--enable-preview --add-modules=jdk.incubator.vector" +JAVA_OPTS="--enable-preview --add-modules=jdk.incubator.vector -XX:+UnlockExperimentalVMOptions -XX:+UseEpsilonGC -Xmx512m -Xlog:all=error" java $JAVA_OPTS --class-path target/average-1.0.0-SNAPSHOT.jar dev.morling.onebrc.CalculateAverage_gamlerhart diff --git a/src/main/java/dev/morling/onebrc/CalculateAverage_gamlerhart.java b/src/main/java/dev/morling/onebrc/CalculateAverage_gamlerhart.java index 5d0a4bdbb..4d44494b9 100644 --- a/src/main/java/dev/morling/onebrc/CalculateAverage_gamlerhart.java +++ b/src/main/java/dev/morling/onebrc/CalculateAverage_gamlerhart.java @@ -31,8 +31,7 @@ import static java.lang.Double.doubleToRawLongBits; import static java.lang.Double.longBitsToDouble; -import static java.lang.foreign.ValueLayout.JAVA_BYTE; -import static java.lang.foreign.ValueLayout.JAVA_LONG_UNALIGNED; +import static java.lang.foreign.ValueLayout.*; /** * Broad experiments in this implementation: @@ -242,7 +241,7 @@ else if (isSameEntry(file, slotEntry, pos, len)) { private boolean isSameEntry(MemorySegment file, long slotEntry, long pos, int len) { long keyPos = (slotEntry & MASK_POS) >> SHIFT_POS; int keyLen = (int) (slotEntry & MASK_LEN); - var isSame = isSame(file, keyPos, pos, len); + var isSame = len == keyLen && isSame(file, keyPos, pos, len); return isSame; } @@ -251,8 +250,8 @@ private static boolean isSame(MemorySegment file, long i1, long i2, int len) { var i1len = i1 + vecLen; var i2len = i2 + vecLen; if (len < vecLen && i1len <= file.byteSize() && i2len <= file.byteSize()) { - var v1 = byteVec.fromMemorySegment(file, i1, ByteOrder.BIG_ENDIAN); - var v2 = byteVec.fromMemorySegment(file, i2, ByteOrder.BIG_ENDIAN); + var v1 = byteVec.fromMemorySegment(file, i1, ByteOrder.nativeOrder()); + var v2 = byteVec.fromMemorySegment(file, i2, ByteOrder.nativeOrder()); var isTrue = v1.compare(VectorOperators.EQ, v2, allTrue.indexInRange(0, len)); return isTrue.trueCount() == len; }