-
Notifications
You must be signed in to change notification settings - Fork 67
Move to bytestring Builder #65
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
Good stuff. @kolmodin I'd like your involvement. In principle this is the direction we've wanted to go, once bytestring builder was sufficiently widely deployed. And now that the perf issue that @kolmodin found before seems to be resolved then seems like we should get on with it. Any API compat issues that we need to think about? |
What's the cause of the regressions in 7.10?
|
As a follow-up we should look at the |
@tibbe If I was following correctly, it was more that the |
There are definitely some questions regarding how we want to merge this. Without haskell/bytestring#40 we regress quite heavily on GHC 7.6 and 7.10. Below is a comparison between
GHC 7.8 is quite consistent. With GHC 7.6 and 7.10, however, the small regressions with the fix balloon into several-hundred-percent regressions without. This all suggests that it would likely be good to at least understand these regressions that remain after haskell/bytestring#40 before we move on this. If it looks like further fixing these will require further changes in |
Aside: from your first set of benchmarks this is a curious result:
These benchmarks look quite similar at a first glance, but binary performs widely different one these. |
@tibbe that is indeed quite interesting. Could this be the result of unaligned accesses? |
It's indeed tricky to define binary's builder in terms of bytestring, since bytestring will only be fast in the very last release. We'd have to require Perhaps we could keep the old implementation inside some |
Alignment shouldn't an issue for |
@tibbe the other way to look at it is that the numbers with a slow |
edit I was wrong, it's actually the simplifier as one might expect. This arises after the initial Presumably it feels as though expressions of the form |
Unfortunately fixing this may require GHC changes. It seems that GHC introduces sharing when it floats the While our binding is almost certainly small enough, it is used in all (two!) branches of the I'm not really sure of what to blame this on. While from a human's perspective floating out something like |
This is good work. In the branch I had I used CPP to rely on the ByteString
|
With this Of course, it's totally unclear that this patch is the fix that we
|
The cause of the "Host endian/1MB of Word8 in chunks of 16" benchmark's slowness is being tracked as https://ghc.haskell.org/trac/ghc/ticket/10012 |
@bgamari Did your fix go into GHC? |
@kolmodin it did not make it upstream nor is it entirely clear that it's the right solution as it is a very big hammer which may have unintended consequences. At this point this work is blocked on my finishing my thesis and finding a free weekend or two. Indeed, I have a small Python hack which takes the CSV output from Criterion and renders a table. |
bump What's the current situation of this one? Is this GHC 8.0 material? |
Unfortunately it's not. @bgamari explains in #65 (comment) that it depends on a patch to GHC that has not been merged. |
Indeed; this is because we really don't know the right way to fix this yet. However, I'll add this ticket to my todo list. It seems likely that doing a better job optimizing this case could help a substantial amount of code. |
be31bd7
to
93a49d0
Compare
With haskell/bytestring#40 resolved it should finally be possible to move
binary
tobytestring
'sBuilder
. This addresses #37.The following is a comparison of
benchmarks/Builder.hs
with three GHC versions. The first column is the mean time of theData.Binary.Builder
, the second is the mean ofData.ByteString.Builder
, and the third is the percent change relative toBinary.Builder
.There are still a couple of sticky spots but I think these are made up for by the great improvements made elsewhere. I'll try having a look at these sticky spots soon.