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
Optimise IndexedSeqOps.foldRight #8929
Conversation
b70b5a1
to
c33a0d0
Compare
CI is showing a failure but I think it's spurious. I don't have the right access on Travis to re-run the task unfortunately. |
I think there's some magic incantation like |
/rebuild |
The travis failure is still being hunted #8921 |
I remain sceptical about using The fact that your benchmark shows an improvement could well be due to overfitting: a new JVM is forked that only executes |
Thanks a lot for the eyes on this and my other PRs @lrytz. Your info about JMH overfitting is fascinating! I hadn't thought of that at all. How about I add a bunch of Otherwise if you and @Ichoran prefer, let me know and I can just ignore the benchmarks and just use iterators at this level. It's no problem :) |
It depends on how much time you're motivated to invest :) Benchmarking is hard, using JMH doesn't magically make it easy. A big difficulty here is that we're looking at an open supertype, changing it affects multiple implementations. In general, I think we have to apply optimizations to individual concrete collection types (like you did for ArraySeq). Even besides benchmark numbers, I beleive that iterator-based implementation is the right default at this level in the collections hierarchy. |
I re-ran benchmarks, this time with a bunch of collection noise in the setup and lo and behold, it made a massive difference to some of the results! See results-02.txt. In terms of what the results tell us are the fastest, nothing changes. while-loops still win against iterators.
|
To clarify, in |
c33a0d0
to
6150705
Compare
Hi all. I think we all got stuck here because a while-loop was being reported as faster by JMH which goes against the intuition and experience of a number of people. I've now updated this PR to only optimise @lrytz Please take another look when you're free. |
6150705
to
a14606d
Compare
Thanks, @japgolly. I didn't manage to find the time to look at and think about your benchmark for the previous version in detail. Pushed a tiny diff to keep the same parameter name. |
Inherited foldRight implementation calls reverse.foldLeft
Full benchmarks results and source: https://github.com/japgolly/misc/tree/scalaBM