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

Exit earlier from loop when a new Result is created #668

Conversation

tivrfoa
Copy link
Contributor

@tivrfoa tivrfoa commented Jan 30, 2024

 *   3) Make a cache of long[] name to String, to avoid `ByteBuffer.allocate`
 * and creating new UTF-8 strings. I didn't profile, so it's just a guess
 * that this map will be a bit faster. Although it's outside the main loop, so
 * not a big difference ...;
 *   4) Exit earlier from loop if a new entry was created.

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): not a new entry. Same collision logic
  • Execution time:
  • Execution time of reference implementation:

@gunnarmorling
Copy link
Owner

A bit slower now:

Benchmark 1: timeout -v 300 ./calculate_average_tivrfoa.sh 2>&1
  Time (mean ± σ):      2.355 s ±  0.022 s    [User: 0.002 s, System: 0.004 s]
  Range (min … max):    2.320 s …  2.375 s    5 runs

Summary
  tivrfoa: trimmed mean 2.3596067892600003, raw times 2.3198986672600004,2.3745432172600003,2.36888179626,2.3620232222600004,2.3479153492600005

Leaderboard

| # | Result (m:s.ms) | Implementation     | JDK | Submitter     | Notes     |
|---|-----------------|--------------------|-----|---------------|-----------|
|   | 00:02.359 | [link](https://github.com/gunnarmorling/1brc/blob/main/src/main/java/dev/morling/onebrc/CalculateAverage_tivrfoa.java)| 21.0.2-graal | [tivrfoa](https://github.com/tivrfoa) | GraalVM native binary, uses Unsafe |

@tivrfoa tivrfoa force-pushed the exit-loop-earlier-when-new-entry-is-created branch from e0ab6f6 to 14b1319 Compare January 31, 2024 10:41
@tivrfoa
Copy link
Contributor Author

tivrfoa commented Jan 31, 2024

A bit slower now:

Thank you @gunnarmorling !

I made some changes. Could you please run it again?

@gunnarmorling
Copy link
Owner

Still slower:

Benchmark 1: timeout -v 300 ./calculate_average_tivrfoa.sh 2>&1
  Time (mean ± σ):      2.287 s ±  0.007 s    [User: 0.001 s, System: 0.005 s]
  Range (min … max):    2.281 s …  2.298 s    5 runs

Summary
  tivrfoa: trimmed mean 2.284516698433333, raw times 2.2978994541,2.2853571351,2.2840650791,2.2841278811,2.2813756321

Leaderboard

| # | Result (m:s.ms) | Implementation     | JDK | Submitter     | Notes     |
|---|-----------------|--------------------|-----|---------------|-----------|
|   | 00:02.284 | [link](https://github.com/gunnarmorling/1brc/blob/main/src/main/java/dev/morling/onebrc/CalculateAverage_tivrfoa.java)| 21.0.2-graal | [tivrfoa](https://github.com/tivrfoa) | GraalVM native binary, uses Unsafe |

 *   3) Make a cache of long[] name to String, to avoid `ByteBuffer.allocate`
 * and creating new UTF-8 strings. I didn't profile, so it's just a guess
 * that this map will be a bit faster. Although it's outside the main loop, so
 * not a big difference ...;
 *   4) Exit earlier from loop if a new entry was created.
As I was not able to make it faster ... so I'll make it slower,
because my current solution should *not* stay at the top, as it added
basically nothing.
@tivrfoa tivrfoa force-pushed the exit-loop-earlier-when-new-entry-is-created branch from 14b1319 to 3990783 Compare January 31, 2024 23:52
@tivrfoa
Copy link
Contributor Author

tivrfoa commented Jan 31, 2024

Hi @gunnarmorling

The new code will be slower, but you can merge it this way, no problem.
If you could just run the code on master for the 10k before, just curious to see the previous time.

Thanks a lot for 1brc!

I think #1brc will be the best thing for Java in 2024, and we're just in January!!! =D

@gunnarmorling
Copy link
Owner

00:02.995 now for the standard key set. Amongst the top for 10K (I'll update that leaderboard later this week):

# Result (m:s.ms) Implementation JDK Submitter Notes
00:04.570 link 21.0.2-graal tivrfoa GraalVM native binary, uses Unsafe

I think #1brc will be the best thing for Java in 2024, and we're just in January!!! =D

Thank you so much, I really appreciate it! Thanks for participating in 1BRC and congrats on creating one of the top entries!

@gunnarmorling gunnarmorling merged commit fdd539e into gunnarmorling:main Feb 1, 2024
1 check passed
@gunnarmorling
Copy link
Owner

Hey @tivrfoa!

Congrats again on being in the Top 20 of the One Billion Row Challenge!

To celebrate this amazing achievement, I would like to send you a 1BRC t-shirt and coffee mug. To claim your prize, fill out this form by Feb 18. After submitting the form, please provide a comment with the random value you've specified in the form, so that I know it is you who submitted it.

All data entered will solely be used in relation to processing this shipment. Shipments can be sent to any country listed here or here (I'll use whichever one is cheaper for me to ship to your location). A big thank you to Decodable for sponsoring these prizes!

Thanks a lot for participating in 1BRC,

--Gunnar

@tivrfoa
Copy link
Contributor Author

tivrfoa commented Feb 11, 2024

Hey @tivrfoa!

Congrats again on being in the Top 20 of the One Billion Row Challenge!

To celebrate this amazing achievement, I would like to send you a 1BRC t-shirt and coffee mug. To claim your prize, fill out this form by Feb 18. After submitting the form, please provide a comment with the random value you've specified in the form, so that I know it is you who submitted it.

All data entered will solely be used in relation to processing this shipment. Shipments can be sent to any country listed here or here (I'll use whichever one is cheaper for me to ship to your location). A big thank you to Decodable for sponsoring these prizes!

Thanks a lot for participating in 1BRC,

--Gunnar

32228 24253

Thank you! 😄

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.

2 participants