Commit Graph

361 Commits

Author SHA1 Message Date
Jaroslav Bachorik
865188ccee
Small improvements (#379) 2024-01-14 14:12:19 +01:00
Vemana
f11fad2a68
Submission #5 [No bitwise tricks nor Unsafe yet; 13th place on leaderboard in local testing using evaluate2.sh] (#209)
* Linear probe for city indexing. Beats current leader spullara 2.2 vs 3.8 elapsed time.

* Straightforward impl using bytebuffers. Turns out memorysegments were slower than used mappedbytebuffers.

* A initial submit-worthy entry

Comparison to select entries (averaged over 3 runs)
* spullara 1.66s [5th on leaderboard currently]
* vemana (this submission) 1.65s
* artsiomkorzun 1.64s [4th on leaderboard currently]

Tests: PASS
Impl Class: dev.morling.onebrc.CalculateAverage_vemana

Machine specs
* 16 core Ryzen 7950X
* 128GB RAM

Description
* Decompose the full file into Shards of memory mapped files and process
  each independently, outputting a TreeMap: City -> Statistics
* Compose the final answer by merging the individual TreeMap outputs
* Select 1 Thread per available processor as reported by the JVM
* Size to fit all datastructure in 0.5x L3 cache (4MB/core on the
  evaluation machines)
* Use linear probing hash table, with identity of city name = byte[] and
  hash code computed inline
* Avoid all allocation in the hot path and instead use method
  parameters. So, instead of passing a single Object param called Point(x, y, z),
  pass 3 parameters for each of its components. It is ugly, but this
  challenge is so far from Java's idioms anyway
* G1GC seems to want to interfere; use ParallelGC instead (just a quick
  and dirty hack)

Things tried that did not work
* MemorySegments are actually slower than MappedByteBuffers
* Trying to inline everything: not needed; the JIT compiler is pretty
  good
* Playing with JIT compiler flags didn't yield clear wins. In
  particular, was surprised that using a max level of 3 and reducing
  compilation threshold did nothing.. when the jit logs print that none
  of the methods reach level 4 and stay there for long
* Hand-coded implementation of Array.equals(..) using
  readLong(..) & bitmask_based_on_length from a bytebuffer instead of byte by byte

* Further tuning to compile loop methods: timings are now consistenctly ahead of artsiomkorzun in 4th place.

There are methods on the data path that were being interpreted for far
too long. For example, the method that takes a byte range and simply
calls one method per line was taking a disproportionate amount of time.
Using `-XX:+AlwaysCompileLoopMethods` option improved completion time by 4%.

============= vemana ===============
[20:55:22] [lsv@vemana]$ for i in 1 2 3 4 5; do ./runTheir.sh vemana;
done;

Using java version 21.0.1-graal in this shell.

real    0m1.581s
user    0m34.166s
sys     0m1.435s

Using java version 21.0.1-graal in this shell.

real    0m1.593s
user    0m34.629s
sys     0m1.470s

Using java version 21.0.1-graal in this shell.

real    0m1.632s
user    0m35.893s
sys     0m1.340s

Using java version 21.0.1-graal in this shell.

real    0m1.596s
user    0m33.074s
sys     0m1.386s

Using java version 21.0.1-graal in this shell.

real    0m1.611s
user    0m35.516s
sys     0m1.438s

============= artsiomkorzun ===============
[20:56:12] [lsv@vemana]$ for i in 1 2 3 4 5; do ./runTheir.sh
artsiomkorzun; done;

Using java version 21.0.1-graal in this shell.

real    0m1.669s
user    0m38.043s
sys     0m1.287s

Using java version 21.0.1-graal in this shell.

real    0m1.679s
user    0m37.840s
sys     0m1.400s

Using java version 21.0.1-graal in this shell.

real    0m1.657s
user    0m37.607s
sys     0m1.298s

Using java version 21.0.1-graal in this shell.

real    0m1.643s
user    0m36.852s
sys     0m1.392s

Using java version 21.0.1-graal in this shell.

real    0m1.644s
user    0m36.951s
sys     0m1.279s

============= spullara ===============
[20:57:55] [lsv@vemana]$ for i in 1 2 3 4 5; do ./runTheir.sh spullara;
done;

Using java version 21.0.1-graal in this shell.

real    0m1.676s
user    0m37.404s
sys     0m1.386s

Using java version 21.0.1-graal in this shell.

real    0m1.652s
user    0m36.509s
sys     0m1.486s

Using java version 21.0.1-graal in this shell.

real    0m1.665s
user    0m36.451s
sys     0m1.506s

Using java version 21.0.1-graal in this shell.

real    0m1.671s
user    0m36.917s
sys     0m1.371s

Using java version 21.0.1-graal in this shell.

real    0m1.634s
user    0m35.624s
sys     0m1.573s

========================== Running Tests ======================

[21:17:57] [lsv@vemana]$ ./runTests.sh vemana
Validating calculate_average_vemana.sh --
src/test/resources/samples/measurements-10000-unique-keys.txt

Using java version 21.0.1-graal in this shell.

real    0m0.150s
user    0m1.035s
sys     0m0.117s
Validating calculate_average_vemana.sh --
src/test/resources/samples/measurements-10.txt

Using java version 21.0.1-graal in this shell.

real    0m0.114s
user    0m0.789s
sys     0m0.116s
Validating calculate_average_vemana.sh --
src/test/resources/samples/measurements-1.txt

Using java version 21.0.1-graal in this shell.

real    0m0.115s
user    0m0.948s
sys     0m0.075s
Validating calculate_average_vemana.sh --
src/test/resources/samples/measurements-20.txt

Using java version 21.0.1-graal in this shell.

real    0m0.113s
user    0m0.926s
sys     0m0.066s
Validating calculate_average_vemana.sh --
src/test/resources/samples/measurements-2.txt

Using java version 21.0.1-graal in this shell.

real    0m0.110s
user    0m0.734s
sys     0m0.078s
Validating calculate_average_vemana.sh --
src/test/resources/samples/measurements-3.txt

Using java version 21.0.1-graal in this shell.

real    0m0.114s
user    0m0.870s
sys     0m0.095s
Validating calculate_average_vemana.sh --
src/test/resources/samples/measurements-boundaries.txt

Using java version 21.0.1-graal in this shell.

real    0m0.113s
user    0m0.843s
sys     0m0.084s
Validating calculate_average_vemana.sh --
src/test/resources/samples/measurements-complex-utf8.txt

Using java version 21.0.1-graal in this shell.

real    0m0.121s
user    0m0.852s
sys     0m0.171s

* Improve by a few % more; now, convincingly faster than 6th place
submission. So far, only algorithms and tuning; no bitwise tricks yet.

Improve chunking implementation to avoid allocation and allow
finegrained chunking for the last X% of work. Work now proceeds in two
stages: big chunk stage and small chunk stage. This is to avoid
straggler threads holding up result merging.

Tests pass

[07:14:49] [lsv@vemana]$ ./test.sh vemana
Validating calculate_average_vemana.sh --
src/test/resources/samples/measurements-10000-unique-keys.txt

Using java version 21.0.1-graal in this shell.

real    0m0.152s
user    0m0.973s
sys     0m0.107s
Validating calculate_average_vemana.sh --
src/test/resources/samples/measurements-10.txt

Using java version 21.0.1-graal in this shell.

real    0m0.113s
user    0m0.840s
sys     0m0.060s
Validating calculate_average_vemana.sh --
src/test/resources/samples/measurements-1.txt

Using java version 21.0.1-graal in this shell.

real    0m0.107s
user    0m0.681s
sys     0m0.085s
Validating calculate_average_vemana.sh --
src/test/resources/samples/measurements-20.txt

Using java version 21.0.1-graal in this shell.

real    0m0.105s
user    0m0.894s
sys     0m0.068s
Validating calculate_average_vemana.sh --
src/test/resources/samples/measurements-2.txt

Using java version 21.0.1-graal in this shell.

real    0m0.099s
user    0m0.895s
sys     0m0.068s
Validating calculate_average_vemana.sh --
src/test/resources/samples/measurements-3.txt

Using java version 21.0.1-graal in this shell.

real    0m0.098s
user    0m0.813s
sys     0m0.050s
Validating calculate_average_vemana.sh --
src/test/resources/samples/measurements-boundaries.txt

Using java version 21.0.1-graal in this shell.

real    0m0.095s
user    0m0.777s
sys     0m0.087s
Validating calculate_average_vemana.sh --
src/test/resources/samples/measurements-complex-utf8.txt

Using java version 21.0.1-graal in this shell.

real    0m0.112s
user    0m0.904s
sys     0m0.069s

* Merge results from finished threads instead of waiting for all threads
to finish.

Not a huge difference overall but no reason to wait.

Also experiment with a few other compiler flags and attempt to use
jitwatch to understand what the jit is doing.

* Move to prepare_*.sh format and run evaluate2.sh locally.

Shows 7th place in leaderboard

| # | Result (m:s.ms) | Implementation     | JDK | Submitter     | Notes
|
|---|-----------------|--------------------|-----|---------------|-----------|
| 1 | 00:01.588 |
[link](https://github.com/gunnarmorling/1brc/blob/main/src/main/java/dev/morling/onebrc/CalculateAverage_thomaswue.java)|
21.0.1-graal | [Thomas Wuerthinger](https://github.com/thomaswue) |
   GraalVM native binary |
| 2 | 00:01.866 |
[link](https://github.com/gunnarmorling/1brc/blob/main/src/main/java/dev/morling/onebrc/CalculateAverage_merykitty.java)|
21.0.1-open | [Quan Anh Mai](https://github.com/merykitty) |  |
| 3 | 00:01.904 |
[link](https://github.com/gunnarmorling/1brc/blob/main/src/main/java/dev/morling/onebrc/CalculateAverage_royvanrijn.java)|
21.0.1-graal | [Roy van Rijn](https://github.com/royvanrijn) |  |
|   | 00:02.398 |
[link](https://github.com/gunnarmorling/1brc/blob/main/src/main/java/dev/morling/onebrc/CalculateAverage_ebarlas.java)|
21.0.1-graal | [Elliot Barlas](https://github.com/ebarlas) |  |
|   | 00:02.724 |
[link](https://github.com/gunnarmorling/1brc/blob/main/src/main/java/dev/morling/onebrc/CalculateAverage_obourgain.java)|
21.0.1-open | [Olivier Bourgain](https://github.com/obourgain) |  |
|   | 00:02.771 |
[link](https://github.com/gunnarmorling/1brc/blob/main/src/main/java/dev/morling/onebrc/CalculateAverage_algirdasrascius.java)|
21.0.1-open | [Algirdas Ra__ius](https://github.com/algirdasrascius) |
   |
|   | 00:02.842 |
[link](https://github.com/gunnarmorling/1brc/blob/main/src/main/java/dev/morling/onebrc/CalculateAverage_vemana.java)|
21.0.1-graal | [Vemana](https://github.com/vemana) |  |
|   | 00:02.902 |
[link](https://github.com/gunnarmorling/1brc/blob/main/src/main/java/dev/morling/onebrc/CalculateAverage_spullara.java)|
21.0.1-graal | [Sam Pullara](https://github.com/spullara) |  |
|   | 00:02.906 |
[link](https://github.com/gunnarmorling/1brc/blob/main/src/main/java/dev/morling/onebrc/CalculateAverage_artsiomkorzun.java)|
21.0.1-graal | [artsiomkorzun](https://github.com/artsiomkorzun) |  |
|   | 00:02.970 |
[link](https://github.com/gunnarmorling/1brc/blob/main/src/main/java/dev/morling/onebrc/CalculateAverage_isolgpus.java)|
21.0.1-open | [Jamie Stansfield](https://github.com/isolgpus) |  |

* Tune chunksize to get another 2% improvement for 8 processors as used by
the evaluation script.

* Read int at a time for city name length detection; speeds up by 2% in local testing.

* Improve reading temperature double by exiting loop quicker; no major
tricks (like reading an int) yet, but good for 5th place on leaderboard in local testing.

This small change has caused a surprising gain in performance by about 4%.
I didn't expect such a big change, but perhaps in combination with the
earlier change to read int by int for the city name, temperature reading
is dominating that aspect of the time. Also, perhaps the quicker exit
(as soon as you see '.' instead of reading until '\n') means you get to
simply skip reading the '\n' across each of the lines. Since the lines
are on average like 15 characters, it may be that avoiding reading the \n
is a meaningful saving. Or maybe the JIT found a clever optimization for
reading the temperature.

Or maybe it is simply the case that the number of multiplications is now
down to 2 from the previous 3 is what's causing the performance gain?

| # | Result (m:s.ms) | Implementation     | JDK | Submitter     | Notes
|
|---|-----------------|--------------------|-----|---------------|-----------|
| 1 | 00:01.531 |
[link](https://github.com/gunnarmorling/1brc/blob/main/src/main/java/dev/morling/onebrc/CalculateAverage_thomaswue.java)|
21.0.1-graal | [Thomas Wuerthinger](https://github.com/thomaswue) |
   GraalVM native binary |
| 2 | 00:01.794 |
[link](https://github.com/gunnarmorling/1brc/blob/main/src/main/java/dev/morling/onebrc/CalculateAverage_royvanrijn.java)|
21.0.1-graal | [Roy van Rijn](https://github.com/royvanrijn) |  |
| 3 | 00:01.956 |
[link](https://github.com/gunnarmorling/1brc/blob/main/src/main/java/dev/morling/onebrc/CalculateAverage_merykitty.java)|
21.0.1-open | [Quan Anh Mai](https://github.com/merykitty) |  |
|   | 00:02.346 |
[link](https://github.com/gunnarmorling/1brc/blob/main/src/main/java/dev/morling/onebrc/CalculateAverage_ebarlas.java)|
21.0.1-graal | [Elliot Barlas](https://github.com/ebarlas) |  |
|   | 00:02.673 |
[link](https://github.com/gunnarmorling/1brc/blob/main/src/main/java/dev/morling/onebrc/CalculateAverage_vemana.java)|
21.0.1-graal | [Subrahmanyam](https://github.com/vemana) |  |
|   | 00:02.689 |
[link](https://github.com/gunnarmorling/1brc/blob/main/src/main/java/dev/morling/onebrc/CalculateAverage_obourgain.java)|
21.0.1-open | [Olivier Bourgain](https://github.com/obourgain) |  |
|   | 00:02.785 |
[link](https://github.com/gunnarmorling/1brc/blob/main/src/main/java/dev/morling/onebrc/CalculateAverage_algirdasrascius.java)|
21.0.1-open | [Algirdas Ra__ius](https://github.com/algirdasrascius) |
   |
|   | 00:02.926 |
[link](https://github.com/gunnarmorling/1brc/blob/main/src/main/java/dev/morling/onebrc/CalculateAverage_isolgpus.java)|
21.0.1-open | [Jamie Stansfield](https://github.com/isolgpus) |  |
|   | 00:02.928 |
[link](https://github.com/gunnarmorling/1brc/blob/main/src/main/java/dev/morling/onebrc/CalculateAverage_artsiomkorzun.java)|
21.0.1-graal | [Artsiom Korzun](https://github.com/artsiomkorzun) |  |
|   | 00:02.932 |
[link](https://github.com/gunnarmorling/1brc/blob/main/src/main/java/dev/morling/onebrc/CalculateAverage_spullara.java)|
21.0.1-graal | [Sam Pullara](https://github.com/spullara) |  |

* Reduce one multiplication when temperature is +ve.

* Linear probe for city indexing. Beats current leader spullara 2.2 vs 3.8 elapsed time.

* Straightforward impl using bytebuffers. Turns out memorysegments were slower than used mappedbytebuffers.

* A initial submit-worthy entry

Comparison to select entries (averaged over 3 runs)
* spullara 1.66s [5th on leaderboard currently]
* vemana (this submission) 1.65s
* artsiomkorzun 1.64s [4th on leaderboard currently]

Tests: PASS
Impl Class: dev.morling.onebrc.CalculateAverage_vemana

Machine specs
* 16 core Ryzen 7950X
* 128GB RAM

Description
* Decompose the full file into Shards of memory mapped files and process
  each independently, outputting a TreeMap: City -> Statistics
* Compose the final answer by merging the individual TreeMap outputs
* Select 1 Thread per available processor as reported by the JVM
* Size to fit all datastructure in 0.5x L3 cache (4MB/core on the
  evaluation machines)
* Use linear probing hash table, with identity of city name = byte[] and
  hash code computed inline
* Avoid all allocation in the hot path and instead use method
  parameters. So, instead of passing a single Object param called Point(x, y, z),
  pass 3 parameters for each of its components. It is ugly, but this
  challenge is so far from Java's idioms anyway
* G1GC seems to want to interfere; use ParallelGC instead (just a quick
  and dirty hack)

Things tried that did not work
* MemorySegments are actually slower than MappedByteBuffers
* Trying to inline everything: not needed; the JIT compiler is pretty
  good
* Playing with JIT compiler flags didn't yield clear wins. In
  particular, was surprised that using a max level of 3 and reducing
  compilation threshold did nothing.. when the jit logs print that none
  of the methods reach level 4 and stay there for long
* Hand-coded implementation of Array.equals(..) using
  readLong(..) & bitmask_based_on_length from a bytebuffer instead of byte by byte

* Further tuning to compile loop methods: timings are now consistenctly ahead of artsiomkorzun in 4th place.

There are methods on the data path that were being interpreted for far
too long. For example, the method that takes a byte range and simply
calls one method per line was taking a disproportionate amount of time.
Using `-XX:+AlwaysCompileLoopMethods` option improved completion time by 4%.

============= vemana ===============
[20:55:22] [lsv@vemana]$ for i in 1 2 3 4 5; do ./runTheir.sh vemana;
done;

Using java version 21.0.1-graal in this shell.

real    0m1.581s
user    0m34.166s
sys     0m1.435s

Using java version 21.0.1-graal in this shell.

real    0m1.593s
user    0m34.629s
sys     0m1.470s

Using java version 21.0.1-graal in this shell.

real    0m1.632s
user    0m35.893s
sys     0m1.340s

Using java version 21.0.1-graal in this shell.

real    0m1.596s
user    0m33.074s
sys     0m1.386s

Using java version 21.0.1-graal in this shell.

real    0m1.611s
user    0m35.516s
sys     0m1.438s

============= artsiomkorzun ===============
[20:56:12] [lsv@vemana]$ for i in 1 2 3 4 5; do ./runTheir.sh
artsiomkorzun; done;

Using java version 21.0.1-graal in this shell.

real    0m1.669s
user    0m38.043s
sys     0m1.287s

Using java version 21.0.1-graal in this shell.

real    0m1.679s
user    0m37.840s
sys     0m1.400s

Using java version 21.0.1-graal in this shell.

real    0m1.657s
user    0m37.607s
sys     0m1.298s

Using java version 21.0.1-graal in this shell.

real    0m1.643s
user    0m36.852s
sys     0m1.392s

Using java version 21.0.1-graal in this shell.

real    0m1.644s
user    0m36.951s
sys     0m1.279s

============= spullara ===============
[20:57:55] [lsv@vemana]$ for i in 1 2 3 4 5; do ./runTheir.sh spullara;
done;

Using java version 21.0.1-graal in this shell.

real    0m1.676s
user    0m37.404s
sys     0m1.386s

Using java version 21.0.1-graal in this shell.

real    0m1.652s
user    0m36.509s
sys     0m1.486s

Using java version 21.0.1-graal in this shell.

real    0m1.665s
user    0m36.451s
sys     0m1.506s

Using java version 21.0.1-graal in this shell.

real    0m1.671s
user    0m36.917s
sys     0m1.371s

Using java version 21.0.1-graal in this shell.

real    0m1.634s
user    0m35.624s
sys     0m1.573s

========================== Running Tests ======================

[21:17:57] [lsv@vemana]$ ./runTests.sh vemana
Validating calculate_average_vemana.sh --
src/test/resources/samples/measurements-10000-unique-keys.txt

Using java version 21.0.1-graal in this shell.

real    0m0.150s
user    0m1.035s
sys     0m0.117s
Validating calculate_average_vemana.sh --
src/test/resources/samples/measurements-10.txt

Using java version 21.0.1-graal in this shell.

real    0m0.114s
user    0m0.789s
sys     0m0.116s
Validating calculate_average_vemana.sh --
src/test/resources/samples/measurements-1.txt

Using java version 21.0.1-graal in this shell.

real    0m0.115s
user    0m0.948s
sys     0m0.075s
Validating calculate_average_vemana.sh --
src/test/resources/samples/measurements-20.txt

Using java version 21.0.1-graal in this shell.

real    0m0.113s
user    0m0.926s
sys     0m0.066s
Validating calculate_average_vemana.sh --
src/test/resources/samples/measurements-2.txt

Using java version 21.0.1-graal in this shell.

real    0m0.110s
user    0m0.734s
sys     0m0.078s
Validating calculate_average_vemana.sh --
src/test/resources/samples/measurements-3.txt

Using java version 21.0.1-graal in this shell.

real    0m0.114s
user    0m0.870s
sys     0m0.095s
Validating calculate_average_vemana.sh --
src/test/resources/samples/measurements-boundaries.txt

Using java version 21.0.1-graal in this shell.

real    0m0.113s
user    0m0.843s
sys     0m0.084s
Validating calculate_average_vemana.sh --
src/test/resources/samples/measurements-complex-utf8.txt

Using java version 21.0.1-graal in this shell.

real    0m0.121s
user    0m0.852s
sys     0m0.171s

* Improve by a few % more; now, convincingly faster than 6th place
submission. So far, only algorithms and tuning; no bitwise tricks yet.

Improve chunking implementation to avoid allocation and allow
finegrained chunking for the last X% of work. Work now proceeds in two
stages: big chunk stage and small chunk stage. This is to avoid
straggler threads holding up result merging.

Tests pass

[07:14:49] [lsv@vemana]$ ./test.sh vemana
Validating calculate_average_vemana.sh --
src/test/resources/samples/measurements-10000-unique-keys.txt

Using java version 21.0.1-graal in this shell.

real    0m0.152s
user    0m0.973s
sys     0m0.107s
Validating calculate_average_vemana.sh --
src/test/resources/samples/measurements-10.txt

Using java version 21.0.1-graal in this shell.

real    0m0.113s
user    0m0.840s
sys     0m0.060s
Validating calculate_average_vemana.sh --
src/test/resources/samples/measurements-1.txt

Using java version 21.0.1-graal in this shell.

real    0m0.107s
user    0m0.681s
sys     0m0.085s
Validating calculate_average_vemana.sh --
src/test/resources/samples/measurements-20.txt

Using java version 21.0.1-graal in this shell.

real    0m0.105s
user    0m0.894s
sys     0m0.068s
Validating calculate_average_vemana.sh --
src/test/resources/samples/measurements-2.txt

Using java version 21.0.1-graal in this shell.

real    0m0.099s
user    0m0.895s
sys     0m0.068s
Validating calculate_average_vemana.sh --
src/test/resources/samples/measurements-3.txt

Using java version 21.0.1-graal in this shell.

real    0m0.098s
user    0m0.813s
sys     0m0.050s
Validating calculate_average_vemana.sh --
src/test/resources/samples/measurements-boundaries.txt

Using java version 21.0.1-graal in this shell.

real    0m0.095s
user    0m0.777s
sys     0m0.087s
Validating calculate_average_vemana.sh --
src/test/resources/samples/measurements-complex-utf8.txt

Using java version 21.0.1-graal in this shell.

real    0m0.112s
user    0m0.904s
sys     0m0.069s

* Merge results from finished threads instead of waiting for all threads
to finish.

Not a huge difference overall but no reason to wait.

Also experiment with a few other compiler flags and attempt to use
jitwatch to understand what the jit is doing.

* Move to prepare_*.sh format and run evaluate2.sh locally.

Shows 7th place in leaderboard

| # | Result (m:s.ms) | Implementation     | JDK | Submitter     | Notes
|
|---|-----------------|--------------------|-----|---------------|-----------|
| 1 | 00:01.588 |
[link](https://github.com/gunnarmorling/1brc/blob/main/src/main/java/dev/morling/onebrc/CalculateAverage_thomaswue.java)|
21.0.1-graal | [Thomas Wuerthinger](https://github.com/thomaswue) |
   GraalVM native binary |
| 2 | 00:01.866 |
[link](https://github.com/gunnarmorling/1brc/blob/main/src/main/java/dev/morling/onebrc/CalculateAverage_merykitty.java)|
21.0.1-open | [Quan Anh Mai](https://github.com/merykitty) |  |
| 3 | 00:01.904 |
[link](https://github.com/gunnarmorling/1brc/blob/main/src/main/java/dev/morling/onebrc/CalculateAverage_royvanrijn.java)|
21.0.1-graal | [Roy van Rijn](https://github.com/royvanrijn) |  |
|   | 00:02.398 |
[link](https://github.com/gunnarmorling/1brc/blob/main/src/main/java/dev/morling/onebrc/CalculateAverage_ebarlas.java)|
21.0.1-graal | [Elliot Barlas](https://github.com/ebarlas) |  |
|   | 00:02.724 |
[link](https://github.com/gunnarmorling/1brc/blob/main/src/main/java/dev/morling/onebrc/CalculateAverage_obourgain.java)|
21.0.1-open | [Olivier Bourgain](https://github.com/obourgain) |  |
|   | 00:02.771 |
[link](https://github.com/gunnarmorling/1brc/blob/main/src/main/java/dev/morling/onebrc/CalculateAverage_algirdasrascius.java)|
21.0.1-open | [Algirdas Ra__ius](https://github.com/algirdasrascius) |
   |
|   | 00:02.842 |
[link](https://github.com/gunnarmorling/1brc/blob/main/src/main/java/dev/morling/onebrc/CalculateAverage_vemana.java)|
21.0.1-graal | [Vemana](https://github.com/vemana) |  |
|   | 00:02.902 |
[link](https://github.com/gunnarmorling/1brc/blob/main/src/main/java/dev/morling/onebrc/CalculateAverage_spullara.java)|
21.0.1-graal | [Sam Pullara](https://github.com/spullara) |  |
|   | 00:02.906 |
[link](https://github.com/gunnarmorling/1brc/blob/main/src/main/java/dev/morling/onebrc/CalculateAverage_artsiomkorzun.java)|
21.0.1-graal | [artsiomkorzun](https://github.com/artsiomkorzun) |  |
|   | 00:02.970 |
[link](https://github.com/gunnarmorling/1brc/blob/main/src/main/java/dev/morling/onebrc/CalculateAverage_isolgpus.java)|
21.0.1-open | [Jamie Stansfield](https://github.com/isolgpus) |  |

* Tune chunksize to get another 2% improvement for 8 processors as used by
the evaluation script.

* Read int at a time for city name length detection; speeds up by 2% in local testing.

* Improve reading temperature double by exiting loop quicker; no major
tricks (like reading an int) yet, but good for 5th place on leaderboard in local testing.

This small change has caused a surprising gain in performance by about 4%.
I didn't expect such a big change, but perhaps in combination with the
earlier change to read int by int for the city name, temperature reading
is dominating that aspect of the time. Also, perhaps the quicker exit
(as soon as you see '.' instead of reading until '\n') means you get to
simply skip reading the '\n' across each of the lines. Since the lines
are on average like 15 characters, it may be that avoiding reading the \n
is a meaningful saving. Or maybe the JIT found a clever optimization for
reading the temperature.

Or maybe it is simply the case that the number of multiplications is now
down to 2 from the previous 3 is what's causing the performance gain?

| # | Result (m:s.ms) | Implementation     | JDK | Submitter     | Notes
|
|---|-----------------|--------------------|-----|---------------|-----------|
| 1 | 00:01.531 |
[link](https://github.com/gunnarmorling/1brc/blob/main/src/main/java/dev/morling/onebrc/CalculateAverage_thomaswue.java)|
21.0.1-graal | [Thomas Wuerthinger](https://github.com/thomaswue) |
   GraalVM native binary |
| 2 | 00:01.794 |
[link](https://github.com/gunnarmorling/1brc/blob/main/src/main/java/dev/morling/onebrc/CalculateAverage_royvanrijn.java)|
21.0.1-graal | [Roy van Rijn](https://github.com/royvanrijn) |  |
| 3 | 00:01.956 |
[link](https://github.com/gunnarmorling/1brc/blob/main/src/main/java/dev/morling/onebrc/CalculateAverage_merykitty.java)|
21.0.1-open | [Quan Anh Mai](https://github.com/merykitty) |  |
|   | 00:02.346 |
[link](https://github.com/gunnarmorling/1brc/blob/main/src/main/java/dev/morling/onebrc/CalculateAverage_ebarlas.java)|
21.0.1-graal | [Elliot Barlas](https://github.com/ebarlas) |  |
|   | 00:02.673 |
[link](https://github.com/gunnarmorling/1brc/blob/main/src/main/java/dev/morling/onebrc/CalculateAverage_vemana.java)|
21.0.1-graal | [Subrahmanyam](https://github.com/vemana) |  |
|   | 00:02.689 |
[link](https://github.com/gunnarmorling/1brc/blob/main/src/main/java/dev/morling/onebrc/CalculateAverage_obourgain.java)|
21.0.1-open | [Olivier Bourgain](https://github.com/obourgain) |  |
|   | 00:02.785 |
[link](https://github.com/gunnarmorling/1brc/blob/main/src/main/java/dev/morling/onebrc/CalculateAverage_algirdasrascius.java)|
21.0.1-open | [Algirdas Ra__ius](https://github.com/algirdasrascius) |
   |
|   | 00:02.926 |
[link](https://github.com/gunnarmorling/1brc/blob/main/src/main/java/dev/morling/onebrc/CalculateAverage_isolgpus.java)|
21.0.1-open | [Jamie Stansfield](https://github.com/isolgpus) |  |
|   | 00:02.928 |
[link](https://github.com/gunnarmorling/1brc/blob/main/src/main/java/dev/morling/onebrc/CalculateAverage_artsiomkorzun.java)|
21.0.1-graal | [Artsiom Korzun](https://github.com/artsiomkorzun) |  |
|   | 00:02.932 |
[link](https://github.com/gunnarmorling/1brc/blob/main/src/main/java/dev/morling/onebrc/CalculateAverage_spullara.java)|
21.0.1-graal | [Sam Pullara](https://github.com/spullara) |  |

* Reduce one multiplication when temperature is +ve.

* Added some documentation on the approach.

---------

Co-authored-by: vemana <vemana.github@gmail.com>
2024-01-14 14:07:03 +01:00
Ragnar Groot Koerkamp
b56f2205c2 Update CreateMeasurements3.java to write measurements3.txt
Currently it overwrites measurements.txt which is a bit confusing.
2024-01-14 14:00:10 +01:00
Cliff Click
14a0100265
BRC Entry (#185)
* BRC Entry

* Fix test cases

* Fix last bug, a little re-org

* Now with Unsafe!

* A little more Unsafe
2024-01-14 11:08:55 +01:00
Gunnar Morling
7816e32b7b #49 Fixing rounding behavior of baseline implementation 2024-01-14 10:59:24 +01:00
Marko Topolnik
8d389a907b Add rounding error test case 2024-01-14 10:59:24 +01:00
Elliot Barlas
d608f14886 Consider file size when calculating partition count. Add simple fast-path optimization to equals method. 2024-01-14 10:24:52 +01:00
Kidlike
c01668403a
submission for kidlike (#294)
* first version

* second version (0m59s)

* third version (0m46s)

* fourth version (0m39s)

* fifth version (0m18s)

* follow naming conventions from project structure

* fix rounding (see /issues/49)

* formatting changes from build

* name should case-match github username

* sixth version (14s)

* seventh version (11s)

* potential fix for other systems?

* no need for sdk install

* binary should go to ./target

* building native-image only when not existing yet
2024-01-13 22:22:36 +01:00
Vasily Zernin
32143b2a4c change chunking formula and some refactoring 2024-01-13 22:13:05 +01:00
jairo
4265c7e9a8 simultaneous reading and calculation, reduction of memory consumption, hashing for the stations 2024-01-13 22:11:33 +01:00
abeobk
b2a4b73c59 use all CPUs 2024-01-13 22:04:34 +01:00
ivanklaric
05fe916948
my 1brc entry (#367) 2024-01-13 22:02:36 +01:00
Jatin Gala
47103cd84e
1brc challange submission jatingala (#364)
* add code

* enable parallel

* fix code warnings

* use graal vm

* formatting changes by build

* add license
2024-01-13 21:44:42 +01:00
javamak
e5540214b8
CalculateAverage_javamak (#360) 2024-01-13 21:41:42 +01:00
Vaidhy Mayilrangam
33c614a1e3
Primitive hash (#345)
* Calculate average by vaidhy

* Calculate average by vaidhy

* More changes

* remove worker log

* Pass -Dparellelism and switch back to open

* Try out mmap

* Improve mmap solution

* no copy version

* reduce threads

* hash code computed on the fly

* Reuse the char (Do not know if it helps)

* primitive hash map

* Primite HashMap

* Micro optimizations to push for optimizations

* Revert "Micro optimizations to push for optimizations"

This reverts commit ea333e2821ebb5c1d6d71a4e87e569a8f2f8f7f0.

* Micro optimizations to get the juice

* floorMod fixes

* findSemi and findNewLine as separate functions

* Optimized parseDouble

* More micro changes

* Aligned equal check

* more small changes

* XOR instead of compare

* Reduce loop length

* Revert changes

* Loop optimization and added native build

* Hand unrolled findSemi loop.

* Remove incorrect comments

* Taking care fo PR comments

* Add prepare script

* Missing header error fix

* remove wrong comment

---------

Co-authored-by: Anita S V <anitasvasu@gmail.com>
Co-authored-by: Anita SV <anitvasu@amazon.com>
2024-01-13 18:46:51 +01:00
Bang NGUYEN
dc49249d36
[Attempt #2] String overflow hash + data/mem optimization (#356)
* Use graal

* Use dynamic cores computer

* Use stream API to cleanup code

* Use max processors

* Use hash to avoid init string

* optimize concurrentmap init

* Smaller hash size

* Avoid checking concurrentmap

* Optimize data type

* string dedup

* Faster write

* Change base

* Remove time

* Use mul instead of div
2024-01-13 12:32:17 +01:00
Oleh Marchenko
e1ae96f297
First version of implementation - omarchenko4j (#222)
* First version of implementation

* Fixes after running script test
2024-01-13 11:52:17 +01:00
Roman Musin
092132afe9
roman-r-m improved version (#368)
* remove unneeded check

* slightly improved hash code perf

* Use unsafe to access memory + untangle the code a bit

* Adhoc cache that works a bit better

* Store station names as offset into the memory segment + length; slightly change how the hash is calculated
2024-01-13 11:46:52 +01:00
Roman Stoffel
062f424c10 Parallelize Roman Stoffel (gamlerhart) Solution
Split the file in regions. Parse those in parallel.
Then merge the result
2024-01-13 11:40:34 +01:00
Andrew Sun
69ffa8e04c Rename files to match GitHub username 2024-01-13 11:29:27 +01:00
Gunnar Morling
457c263a34 Formatting 2024-01-12 22:26:55 +01:00
Maxime
79f19eee9b
first attempt (#226)
* first attempt

* adapted to new organization
2024-01-12 21:39:12 +01:00
Gunnar Morling
4cfb5449e9 Leaderboard, formatting 2024-01-12 21:21:40 +01:00
abeobk
53776398dc abeobk initial implementation 2024-01-12 21:15:47 +01:00
Rafael Merino García
ab9d64b3e3 second try: just testing with the chunk size and gc tunning 2024-01-12 21:11:44 +01:00
Xylitol
9e5ec51315 Improved my implementation 2024-01-12 21:09:02 +01:00
Dr Ian Preston
b93b128cb8
Add CalculateAverage_ianopolous.java (#346)
* Add solution by ianopolous - simple, memory mapped, reduced allocation, no unsafe.

* remove almost all allocation
2024-01-12 21:04:43 +01:00
Roy van Rijn
9227aa5062
Locally another 5% faster, much faster for larger set, made more general (#352) 2024-01-12 21:00:12 +01:00
Thomas Wuerthinger
bd4cff945d
Adding Scanner object and also tuning for better branch prediction for about +6%. (#341) 2024-01-12 20:51:22 +01:00
Andrew Sun
dac38bc97f
Optimizations to Andrew Sun's entry (#310)
Squashed commit of the following:

commit 44d3736de87834b41118d45831e59fc2b052117c
Merge: fcf795f 3127962
Author: Andrew Sun <as-com@users.noreply.github.com>
Date:   Thu Jan 11 20:01:13 2024 -0500

    Merge branch 'gunnarmorling:main' into as-com

commit fcf795fbabacbd91891d11d21450ee4b1c479dc5
Author: Andrew Sun <me@andrewsun.com>
Date:   Wed Jan 10 21:14:01 2024 -0500

    Optimizations to Andrew Sun's entry

commit 4203924711bab5252ff3cbb50a90f4ce4e8e67c2
Merge: 9aed05a 085168a
Author: Andrew Sun <me@andrewsun.com>
Date:   Wed Jan 10 19:40:19 2024 -0500

    Merge remote-tracking branch 'upstream/main' into as-com

commit 9aed05a04bd27fe7323e66c347b1011c77da322c
Merge: 3f8df58 c2d120f
Author: Andrew Sun <me@andrewsun.com>
Date:   Sun Jan 7 16:45:27 2024 -0500

    Merge remote-tracking branch 'origin/as-com' into as-com

    # Conflicts:
    #	calculate_average_asun.sh
    #	src/main/java/dev/morling/onebrc/CalculateAverage_asun.java

commit c2d120f0cb7f18c720a81a7f898102b310f9ecb9
Author: Andrew Sun <me@andrewsun.com>
Date:   Sat Jan 6 00:45:47 2024 -0500

    Add entry by Andrew Sun

commit 3f8df5803bcc8f3e29ed8bfff3077eb0e8cdab15
Author: Andrew Sun <me@andrewsun.com>
Date:   Sat Jan 6 00:45:47 2024 -0500

    Add entry by Andrew Sun
2024-01-12 20:42:22 +01:00
John Ziamos
90cd353fbe
this hashmap was faster on my system (#304)
use cursor style parsing thing
2024-01-12 20:39:16 +01:00
Thanh Duong
9d10724abc
1brc submission - thanhtrinity (#269)
* Add Calculation

* Update hashing remove abs and use 0x7FFFFFFF

* Collision Handling using Linear Prob

* Refactor code
2024-01-12 20:36:44 +01:00
Samuel Yvon
22b960ada2
Graal Native for SamuelYvon (#332)
* Graal Native

* I need a GC :(

* Fix slash lolz

* Fix god damn output lol

I forgot java :D

* Custom hash, custom key

* More optimisations

* I don't need "optimize-build"

I don't care about image size! :D
2024-01-12 20:16:13 +01:00
Quan Anh Mai
dad698d3df unsafe approach 2024-01-12 18:39:12 +01:00
zerninv
06f9b74829
use unsafe (#343) 2024-01-12 09:54:28 +01:00
Roman Romanchuk
594f6c4e5f
Lazy strings init, custom station map (#336) 2024-01-12 09:52:32 +01:00
Yavuz Tas
10f425e2b6
I optimized my solution: (#337)
- Eliminate redundant object creations in between
 - Custom HashMap on purpose - Inspired by @spullara
 - More performant temperature parsing - Inspired by @yemreinci
 - JVM tweaks, decreased heap memory, and remove AlwaysPreTouch

Co-authored-by: Yavuz Tas <yavuz.tas@ing.com>
2024-01-12 09:47:31 +01:00
Parth Mudgal
f37b304fc3
inline hash calculation and number parsing (#200)
no number parsing with precalculated map
verify tests
better loop with direct hash to measurement mapping
accept formatting changes
Use unsafe
2024-01-12 09:38:09 +01:00
Bang NGUYEN
af1946fcb5
[Attempt 1] Memory mapping + split by linebreak + multithreads + fast double parser (#330)
* Create clones

* Cleanup code and add memory mapping to read file

* Fix chunks reading logic to fit linebreak

* Remove unused

* Sequential

* Multi thread process chunks

* Add new line in output

* Remove unnecessary operation with map & reducer memory

* Reduce mem usage by using only 1 map

* formatting

* Remove unnecessary length check

* Remove trycatch

* Optimize double parsing
2024-01-12 09:35:35 +01:00
Gunnar Morling
3c465cecf9 Leaderboard, class name 2024-01-12 09:21:29 +01:00
Richard Startin
37a50cb2af
update richardstartin submission (#325) 2024-01-12 09:06:09 +01:00
Jason Nochlin
6181996678
hundredwatt - 2nd submission (#338)
* check full hash before comparing

* implement merykitty suggestions to simplify temperature masking; required refactoring to little-endian

* standalone script for offline Perfect Hash seed searching

* stop using an oversized hash table

---------

Co-authored-by: Jason Nochlin <hundredwatt@users.noreply.github.com>
2024-01-12 09:03:31 +01:00
Gunnar Morling
bf2b553d9c Formatting 2024-01-11 22:16:01 +01:00
Ricardo Pieper
263b272028
First attempt from ricardopieper, class CalculateAverage_ricardopieper (#306)
* My entry

* Added scripts

* Fix for unicode chars

* Formatting

* Clarifying comment

* Perf improvements

* Fixing bugs

* Fixing tests

* Deleted second file

* Added license

* Cleanup and windows support
2024-01-11 22:14:13 +01:00
Jaroslav Bachorik
ce6abf9740
Submission @jbachorik (#153)
* Submission @jbachorik

* Submission @jbachorik (take 2)

* Fix test failure

* Submission @jbachorik (take 2)

* Submission @jbachorik (take 2)
part 2

* Second reincarnation

* Launcher tweaks

* Rebase and fix new tests
2024-01-11 22:03:44 +01:00
Xylitol
7c79f235d2
Initial implementation by xylitol (#318) 2024-01-11 21:57:23 +01:00
zerninv
0e420f99e2
use custom container (#305) 2024-01-11 21:53:51 +01:00
parkertimmins
bd2f7f7a53
First deployed version for parkertimmins (#322)
Version notes:
        - simd search with overlapping words, at most one entry/semicolon parsed per simd word
        - branchless temperature parsing
2024-01-11 21:46:08 +01:00
Roy van Rijn
4d0586142c
Adding delayed string creation again for (no-) gc, small tweaks (#315) 2024-01-11 21:38:06 +01:00
Jairo Graterón
20e52aaadf
Divide the reading of the file by parts (#254)
* divide the reading of the file by parts

* fix format

* add number of core partition

* fix format

* implement strToDouble

* fix strtodouble

* add locale, fix read file, tests pass

* delete unnecessary method clean
2024-01-11 21:22:58 +01:00
Anthony Goubard
11a740c5d0
One HashMap per thread: 23" to 18" locally but hopefully more on the server (#319) 2024-01-11 21:11:08 +01:00
Artsiom Korzun
8ef8cd2b17
improved artsiomkorzun solution (#321) 2024-01-11 21:08:15 +01:00
Keshavram Kuduwa
1a82c77026
Optimised Code and Fixed Tests (#314)
Co-authored-by: Keshavram Kuduwa <keshavram.kuduwa@apptware.com>
2024-01-11 21:04:50 +01:00
Hallvard Trætteberg
7b4ad1a723
Uses MappedByteBuffer for io, trie instead of map and parallelStream (#234)
* Uses MappedByteBuffer for io, trie instead of map and parallelStream

* Added license
2024-01-11 20:58:42 +01:00
Eve
4b870e6fcb
djb2 single threaded implementation (#308) 2024-01-11 20:50:51 +01:00
Samuel Yvon
56b2a6b53b
First Version (#292)
* First Version

First draft; stole chunking but it's bad

Forgot my changes

No regex building

Clean & optim

I was not benchmarking myself T_T

Faaaster

First Version

* Update calculate_average_samuelyvon.sh

Co-authored-by: Gunnar Morling <gunnar.morling@googlemail.com>

* Add prepare script

* Fix rounding

* Fix format

* Fixing casing

* Formats of sorts?

* Rename

---------

Co-authored-by: Gunnar Morling <gunnar.morling@googlemail.com>
2024-01-11 20:37:08 +01:00
Marko Topolnik
95459f5640
Entry into the contest, calculate_average_mtopolnik.sh (#246)
* calculate_average_mtopolnik

* short hash (just first 8 bytes of name)

* Remove unneeded checks

* Remove archiving classes

* 2x larger hashtable

* Add "set" to setters

* Simplify parsing temperature, remove newline search

* Reduce the size of the name slot

* Store name length and use to detect collision

* Reduce memory loads in parseTemperature

* Use short for min/max

* Extract constant for semicolon

* Fix script header

* Explicit bash shell in shebang

* Inline usage of broadcast semicolon

* Try vectorization

* Remove vectorization

* Go Unsafe

* Use SWAR temperature parsing by merykitty

* Inline some things

* Remove commented-out MemorySegment usage

* Inline namesMem.asSlice() invocation

* Try out JVM JIT flags

* Implement strcmp

* Remove unused instance variables

* Optimize hashing

* Put station name into hashtable

* Reorder method

* Remove usage of MemorySegment.getUtf8String

Replace with UNSAFE.copyMemory() and new String()

* Fix hashing bug

* Remove outdated comments

* Fix informative constants

* Use broadcastByte() more

* Improve method naming

* More hashing

* Revert more hashing

* Add commented-out code to hash 16 bytes

* Slight cleanup

* Align hashtable at cacheline boundary

* Add Graal Native image

* Revert Graal Native image

This reverts commit d916a42326d89bd1a841bbbecfae185adb8679d7.

* Simplify shell script (no SDK selection)

* Move a constant, zero out hashtable on start

* Better name comparison

* Add prepare_mtopolnik.sh

* Cleaner idiom in name comparison

* AND instead of MOD for hashtable indexing

* Improve word masking code

* Fix formatting

* Reduce memory loads

* Remove endianness checks

* Avoid hash == 0 problem

* Fix subtle bug

* MergeSort of parellel results

* Touch up perf

* Touch up perf

* Remove -Xmx256m

* Extract result printing method

* Print allocation details on OOME

* Single mmap

* Use global allocation arena
2024-01-11 20:02:14 +01:00
Jamal Mulla
8ec9ba861a
First submission - CalculateAverage_JamalMulla.java - Jamal Mulla (#238)
* Initial chunked impl

* Bytes instead of chars

* Improved number parsing

* Custom hashmap

* Graal and some tuning

* Fix segmenting

* Fix casing

* Unsafe

* Inlining hash calc

* Improved loop

* Cleanup

* Speeding up equals

* Simplifying hash

* Replace concurrenthashmap with lock

* Small changes

* Script reorg

---------

Co-authored-by: Jamal Mulla <j.mulla@mwam.com>
2024-01-11 19:56:29 +01:00
Roman Romanchuk
6381aefcc1 Fixed failing tests 2024-01-11 19:49:51 +01:00
Roman Musin
4b3f959812
First version - roman_r_m (#193)
* initial commit

* - use loop
- use mutable object to store results

* get rid of regex

* Do not allocate measurement objects

* MMap + custom double parsing ~ 1:30 (down from ~ 2:05)

* HashMap for accumulation and only sort at the end - 1:05

* MMap the whole file

* Use graal

* no GC

* Store results in an array list to avoid double map lookup

* Adjust max buf size

* Manual parsing number to long

* Add --enable-preview

* remove buffer size check (has no effect on performance)

* fix min & max initialization

* do not check for \r

* Revert "do not check for \r"

This reverts commit 9da1f574bf6261ea49c353488d3b4673cad3ce6e.

* Optimise parsing. Now completes in 31 sec down from ~43

* trying to parse numbers faster

* use open address hash table instead of the standard HashMap

* formatting

* Rename the script to match github username (change underscores to slashes)
Enable transparent huge pages, seems to improve by ~2 sec

* Revert "formatting"

This reverts commit 4e90797d2a729ed7385c9000c85cc7e87d935f96.

* Revert "use open address hash table instead of the standard HashMap"

This reverts commit c784b55f61e48f548b2623e5c8958c9b283cae14.

* add prepare_roman-r-m.sh

* SWAR tricks to find semicolon (-2 seconds ro run time)

* remove time call

* fix test

* Parallel version (~6.5 seconds)
2024-01-11 12:29:08 +01:00
Wladimir Schmidt
52c490cc24
Add multithreaded generation of measurements file with Gaussian distribution (M2 AIR took 24 seconds for 1B items) (#175)
* Add multithreaded variant to generate measurements

* Add removing existing measurements.txt file in case exists (for usability reasons)
Fix bug for number of lines generated

* Fix also for less than assumed chunk size (10M entries) per thread
2024-01-11 12:16:30 +01:00
MeanderingProgrammer
7ca2aa8d1d First attempt from MeanderingProgrammer
#### Check List:

- [x] Tests pass (`./test.sh MeanderingProgrammer` shows no differences between expected and actual outputs)
- [x] All formatting changes by the build are committed
- [x] Your launch script is named `calculate_average_MeanderingProgrammer.sh` (make sure to match casing of your GH user name) and is executable
- [x] Output matches that of `calculate_average_baseline.sh`

* Execution time: `00:04.668`
* Execution time of reference implementation: `02:40.597`
* System: Apple M2 Max, 12 cores, 64 GB
2024-01-11 12:03:29 +01:00
Roman Stoffel
64a78c3880 Basic Implementation with Memory Mapped File, SIMD Search
By gamlerhart
2024-01-11 11:58:57 +01:00
Jason Nochlin
80328e4898
create fork hundredwatt (#279)
Co-authored-by: Jason Nochlin <hundredwatt@users.noreply.github.com>
2024-01-11 11:48:22 +01:00
maeda6uiui
b0d381c91e Add code by maeda6uiui 2024-01-11 11:32:30 +01:00
Roy van Rijn
8c24871406
Fixing the off-by-one error and updating to native, redone layout of code. (#307) 2024-01-11 11:12:05 +01:00
Gunnar Morling
b0c9952c08 Leaderboard, formatting 2024-01-11 10:48:03 +01:00
David Kopec
780ab9af3e
Update davecom entry use ByteBuffer instead of String for Names and graal (#245)
* my implementation about 19.5 seconds on M1 MacBook Air

* final version

* use ByteBuffer instead of String; use graal

* add prepare_davecom script
2024-01-11 10:24:25 +01:00
Charlie Evans
c887202206
Charlibot submission (#249)
* committing my ugly code

* fulfil the brief wrt number of characters and the number of cities

* prepare submission
2024-01-11 10:01:06 +01:00
kumarsaurav123
99dd18b672
CalculateAverage_kumarsaurav123.java-> RAM 16 GB CPU 32 Core (#247) 2024-01-11 09:55:24 +01:00
Aleš Justin
965e852ba7
Simple, slow but very short. :-) (#240)
* Simple, slow but very short. :-)

* Fix sync on DSS::accept.
2024-01-11 09:48:27 +01:00
Artsiom Korzun
8602a35504
improved artsiomkorzun solution (#176)
improved artsiomkorzun solution

improved artsiomkorzun solution

Co-authored-by: Artsiom Korzun <akorzun@deltixlab.com>
2024-01-11 09:00:24 +01:00
Anthony Goubard
e7ab90e3ac
Implementation CalculateAverage_japplis of 1BRC from Anthony Goubard (#271)
* Implementation CalculateAverage_japplis of 1BRC from Anthony Goubard (japplis).
Local performance (7 years old desktop i7-6700K - 8 cores - 16GB) 26 seconds. For reference, Jamie Stansfield (isolgpus) is 23 seconds on my machine and 11s in your results.
I've added the nbactions.xml to the .gitignore file. When you add in NetBeans options like --enable-preview to actions like debug file or run file, it creates this file.

* Implementation CalculateAverage_japplis of 1BRC from Anthony Goubard (japplis).
Local performance (7 years old desktop i7-6700K - 8 cores - 16GB) 26 seconds. For reference, Jamie Stansfield (isolgpus) is 23 seconds on my machine and 11s in your results.
I've added the nbactions.xml to the .gitignore file. When you add in NetBeans options like --enable-preview to actions like debug file or run file, it creates this file.
second commit: Removed BufferedInputStream and replaced Measurement with IntSummaryStatistics (thanks davecom): still 23" but cleaner code
2024-01-10 23:09:21 +01:00
pedestrianlove
3f2fd934e5
Add entries for pedestrianlove. (#265)
Co-authored-by: jsl <s03851050@go.thu.edu.tw>
2024-01-10 22:57:41 +01:00
Pratham
473791e188
first cut 1brc submission (#216)
* phd3 initial entry

* Optimize parsing doubles

* Remove redundant check

* Update calculate_average_phd3.sh

---------

Co-authored-by: Gunnar Morling <gunnar.morling@googlemail.com>
2024-01-10 22:40:27 +01:00
Algirdas Raščius
d17619c95c
Quick and dirty first version (#215)
* Quick and dirty first version

* Update script to new standard
2024-01-10 22:35:37 +01:00
Anton Rybochkin
ad7a6ec573
Initial solution by raipc
* Initial solution by raipc

* Implemented custom hash map with open addressing

* Small optimizations to task splitting and range check disabling

* Fixed off-by-one error in merge

* Run with EpsilonGC. Borrowed VM params from Shipilev

* Make script executable

* Add a license
2024-01-10 22:26:00 +01:00
Michael Berry
1589210038
Initial implementation (#158)
* Initial implementation

* Make executable

* Deal with collisions (but very slow)

* Formatting

* Remove superfluous time

* Formatting

* Fixes

* Remove hard coded correction line

* Integer parsing speedup
2024-01-10 22:17:11 +01:00
arjenvaneerde
d4fdcc5408
Some optimizations arjenvaneerde
* First working version.

* Small adjustments.

* Correct number of threads.

* Sync

* Some fixes. To LF instead of CRLF.

* Parallel reading and processing.

* Update CreateMeasurements.java

* Update CalculateAverage.java

* Small fix for bug in switching buffers.

* Update calculate_average_arjenvaneerde.sh

---------

Co-authored-by: Gunnar Morling <gunnar.morling@googlemail.com>
2024-01-10 22:06:28 +01:00
zerninv
814c88fcb5
Implements CalculateAverage_zerninv.java
* initial attempt

* adjust to new evaluation env

* fix tests

* fix typo

* some numbers adjustments

* Update calculate_average_zerninv.sh

---------

Co-authored-by: Gunnar Morling <gunnar.morling@googlemail.com>
2024-01-10 21:53:34 +01:00
AbstractKamen
7483b90cec
CalculateAverage_AbstractKamen
* initial commit

* first attempt: segment the file and process it in parallel

* remove commented stuff

* custom parseDouble for this simple case

* fixed some issues and improved parsing

* format

* Update calculate_average_AbstractKamen.sh

---------

Co-authored-by: Gunnar Morling <gunnar.morling@googlemail.com>
2024-01-10 21:48:12 +01:00
Gunnar Morling
209e005461 Leaderboard, clean-up 2024-01-10 21:37:16 +01:00
Gaurav Mathur
20f0179181
gnmathur's solution (#202)
Co-authored-by: Gaurav Mathur <gmathur@gurukul>
2024-01-10 21:36:29 +01:00
CourageLee
c9b7fe9deb
Add CalculateAverage_couragelee Java class and shell script
This commit introduces a new java class, CalculateAverage_couragelee, and a shell script for calculating averages. The java class utilizes NIO's memory-mapping and parallel computing techniques to perform calculations. These changes should improve the efficiency and speed of average calculations.
2024-01-10 21:16:36 +01:00
Prabhu R
1086385f1f
Implementation by rprabhu
Co-authored-by: Prabhu R <prabhu.rengaswamy@outlook.com>
2024-01-10 21:09:42 +01:00
greid
08af2622d3 gabrielreid take 2
Clear up some TODOS, simplify the code a bit, which appears to
result in a 25% performance increase.
2024-01-10 20:43:46 +01:00
Stefan Sprenger
a8a3876416
Second submission by flippingbits - 50% performance improvement
* feat(flippingbits): Improve parsing of measurement and few cleanups

* feat(flippingbits): Reduce chunk size to 10MB

* feat(flippingbits): Improve parsing of station names

* chore(flippingbits): Remove obsolete import

* chore(flippingbits): Few cleanups
2024-01-10 20:36:22 +01:00
Quan Anh Mai
97b1f014ad
merykitty's second attempt 2024-01-10 20:24:19 +01:00
Elliot Barlas
44414a33dc Consume four bytes at a time from buffer using getInt. Store key with unsafe int array rather than byte array. Use custom equals rather than Arrays equals. 2024-01-10 20:03:14 +01:00
Thomas Wuerthinger
af66ac145f
Second tuning for thomaswue
* Optimize checking for collisions by doing this a long at a time always.

* Use a long at a time scanning for delimiter.

* Minor tuning. Now below 0.80s on Intel i9-13900K.

* Add number parsing code from Quan Anh Mai. Fix name length issue.

* Include suggestion from Alfonso Peterssen for another 1.5%.

* Optimize hash collision check compare for ~4% gain.

* Add perf stats based on latest version.
2024-01-10 19:42:51 +01:00
Nils Semmelrock
a421ad5dbf Revert "Adding Nils Semmelrock's submission"
This reverts commit 12ae36ad
2024-01-10 19:33:52 +01:00
Alexander Yastrebov
a08cd0e05a Add small test cases
For https://github.com/gunnarmorling/1brc/issues/276
2024-01-10 15:48:42 +01:00
Daniel Avery
82cb32946e
Add davery22 impl 2024-01-07 21:14:04 +01:00
Jamie Stansfield
dbd8ca4562
isolgpus: submission 2 - about a 25% improvement on submission 1. (#168)
* isolgpus: fix chunk sizing when not at 8 threads
use as many cores as are available
don't buffer the station name, only use it when we need it.
get rid of the main branch
move variables inside the loop

* isolgpus: optimistically assume we can read a whole int for the station name, but roll back if we get it wrong. This should be very beneficial on a dataset where station names are mostly over 4 chars

---------

Co-authored-by: Jamie Stansfield <jalstansfield@gmail.com>
2024-01-07 20:55:30 +01:00
Thomas Wuerthinger
243388ad7b
Use SIMD for search for delimiter and name compare 2024-01-07 20:50:11 +01:00
김예환 Ye-Hwan Kim (Sam)
9e9e533401
Add yehwankim23 (#148) 2024-01-07 20:41:41 +01:00
Olivier Bourgain
143132e8df
My implementation is in dev.morling.onebrc.CalculateAverage_obourgain and runnable with provided script calculate_average_obourgain.sh (#75)
Runs with standard JDK 21.

On my computers (i5 13500, 20 cores, 32GB ram) my best run is (file fully in page cache):
49.78user 0.69system 0:02.81elapsed 1795%CPU

A bit older version of the code on Mac pro  M1 32 GB:
real	0m2.867s
user	0m23.956s
sys	0m1.329s

As I wrote in comments in the code, I have a few different roundings that the reference implementation. I have seend that there is an issue about that, but no specific rule yet.

Main points:
- use MemorySegment, it's faster than ByteBuffer
- split the work in a lot of chunks and distribute to a thread pool
- fast measurement parser by using a lot of domain knowledge
- very low allocation
- visit each byte only once

Things I tried that were in fact pessimizations:
- use some internal JDK code to vectorize the hashCode computation
- use a MemorySegment to represent the keys instead of byte[], to avoid
  copying

Hope I won't have a bad surprise when running on the target server 😱
2024-01-07 20:15:53 +01:00
Roy van Rijn
e665d71549
Roy: Adding a bit of unsafe...
Co-authored-by: Gunnar Morling <gunnar.morling@googlemail.com>
2024-01-07 19:41:43 +01:00
ags
990483dcc8 first attempt 2024-01-07 12:09:43 +01:00
Cool_Mineman
d89d1b488d
Initial Implementation - coolmineman (#196)
* start

* slower

* still bad

* finally faster than baseline :)

* starting to go fast

* improve

* we ball

* fix race condition an newline

* change threadpool

* ~18sec on my machine
2024-01-07 11:39:45 +01:00
Kevin McMurtrie
2e1fba5a92
1brc submission - Kevin McMurtrie (#195)
* v1

* Fix sorting
2024-01-07 11:12:57 +01:00
John
96d1050a8c An implementation optimised for simplicity/readability. 2024-01-07 11:04:49 +01:00
Gunnar Morling
96efccfb49 Leaderboard update 2024-01-07 10:58:05 +01:00
Serghei Motpan
6b3027955a CalculateAverage semotpan attempt 1 2024-01-07 10:57:34 +01:00
Santanu Barua
85fa0891bc
Implements CalculateAverage_santanu.java
Execution time: 1 minute and 27.863 seconds
System specs: Apple M1, 8 cores, 16GB RAM

Co-authored-by: santanu barua <santanu@host109.private.net>
2024-01-07 10:40:18 +01:00
Keshavram Kuduwa
78b3415678
Optimised Code to use FileSegments with ByteBuffer (#184)
* Keshavram Kuduwa's Submission

* Resolves #102 and Code Optimizations

* Resolves #102 and Code Optimizations

* Optimised Code with Roy's Reference

* Fixed Tests

* Clean Up Code

---------

Co-authored-by: Keshavram Kuduwa <keshavram.kuduwa@apptware.com>
2024-01-07 10:11:56 +01:00
Elliot Barlas
c13997c9e0
Continue unrolling and inlining value parser. Make targeted use of ByteBuffer.getInt() instead of ByteBuffer.get(). Switch from GraalVM CE to GraalVM. (#201) 2024-01-07 10:05:18 +01:00
Andrew Sun
aa0395d01b
Add entry by Andrew Sun 2024-01-07 10:00:58 +01:00
Carlo
3ebc7d2b9c
Experiment from entangled90
* single thread memory mapped file reader, pool of processors

* cleanup of inner classes of MetricProcessor

* doubles are parsed without external functions, strings are lazily created from byte arrays

* remove load() MappedByteBuffer in memory

* fixed handling of newline

* fix a bug & correct locale used

* MappedByteBuffer size set to 1MB

* fixed rounding

* Do not use ArrayBlockingQueue.offer since it drops elements when queue is full

* MappedByteBuffer size = 32 MB
2024-01-07 09:50:34 +01:00
Gergely Kiss
c72a8e9769
Adding kgeri's solution (#137)
* Adding kgeri's solution

* parallelizing CalculatorAverage_kgeri

* fixing aggregation bugs, chunk size calc for small files

* removed GC logging

Co-authored-by: Gunnar Morling <gunnar.morling@googlemail.com>

* fix for when there's no newline at end of input

* fix for when the final record ends on the chunk boundary

---------

Co-authored-by: Gunnar Morling <gunnar.morling@googlemail.com>
2024-01-07 09:45:30 +01:00
Dimitar Dimitrov
14918bb306
ddimtirov - supporting hash collisions, should have fixed #101
* ddimtirov - supporting hash collisions, should have fixed #101
* Make life easier for Windows user who need to use WSL to run the tests
2024-01-06 19:24:48 +01:00
Yavuz Tas
e8b2d2d7b4
Improvement in CalculateAverage_yavuztas (#162)
* improve double reading by eleminating string parsing in between, make calculations over on integer instead of double, parse into double at the end only once

* more improvements, sharing a single StringBuilder to build all toStrings, minor performance gain.

* micro optimizations on reading temperature

* a small skip for redundant traverses, micro optmization

* micro optimization, eleminate some if cases, saves 0.5 seconds more

* micro optimization, calculate key hash ahead eleminates more more loop, saves 0.5 seconds more :)

* optimize key equals and handling the case when a region is larger than max integer size

---------

Co-authored-by: Yavuz Tas <yavuz.tas@ing.com>
2024-01-06 19:09:16 +01:00
Mudit Saxena
9879ff5034
Mudit/initial attempt (#41)
* Initial version with multiple ideas

* Added virtual thread implementation based on certain task size

* Removed evaluate file

* Fixed test issues

* Added a custom input split
2024-01-06 18:54:37 +01:00
Gunnar Morling
32bef5ac96 Updating leaderboard, formatting, avoiding OOME 2024-01-06 18:20:44 +01:00
Rafael Merino García
40acde7dd5
my first try to 1BRC!
* first try

* format

* Update calculate_average_imrafaelmerino.sh

Co-authored-by: Gunnar Morling <gunnar.morling@googlemail.com>

* Update src/main/java/dev/morling/onebrc/CalculateAverage_imrafaelmerino.java

Co-authored-by: Gunnar Morling <gunnar.morling@googlemail.com>

---------

Co-authored-by: Rafael Merino García <imrafaelmerino@gmail.com>
Co-authored-by: Gunnar Morling <gunnar.morling@googlemail.com>
2024-01-06 18:18:54 +01:00
Stefan Sprenger
749d2d8f78
Add solution by flippingbits - Use SIMD for computing aggregates
* feat(flippingbits): First revision

* chore(flippingbits): Clean up output

* fix(flippingbits): Use ShortVector.SPECIES_MAX
2024-01-06 18:13:52 +01:00
Horia Chiorean
1a9b1cb7da
hchiorean - Initial version
* Initial version

* Removed some System out messages and tweaked some config values

* Added some fixes and some tweaks
2024-01-06 17:59:49 +01:00
Quan Anh Mai
4fc6034812
merykitty's attempt
* first commit

* fix test

* concurrency

* format for easier to follow explanation

* fix large keys

* fix overlapping ranges

* prefetch file

* add comments, remove prefetching

* typo
2024-01-06 17:01:12 +01:00
Bruno Félix
6eb8b49b7c
Implementation of 1brc - felix19350 (#53)
* Implementation of 1brc - felix19350

* Added license header

* Fixed failing tests

* Replaced parsing of doubles with a custom parser and integer arithmetic

---------

Co-authored-by: Bruno Felix <bruno.felix@klarna.com>
2024-01-06 11:27:30 +01:00
Michael Berry
38fc317073 Fix #159 2024-01-06 11:05:36 +01:00
Thomas Wuerthinger
a53aa2e6fd
Initial version for thomaswue with Oracle GraalVM Native Image
* Initial version.

* Make PGO feature optional off-by-default. Needs PGO_MODE environment
variable to be set. Add -O3 -march=native tuning flags for better
performance.

* Adjust script to be more quiet.

* Adjust max city length. Fix an issue when accumulating results.

* Tune thomaswue submission.
mmap the entire file, use Unsafe directly instead of ByteBuffer, avoid byte[] copies.
These tricks give a ~30% speedup, over an already fast implementation.

* Optimize parsing of numbers based on specific given constraints.

* Fix for segment calculation for case of very small input.

* Minor shell script fixes.

* Separate out build step into file additional_build_step_thomaswue.sh,
simplify run script and remove PGO option for now.

* Minor corrections to the run script.

---------

Co-authored-by: Alfonso² Peterssen <alfonso.peterssen@oracle.com>
2024-01-06 10:55:07 +01:00
Markus Ebner
093bd35c44 seijikun: Fix new unit-test introduced with #125 2024-01-06 10:39:19 +01:00
Marko Topolnik
35b90992aa More detailed attribution 2024-01-06 10:35:44 +01:00
Marko Topolnik
7ec968d3bb One more sample in test file 2024-01-06 10:35:44 +01:00
Marko Topolnik
eccc8f9097 Improve name generation 2024-01-06 10:35:44 +01:00
Marko Topolnik
e09cb7deea Limit names to 100 bytes 2024-01-06 10:35:44 +01:00
Marko Topolnik
a094d07925 Move attribution into weather_stations.csv 2024-01-06 10:35:44 +01:00
Marko Topolnik
d7456c6ff9 Add test sample with a worst-case UTF-8 name 2024-01-06 10:35:44 +01:00
Marko Topolnik
816e59b678 Eliminate duplicate station names 2024-01-06 10:35:44 +01:00
Marko Topolnik
0f1f204a0d Generate measurements with random names
Name length goes from 1 to 100.
2024-01-06 10:35:44 +01:00
Abhilash
ba1999cddf 1 brc - 2gb memory 1 min 31 secs 2024-01-06 00:25:15 +01:00
twobiers
c24bcac047 Adjust buffer size to solve test failure in #125 2024-01-06 00:12:36 +01:00
Yavuz Tas
f6acc6f3d5
A solution with Actor Model concurrency and MappedByteBuffer
* A solution with Actor Model concurrency and MappedByteBuffer

* fix test cases

* revert back the file name to original

* cache String hashCode calculation via composing with Key object

* fix wrong key caching and eleminate duplicate String creation between actors

* update possible char count in a line, fix calculate_average.sh

* increase possible line length to 256 bytes, much safer to cover 100 chars I hope

---------

Co-authored-by: Yavuz Tas <yavuz.tas@ing.com>
2024-01-05 23:50:58 +01:00
Roman Schweitzer
5f4ed31fec
CalculateAverage_truelive second attempt
* cleanup

* getDouble new double parser

* parseBuffer more reliable

* use graalvm to execute

* cleanup

* cleanup

* fix formatting

* fix graalvm init and launch script
2024-01-05 23:40:03 +01:00
Parth Mudgal
72ad94d6c2
artpar's attempt
* artpar's attempt

* artpar's attempt

* remove int -> Integer conversions, custom parsing for measurements

* remove allocations by caching station names
also remove Integer and use int instead to remove valueOf calls

* Fix result mismatch errors

* parse int instead of double

* reduce time spent reading the mapped buffer

* cleanup unused memory

* less is faster ? vector addition doesn't look worth it

* backout from virtual threads as well

* Fix breaking tests
2024-01-05 23:28:38 +01:00
greid
d3e88219f0 gabrielreid's first attempt
Somewhat mixed collection of multiple ideas, mostly based initially
on using the new JDK Vector API for extracting offsets of newlines
and semicolons.

Runs locally in just under 11 seconds on 1B rows of input on a
2020 M1 Macbook Air.
2024-01-05 23:19:02 +01:00
Jamie Stansfield
4614b81eb6
isolgpus: submission 1
* isolgpus: submission 1

* isolgpus: fix min value bug (breaks if a negative temperature never appears)

* isolgpus: remove unused collector

* isolgpus: fix split on chunk bug

* isolgpus: change name equality algo to a cheaper check.

* isolgpus: fix chunking state to cope with last byte of last chunk

* isolgpus: hash as we go, instead of at the end

* isolgpus: adjust thread count to core count

* isolgpus: change cores to 8 statically

---------

Co-authored-by: Jamie Stansfield <jalstansfield@gmail.com>
2024-01-05 23:10:43 +01:00
Yunus Inci
4fe00bf7a7 Improve spullara's solution 2024-01-05 23:00:43 +01:00
Johannes Schüth
22b5435893 Adding Johannes Schüth's submission 2024-01-05 22:52:39 +01:00
Ramzi Ben Yahya
e8a3011aca
rby: Has some interesting optimisations but could be improved further with a custom hash map
* rby: Could be improved with a custom hashmap

* Flag not needed

* Fixes the tests when running ./test.sh rby
2024-01-05 20:25:51 +01:00
Tobi
d617039d10
Twobier's submission
* First performance tweaks

* further tweaks

* collect into a treemap

* Tweak JVM options

* Inline rounding into collector

* reduce some operations

* oops, add missing braces

* tweak JVM options

* small fixes

* add min and max to processing

* fix min

* remove compact strings

* replace sumWithCompensation with naive sum implementation

* use UseShenandoahGC

* integrate mmap

* integrate mmap

* Fix messed up array logic

* Set jdk version
2024-01-05 20:18:27 +01:00
Markus Ebner
36dac255cf
Update seijikun implementation
* Use Integer calculation instead of double, add unit-test

* Bring back StationIdent optimization

Originally, StationIdent was using byte[] to store names, so the extra
String allocation could be avoided. However, that produced incorrect
sorting.
Sorting is now moved to the result merging step. Here, names are
converted to Strings.

* Implement readStationName with SIMD 256bit

* Rebase and cleanup test code, now that it's in the project

* Fix seijikun formatting

* Fix test failure in specific jobCnt edge-cases

* Also switch to graalvm
2024-01-05 19:35:15 +01:00
deemkeen
e3f6c3aaf7
initial deemkeen 2024-01-05 19:30:02 +01:00
Artsiom Korzun
cec579b506 improved artsiomkorzun solution 2024-01-05 19:02:44 +01:00
Keshavram Kuduwa
a53549ae50
Resolves #102 and Code Optimizations 2024-01-05 18:35:31 +01:00
Filip Hrisafov
c4879d4104
Use proper key for CalculateAverage_filiphr;
* Revert using hash as a key
* Use custom key with Arrays#equals as a key in the Map of measurements
* Add sdk use java in the calculate script
2024-01-05 17:54:08 +01:00
Roy van Rijn
3a2e0ed267 Adding more speed improvements, going for first again.
Updating script
2024-01-05 17:44:36 +01:00
Ujjwal Bharti
631722158c Added implementation for calculating average 2024-01-05 17:23:13 +01:00
Elliot Barlas
99b453334c Implement imperative state machine for floating point parser rather then generic, adaptive loop. 2024-01-05 17:11:22 +01:00
Samson Yeung
a1a9a19324 Custom atoi/atof parser logic, plus math changes.
This commit uses a custom atoi function that converts 12.4 to 124 so we
can do integer math instead of using doubles.
2024-01-05 16:59:29 +01:00
David Kopec
8a282ab71b
Add davecom Entry 2024-01-05 16:35:05 +01:00
Roman Romanchuk
15cceae81b
fatroom's initial attempt
* Initial attempt

* Fixed temperature parsing

* Switched to memory mapped files

* Fixed rounding issues

* Inline of temperature reading

* Fixed output rounding
2024-01-05 11:30:18 +01:00
anandmattikopp
0d33213dc6 feat: first version of the 1brc solution 2024-01-05 11:24:14 +01:00
Arman Sharif
951c06e051 armandino: first submission 2024-01-05 00:13:44 +01:00
Alexander Yastrebov
69ff290d9d jgrateron: fix formatting
Followup on #69
2024-01-04 23:56:47 +01:00
Nick Palmer
39c421d520 Pass newly added tests :fingers-crossed: 2024-01-04 23:54:04 +01:00
Nick Palmer
6aa63e1bd5 Attempt nicer threading via streams and spliterators 2024-01-04 23:54:04 +01:00
Richard Startin
b2cd84c6bc make aggregation state grow dynamically 2024-01-04 23:48:54 +01:00
Alexander Yastrebov
b467319e58 test: use temperature value of 1.0
In case of key collision broken implementation will likely attribute
measurements to the wrong key and therefore it is better to have
non-zero value to end up with a wrong average value.

When all measurements are zero then averages are also zero even
when attributed to the wrong keys.

Updates #91
2024-01-04 23:46:46 +01:00
jairo
a17ab05d4b add implementation jgrateron 2024-01-04 23:43:43 +01:00
Nils Semmelrock
12ae36ade1
Adding Nils Semmelrock's submission
nothing fancy, just work on chunks in parallel and optimize bottlenecks
2024-01-04 23:31:47 +01:00
Roy van Rijn
1c74049991
Updating Roy's submission
* Added tests for endian-calculations (had these in a different class, perhaps handy for others to see as well)

Inlined the hash function, runs locally in 2.4sec now, hopefully endian issues fix

Added equals to support any city name up to 1024 in length, don't rely on hash

* For clarity I've updated the code so endian doesn't change the hashes, easier to debug.

* Fixing bug in array check

Simple is faster

* Also spotted the diff, not just the big exception

Fixed buffer limit issue
2024-01-04 23:22:48 +01:00
Moysés Borges Furtado
acb6510a02
Adding Moysés Borges Furtado's submission 2024-01-04 23:15:22 +01:00
Alexander Yastrebov
723cc6a33b test: add sample with 10k unique keys
Input created via
```sh
bash -c 'for i in {1..10000} ; do echo "id$i;0.0" ; done' >./src/test/resources/samples/measurements-10000-unique-keys.txt
```
and output via baseline implementation.

Keys are short and very similar which improves chances for collision
and hence are good for testing.

Fixes #91
2024-01-04 21:39:04 +01:00
Gunnar Morling
e1a6832837 Adding a missing new line 2024-01-04 21:32:02 +01:00
Elliot Barlas
a8bd6b58ce
Elliot Barlas: Use proper hash key collision detection scheme
* Use open-addressing scheme to deal with hash table collisions. Reduce concurrency from 16 to 8. Use bit mask rather than mod operator to confine hash code to table range.

* Properly handle file partitions that reside entirely within a line.

* Reorder statements in doProcessBuffer.
2024-01-04 21:06:19 +01:00
Sam Pullara
4af3253d53
Updating Sam Pullara's entry 2024-01-04 19:14:06 +01:00
Gunnar Morling
c1954f6a3f Formatting 2024-01-04 19:03:42 +01:00
artsiomkorzun
9b0b10f101
Adding artsiomkorzun's solution 2024-01-04 19:01:28 +01:00
Filip Hrisafov
8c5aaf2db9 Manually compute temperature value instead of using Long.parseLong 2024-01-04 18:50:45 +01:00
Filip Hrisafov
f5f3a41045 Use a hash key for the city as a key in the map 2024-01-04 18:50:45 +01:00
Filip Hrisafov
4a483b4097 Use long parse and use char array instead of CharBuffer for adding to it 2024-01-04 18:50:45 +01:00
Gunnar Morling
88b1c30db8 Leaderboard update 2024-01-04 18:22:13 +01:00
Richard Startin
c3411f6023
Richard Startin: Adopt @spullara's double parsing code;
* increase chunk size
* simplify and tune parameters
2024-01-04 18:19:56 +01:00
Peter Lawrey
a09fa928db
Adding Peter Lawrey's submission 2024-01-04 17:59:40 +01:00
Gunnar Morling
5c219e7b7a Fixing wrong expected value 2024-01-04 17:43:01 +01:00
Gunnar Morling
b6d33fd8fe Expanding tests and eval infra 2024-01-04 17:22:00 +01:00
Filip Hrisafov
a503362c36 Auto reformat classes 2024-01-04 15:35:34 +01:00
Alexander Yastrebov
c9400bc1ce test: add test samples
Adds test samples that can be used for unit tests or to verify
implementations via:
```bash
for sample in $(ls src/test/resources/samples/*.txt)
do
  echo "Validating $sample"
  rm -f measurements.txt
  ln -s $sample measurements.txt

  diff <(./calculate_average.sh) ${sample%.txt}.out
done
rm measurements.txt
```

For #61
2024-01-04 13:18:29 +01:00
Dimitar Dimitrov
d73457872f ddimtirov - switched to the foreign memory access preview API for another 10% speedup 2024-01-03 21:04:44 +01:00
Dimitar Dimitrov
1923fc65a8 ddimtirov - lifted parallel mmapped i/o from Sam Pullara's implementation 2024-01-03 21:04:44 +01:00
Dimitar Dimitrov
57cfa54c68 ddimtirov - single-threaded datastructures tuning - reading to char buffers, one pass, no allocation processing 2024-01-03 21:04:44 +01:00
Dimitar Dimitrov
2458f056d6 ddimtirov - fixpoint, objects, streams and strings 2024-01-03 21:04:44 +01:00
Roy van Rijn
5570f1b60a
Roy van Rijn: memory mapped files, branchless parsing, bitwiddle magic
Added SWAR (SIMD Within A Register) code to increase bytebuffer processing/throughput
Delaying the creation of the String by comparing hash, segmenting like spullara, improved EOL finding

Co-authored-by: Gunnar Morling <gunnar.morling@googlemail.com>
2024-01-03 20:44:24 +01:00
Richard Startin
0ba5cf33d4 richardstartin submission 2024-01-03 20:42:18 +01:00
Filip Hrisafov
d57cf78faa
Adding filiphr's submission;
* Initial implementation using Shenandoah GC and parallel iteration

* Use memory mapped files

* Iterate the buffer once and use BigDecimal parsing instead of Double.parseDouble

* Add information about Graal

* Add sdk use to calculate script
2024-01-03 20:32:16 +01:00
Karl Heinz Marbaise
95c9d091ef
Adding khmarbaise 2024-01-03 20:21:23 +01:00
Markus Ebner
580c4ac214
Adding seijikun's submission 2024-01-03 20:06:14 +01:00
Nick Palmer
8e6298cd2a
Adding Nick Palmer's submission;
* Memory mapped file, single-pass parsing, custom hash map, fixed thread pool
The threading was a hasty addition and needs work

* Used arraylist instead of treemap to reduce a little overhead
We only need it sorted for output, so only construct a treemap for output

* Attempt to speed up double conversion

* Cap core count for low-core systems

* Fix wrong exponent

* Accumulate measurement value in double, seems marginally faster

Benchmark                                                           Mode  Cnt    Score    Error   Units
DoubleParsingBenchmark.ourToDouble                                 thrpt   10  569.771 ±  7.065  ops/us
DoubleParsingBenchmark.ourToDoubleAccumulateInToDouble             thrpt   10  648.026 ±  7.741  ops/us
DoubleParsingBenchmark.ourToDoubleDivideInsteadOfMultiply          thrpt   10  570.412 ±  9.329  ops/us
DoubleParsingBenchmark.ourToDoubleNegative                         thrpt   10  512.618 ±  8.580  ops/us
DoubleParsingBenchmark.ourToDoubleNegativeAccumulateInToDouble     thrpt   10  565.043 ± 18.137  ops/us
DoubleParsingBenchmark.ourToDoubleNegativeDivideInsteadOfMultiply  thrpt   10  511.228 ± 13.967  ops/us
DoubleParsingBenchmark.stringToDouble                              thrpt   10   52.310 ±  1.351  ops/us
DoubleParsingBenchmark.stringToDoubleNegative                      thrpt   10   50.785 ±  1.252  ops/us
2024-01-03 17:21:56 +01:00
Elliot Barlas
1b048c876d
Adding Elliot Barlas' submission 2024-01-03 16:25:24 +01:00
Roman Schweitzer
ea035790fd
Using DoubleAccumulators to save on a measurment creation (#26) 2024-01-03 16:10:31 +01:00
Chris Riccomini
e9f062ce4d Adding Chris Riccomini's submission 2024-01-03 15:56:31 +01:00
Sam Pullara
c832d64afe
Adding Sam Pullara's submission; 2024-01-03 15:35:51 +01:00
Rene Schwietzke
70fcbf9c27 Removed changes to formatting 2024-01-03 13:03:37 +01:00
Rene Schwietzke
04bd2d69b6 Faster version of the data generator 2024-01-03 13:03:37 +01:00
Karl Heinz Marbaise
7d485d0e8b Usage of try-with-resources
pom file cleanup
2024-01-03 13:03:03 +01:00
Aurelian Tutuianu
1721848570 - implementation by padreati 2024-01-02 21:16:49 +01:00
Gunnar Morling
7b7a7d1667 Evaluating bjhara's entry 2024-01-02 20:43:46 +01:00
Hampus Ram
6b13d52b67 Implementation using memory mapped file 2024-01-02 20:41:33 +01:00
Gunnar Morling
5e80d8a7b0 Evaluating Kuduwa Keshavram's submission 2024-01-02 20:30:41 +01:00