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
This commit is contained in:
Roman Stoffel 2024-01-31 18:13:08 +01:00 committed by GitHub
parent 3cc4fc85d8
commit b529ef2a59
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 6 deletions

View File

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

View File

@ -31,8 +31,7 @@ import java.util.stream.Collectors;
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 @@ public class CalculateAverage_gamlerhart {
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 @@ public class CalculateAverage_gamlerhart {
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;
}