-
Notifications
You must be signed in to change notification settings - Fork 39
Add Quicksort benchmark and export benchmark results as an artifact #477
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
Conversation
f0ac6b9
to
4da51b6
Compare
a993847
to
8d1533e
Compare
With this PR, I enable benchmarks in the cabal matrix of the CI, so that we can check performance across versions of linear-base and versions of GHC easily. The thing is, Without any options, In 8d1533e, I pinned the version of By some very (un)fortunate coincidence, @amesgen & I found that if we enable tests ( |
tests: True | ||
benchmarks: True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't you just remove test:True
in a recent commit? What's the story here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously we used cabal
mainly for the CI, and we explicitly passed --disable-tests --disable-benchmarks
to make the build go faster (as we only wanted to check if the library would build). So I thought it wasn't worth it to enable tests in cabal.project
to then override it to False
on every command of the CI. It would result in a different behavior in dependency resolution compared to using cabal
locally without options.
That's also why I cleaned up cabal.project
to a bare minimum in my previous PR, so that compile-time options would be in the config file shared between both stack and cabal, with little/no overrides in cabal.project.
But now, because dependency resolution doesn't succeed on its own without options, we need to chose:
- use a specific version of
filepath
to obtain a valid build plan; that's commit 3a8e25a - OR enable tests and benchmarks as it coincidentally makes the dependency resolution succeed with a valid build plan; that's commit b53b28a
- OR use
--allow-newer
on a per-package basis, but that would require a lot of trial and error, and we might not find a valid build plan that works with all versions of GHC at once
For reference, here is the comparison of generated Core between GHC 9.6 and GHC 9.8 for quicksort. It seems that GHC 9.6
GHC 9.8
Quicksort-GHC-9.6-full.dump-simpl.txt |
I'll be frank: I'm not sure why unboxing of |
I discovered that the I added a commit to address this, but because the change would affect a dozen of files, I'm requesting your approval again :) Let me know if you think a separate PR would be better. |
Yes, please merge the easy things, and split the last commit in a new PR so that you can explain what you did and why. |
a78d659
to
b53b28a
Compare
This PR adds a proper benchmark for quicksort, across 3 methods and 3 list sizes, as encouraged by this thread. It also runs and exports benchmark results to an artifact for each GHC version in the CI matrix so it will be easier to check for potential performance regression in the future. The PR builds upon #479 and #480
Here are the results I got :
GHC 9.4.8
/!\ Done locally on my computer, so ordering between methods is valid, but absolute times should not be compared to other results below /!\
Results below are extracted from artifacts of https://github.com/tweag/linear-base/actions/runs/10851885368
GHC 9.6.6
GHC 9.8.2
GHC 9.10.1
N.B as far as I know, peak memory usage reporting is quite unreliable when several benchmarks are run in a sequence. In particular, I don't think peak memory can go down, only up if the next bench uses more memory. On the other hand, the "allocated memory" and "copied memory" reporting seems decently reliable.
Conclusion
It appears that starting from GHC 9.8, the performance of quicksort using the linear arrays provided by Linear base gets much more efficient than naive quicksort. That may be related to
Ur
unboxing optimization that was initially disallowed on earlier GHC versions.