Leaderboard update

This commit is contained in:
Gunnar Morling
2024-01-04 18:22:13 +01:00
parent c3411f6023
commit 88b1c30db8
4 changed files with 36 additions and 29 deletions

View File

@@ -159,7 +159,8 @@ public class CalculateAverage_lawrey {
m.sample(temp / 10.0);
}
} catch (IOException ioe) {
}
catch (IOException ioe) {
throw new RuntimeException(ioe);
}
return map;
@@ -169,8 +170,7 @@ public class CalculateAverage_lawrey {
private static int readTemperatureFromBuffer(MappedByteBuffer mbb) {
int temp = 0;
boolean negative = false;
outer:
while (mbb.remaining() > 0) {
outer: while (mbb.remaining() > 0) {
byte b = mbb.get();
switch (b) {
case '-':

View File

@@ -87,8 +87,7 @@ public class CalculateAverage_richardstartin {
private final Table table = new Table(nextBaseIndex());
private static final AtomicIntegerFieldUpdater<Dictionary> BASE_INDEX_UPDATER =
AtomicIntegerFieldUpdater.newUpdater(Dictionary.class, "baseIndex");
private static final AtomicIntegerFieldUpdater<Dictionary> BASE_INDEX_UPDATER = AtomicIntegerFieldUpdater.newUpdater(Dictionary.class, "baseIndex");
volatile int baseIndex;
private void forEach(Table table, IndexedStringConsumer consumer) {
@@ -120,13 +119,15 @@ public class CalculateAverage_richardstartin {
if (storedKey == null) {
if (row.keys.compareAndSet(c, null, slice)) {
return table.index(rowIndex, c);
} else {
}
else {
storedKey = row.keys.get(c);
if (slice.equals(storedKey)) {
return table.index(rowIndex, c);
}
}
} else if (slice.equals(storedKey)) {
}
else if (slice.equals(storedKey)) {
return table.index(rowIndex, c);
}
}
@@ -141,8 +142,7 @@ public class CalculateAverage_richardstartin {
private static final class Row {
private static final AtomicReferenceFieldUpdater<Row, Table>
NEXT_TABLE_UPDATER = AtomicReferenceFieldUpdater.newUpdater(Row.class, Table.class, "next");
private static final AtomicReferenceFieldUpdater<Row, Table> NEXT_TABLE_UPDATER = AtomicReferenceFieldUpdater.newUpdater(Row.class, Table.class, "next");
private final AtomicReferenceArray<ByteBuffer> keys = new AtomicReferenceArray<>(CELLS);
volatile Table next;
@@ -152,7 +152,8 @@ public class CalculateAverage_richardstartin {
Table newTable = new Table(baseIndexSupplier.getAsInt());
if (NEXT_TABLE_UPDATER.compareAndSet(this, null, newTable)) {
next = newTable;
} else {
}
else {
next = this.next;
}
}
@@ -180,14 +181,16 @@ public class CalculateAverage_richardstartin {
private static long compilePattern(long repeat) {
return 0x101010101010101L * repeat;
}
private static long compilePattern(char delimiter) {
return compilePattern (delimiter & 0xFFL);
return compilePattern(delimiter & 0xFFL);
}
private static long compilePattern(byte delimiter) {
return compilePattern(delimiter & 0xFFL);
}
private static final long NEW_LINE = compilePattern((byte)'\n');
private static final long NEW_LINE = compilePattern((byte) '\n');
private static final long DELIMITER = compilePattern(';');
private static int firstInstance(long word, long pattern) {
@@ -311,11 +314,12 @@ public class CalculateAverage_richardstartin {
for (int i = 0; i < contribution.length; i++) {
if (aggregate[i] == null) {
aggregate[i] = contribution[i];
} else if (contribution[i] != null) {
}
else if (contribution[i] != null) {
double[] to = aggregate[i];
double[] from = contribution[i];
// todo won't vectorise - consider separating aggregates into distinct regions and apply
// loop fission (if this shows up in the profile)
// loop fission (if this shows up in the profile)
for (int j = 0; j < to.length; j += 4) {
to[j] += from[j];
to[j + 1] = Math.min(to[j + 1], from[j + 1]);
@@ -334,7 +338,8 @@ public class CalculateAverage_richardstartin {
var slice = slices.get(min);
computeSlice(slice, pages);
return pages;
} else {
}
else {
int mid = (min + max) / 2;
var low = new AggregationTask(dictionary, slices, min, mid);
var high = new AggregationTask(dictionary, slices, mid + 1, max);
@@ -349,7 +354,7 @@ public class CalculateAverage_richardstartin {
public static void main(String[] args) throws IOException {
int maxChunkSize = 250 << 20; // 250MiB
try (var raf = new RandomAccessFile(FILE, "r");
var channel = raf.getChannel()) {
var channel = raf.getChannel()) {
long size = channel.size();
// make as few mmap calls as possible subject to the 2GiB limit per buffer
List<ByteBuffer> rawBuffers = new ArrayList<>();