From ab9d64b3e384f252de13ad058cd33c305439713d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Merino=20Garc=C3=ADa?= Date: Fri, 12 Jan 2024 19:02:31 +0100 Subject: [PATCH] second try: just testing with the chunk size and gc tunning --- calculate_average_imrafaelmerino.sh | 4 ++-- .../dev/morling/onebrc/CalculateAverage_imrafaelmerino.java | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/calculate_average_imrafaelmerino.sh b/calculate_average_imrafaelmerino.sh index 162a308..58b72a2 100755 --- a/calculate_average_imrafaelmerino.sh +++ b/calculate_average_imrafaelmerino.sh @@ -15,7 +15,7 @@ # limitations under the License. # -JAVA_OPTS="" -CHUNK_SIZE=$((8 * 1024 * 1024)) +JAVA_OPTS="-Xms1024m -Xms1024m -XX:+UseParallelGC -XX:MaxHeapFreeRatio=10 -XX:ParallelGCThreads=2" +CHUNK_SIZE=$((50 * 1024 * 1024)) java $JAVA_OPTS --class-path target/average-1.0.0-SNAPSHOT.jar \ dev.morling.onebrc.CalculateAverage_imrafaelmerino $CHUNK_SIZE diff --git a/src/main/java/dev/morling/onebrc/CalculateAverage_imrafaelmerino.java b/src/main/java/dev/morling/onebrc/CalculateAverage_imrafaelmerino.java index 303e9ff..4777fd9 100644 --- a/src/main/java/dev/morling/onebrc/CalculateAverage_imrafaelmerino.java +++ b/src/main/java/dev/morling/onebrc/CalculateAverage_imrafaelmerino.java @@ -144,6 +144,7 @@ public class CalculateAverage_imrafaelmerino { var field = new byte[FIELD_SIZE]; while (bb.position() < limit) { var fieldCurrentIndex = 0; + field[fieldCurrentIndex++] = bb.get(); while (bb.position() < limit) { var fieldByte = bb.get(); if (fieldByte == ';')