1brc icon indicating copy to clipboard operation
1brc copied to clipboard

Minor improvement to @spullara

Open hundredwatt opened this issue 1 year ago • 3 comments

I forked @spullara's file and made a minor improvement that reduces execution time by 2-3%.

This reduced executive time from ~9.5 to ~9.3s in hyperfine with 5 runs

  • Class Name: CalculateAverage_hundredwatt
  • Machine specs: 8 cores, 32GB RAM
  • JVM: 21.0.1-graalce

Improvement:

  • Hard-code processing of the first character of the city name (which can never be ; according to the input value ranges in the README), commit: 0ffa9bcc6944df4db2e0177e09640861631bc813

I ran hyperfine twice with benchmark order reversed the second time and saw the same results.

image

Hyperfine command:

hyperfine --warmup 1 --runs 5 ' java $JAVA_OPTS --class-path target/average-1.0.0-SNAPSHOT.jar dev.morling.onebrc.CalculateAverage_yemreinci' ' java $JAVA_OPTS --class-path target/average-1.0.0-SNAPSHOT.jar dev.morling.onebrc.CalculateAverage_hundredwatt'

(Note: hostname of this machine is fedora-s-8vcpu-16gb-amd-sfo3-01, but I resized it to have 32gb of RAM)

hundredwatt avatar Jan 05 '24 02:01 hundredwatt

Rebased my fork with latest main and ensured test.sh passes

hundredwatt avatar Jan 05 '24 04:01 hundredwatt

The original results excited me because the difference was small, but this change always had the min time. Not true after rebasing.

Seems like it may be a wash for the purposes of this challenge, curious what others think:

image

hundredwatt avatar Jan 05 '24 04:01 hundredwatt

I am on the fence tbh. As per the rules, there should be significant improvements when basing on existing impls. Hard to draw a line of course, but to me this one feels below the threshold, in particular as it seems not consistently faster? I'm inclined to close this one.

gunnarmorling avatar Jan 05 '24 19:01 gunnarmorling