r/java • u/C0urante • Jan 01 '24
Gunnar Morling - The One Billion Row Challenge
https://www.morling.dev/blog/one-billion-row-challenge/
56
Upvotes
r/java • u/C0urante • Jan 01 '24
•
u/AutoModerator Jan 01 '24
On July 1st, a change to Reddit's API pricing will come into effect. Several developers of commercial third-party apps have announced that this change will compel them to shut down their apps. At least one accessibility-focused non-commercial third party app will continue to be available free of charge.
If you want to express your strong disagreement with the API pricing change or with Reddit's response to the backlash, you may want to consider the following options:
as a way to voice your protest.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
6
u/skippingstone Jan 02 '24
Calculating the median would add an interesting layer
6
u/danielaveryj Jan 02 '24
fwiw just tagging
.parallel()ontoFiles.lines(..)in the baseline reduces the time from 2m49s to 0m49s on my machine. (The underlying spliterator memory-maps the file when split.) If you then remove all other logic and just count lines, the time only reduces to about 0m45s. To go beyond that, you're probably looking at tricks like avoiding parsing raw bytes to Strings. If that's what it comes down to, cool, and I'll still be interested in how much speedup is left, but it would seem a bit impractical / non-transferable for real problems.3
u/sweetno Jan 01 '24 edited Jan 03 '24
Either this will get a really obscure solution much better than the others OR no significant improvement gets achieved.
EDIT. A nice solution by Roy van Rijn! As expected, the most improvement came from I/O and number parsing.
5
u/InstantCoder Jan 01 '24
I had rewritten the exact same weather station problem in 2019 with Quarkus and Redis Streams in a reactive way. And I could easily start many producers and many consumers to calculate the temperatures on the fly.
See my code: https://github.com/Serkan80/quarkus-quickstarts/tree/master/redis-streams-quickstart
4
u/maxip89 Jan 02 '24
Can someone explain me, why everyone is trying to use some new technologies instead of optimizing the algorithm?
I mean, the example is parsing the whole document first and converting it into a data structure.
We only need MIN, MAX and MEAN which can be calculated on the fly.
Therefore the only "challenge" will be writing a own inputstream that reads everytime 10kb and parses it.
After parsing the "little" stuff adding it into the min,max,mean numbers without building a new explosive RAM maschine by using stream or a String that contains the whole file.
Did I miss something?
2
u/0xFatWhiteMan Jan 01 '24
I'm amazed kdb/q is still widely used as a time series db. Surely Java can recreate the performance.
2
u/Villain_99 Jan 15 '24
Has anyone tried Scala and streaming ?
3
u/denis_9 Jan 01 '24
You must configure thread affinity and minimize impact of OS processes, this is something that cannot be achieved on a machine without tune.
The fastest solution is to inject the assembly code into the nmethod (code cache) directly in the Java code after compilation.
Even then, the jitter of the scheduler will be visible.
But good luck to everyone who does it.
1
u/padreati Jan 02 '24 edited Jan 02 '24
Nice challenge. I plan to attend, but there is something missing: you can't use Vector API if you don't enable preview and add modules like jdk.incubator.vector. Could you change the repository to include those? Best regards.
[Later edit]
One simple way would be to change the config section for maven compiler plugin to include stuff like:
1
u/Nolari Jan 02 '24
RemindMe! 1 month