Skip to content

Commit

Permalink
mtopolnik submission 3 (#637)
Browse files Browse the repository at this point in the history
* 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 d916a42.

* 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

* Add commented-out Xmx64m XXMaxDirectMemorySize=1g

* withinSafeZone

* Update cursor earlier

* Better assert

* Fix bug in addrOfSemicolonSafe

* Move declaration lower

* Simplify code

* Add rounding error test case

* Fix DANGER_ZONE_LEN

* Deoptimize parseTemperatureSimple()

* Inline parseTemperatureAndAdvanceCursor()

* Skip masking until the last load

* Conditionally fetch name words

* Cleanup

* Use native image

* Use supbrocess

* Simpler code

* Cleanup

* Avoid extra condition on hot path
  • Loading branch information
mtopolnik authored Jan 29, 2024
1 parent 5ba094c commit 886f0cd
Show file tree
Hide file tree
Showing 3 changed files with 222 additions and 261 deletions.
10 changes: 8 additions & 2 deletions calculate_average_mtopolnik.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,11 @@
# limitations under the License.
#

java --enable-preview \
--class-path target/average-1.0.0-SNAPSHOT.jar dev.morling.onebrc.CalculateAverage_mtopolnik
if [ -f target/CalculateAverage_mtopolnik_image ]; then
echo "Using native image 'target/CalculateAverage_mtopolnik_image'" 1>&2
target/CalculateAverage_mtopolnik_image
else
JAVA_OPTS="--enable-preview"
echo "Native image not found, using JVM mode." 1>&2
java $JAVA_OPTS --class-path target/average-1.0.0-SNAPSHOT.jar dev.morling.onebrc.CalculateAverage_mtopolnik
fi
7 changes: 6 additions & 1 deletion prepare_mtopolnik.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,9 @@
#

source "$HOME/.sdkman/bin/sdkman-init.sh"
sdk use java 21.0.1-graal 1>&2
sdk use java 21.0.2-graal 1>&2

if [ ! -f target/CalculateAverage_mtopolnik_image ]; then
NATIVE_IMAGE_OPTS="--gc=epsilon -O3 -H:+UnlockExperimentalVMOptions -H:-GenLoopSafepoints -march=native --enable-preview -H:InlineAllBonus=10 -H:-ParseRuntimeOptions --initialize-at-build-time=dev.morling.onebrc.CalculateAverage_mtopolnik"
native-image $NATIVE_IMAGE_OPTS -cp target/average-1.0.0-SNAPSHOT.jar -o target/CalculateAverage_mtopolnik_image dev.morling.onebrc.CalculateAverage_mtopolnik
fi
Loading

0 comments on commit 886f0cd

Please sign in to comment.