Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Final submission #669

Merged
merged 4 commits into from
Jan 31, 2024
Merged

Final submission #669

merged 4 commits into from
Jan 31, 2024

Conversation

merykitty
Copy link
Contributor

Some small improvements:

  • It is more performant to use branches than to use min/max
  • Do 2 independent iterations to improve IPC

Some that I have tried:

  • Do 4 iterations and use vector instructions to parse all of them at once: LongVector multiplication codegen is horrible, assembling a vector from its elements is expensive, also the constants need to be materialized for each iteration unless the compiler can inline the whole thing.
  • Spawning a separate process to hide the cost of unmapping: It is likely that the cost of initializing the VM is higher than the cost of unmap, I did not see improvements.
  • Some trickeries to avoid Unsafe: Spawning a new segment each time introduces regression, most likely due to failures to inline even with that threshold of inlining, and using a Long.MAX_VALUE-size segment introduces additional bound checks.

Check List:

  • You have run ./mvnw verify and the project builds successfully
  • Tests pass (./test.sh <username> shows no differences between expected and actual outputs)
  • All formatting changes by the build are committed
  • Your launch script is named calculate_average_<username>.sh (make sure to match casing of your GH user name) and is executable
  • Output matches that of calculate_average_baseline.sh
  • For new entries, or after substantial changes: When implementing custom hash structures, please point to where you deal with hash collisions (line number)
  • Execution time: Cannot tell, my laptop is not really reliable for benchmarking, but the elapsed time is around 20s.
  • Execution time of the previous implementation: Around 26s.

@tarsa
Copy link

tarsa commented Jan 30, 2024

  • Spawning a separate process to hide the cost of unmapping: It is likely that the cost of initializing the VM is higher than the cost of unmap, I did not see improvements.

it seems there's another trick to try:

if (CLOSE_STDOUT_ON_RESULT) {
// After printing result, close stdout.
// So parent process can complete without waiting this process completed.
// Saves a few hundred milliseconds caused by unmap.
System.out.close();
}

along with
#echo "Process started at $(date +%s%N | cut -b1-13)"
eval "exec 3< <({ $CONFIGS java $JAVA_OPTS --class-path target/average-1.0.0-SNAPSHOT.jar dev.morling.onebrc.CalculateAverage_serkan_ozal; })"
read <&3 result
echo -e "$result"
#echo "Process finished at $(date +%s%N | cut -b1-13)"

@gunnarmorling
Copy link
Owner

Nice!

# Result (m:s.ms) Implementation JDK Submitter Notes
00:02.367 link 21.0.1-open Quan Anh Mai uses Unsafe
00:03.210 link 21.0.1-open Quan Anh Mai

@gunnarmorling gunnarmorling merged commit 1a4ac0d into gunnarmorling:main Jan 31, 2024
1 check passed
@gunnarmorling
Copy link
Owner

Hey @merykitty, couldn't find another way to reach out to you, so commenting here: would you perhaps be interested in teaming up with Thomas, Roy, Elliot, and me for doing a live stream on #1BRC tomorrow with Nicolai Parlog: https://twitter.com/gunnarmorling/status/1752288991909478611. As one of the fastest JVM-based implementations, it would be great to have your perspective on the challenge. Let me know :)

@merykitty
Copy link
Contributor Author

@gunnarmorling I would be more than happy to join. Can you give me more information regarding the subjects or what can I contribute to the conversation? My email is [email protected].

@gunnarmorling
Copy link
Owner

gunnarmorling commented Feb 1, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants