Skip to content

Commit

Permalink
Gamlerhart Last Update: Disabling GC (#636)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
gamlerhart authored Jan 31, 2024
1 parent 3cc4fc8 commit b529ef2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion calculate_average_gamlerhart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}
Expand Down

0 comments on commit b529ef2

Please sign in to comment.