-
Notifications
You must be signed in to change notification settings - Fork 67
Move to bytestring Builder #111
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
The performance numbers are presented in a little different way than last year. The numbers present are from benching with the patch applied (I assume), but no comparison to without the patch? Other than that, just like last year, since the patch is doing mostly good I agree that it's probably a good idea to merge it. |
src/Data/Binary/Builder.hs
Outdated
----------------------------------------------------------------------------- | ||
-- | | ||
-- Module : Data.Binary.Builder | ||
-- Module : Data.Binary.Builder.Base |
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.
The github UI is not helpful here. Was this file moved?
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.
Nope, just a rebase error it seems. Thanks for catching this.
That is correct; I believe the only difference between the table I presented last time and this one is the addition of standard deviations. The methodology is similar, however. |
93a49d0
to
e61024b
Compare
src/Data/Binary/Builder.hs
Outdated
------------------------------------------------------------------------ | ||
|
||
-- | ||
-- We rely on the fromIntegral to do the right masking for us. |
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.
This comment could be moved further down where we the fromIntegrals are.
Does the fromIntegral do any masking here? Looks like it's just converting between Int and Word.
Previously there was a comparison with/without the patch so the performance difference could be seen. |
The table in this patch is similar: the first column is the benchmark name, the second is benchmark results without the patch, the third is with the patch, the last column is the percent change. I've added to column headings to the table to make this more clear. |
e61024b
to
3ad2041
Compare
3ad2041
to
922592e
Compare
Oh. There was no indication that I could scroll the text sideways (chrome on Mac), sorry. Now I see it all. |
@kolmodin do you expect to merge this? If so it would be great if it could happen soon so I can bump the version shipped with GHC 8.0.1-rc3. |
I ran the GenericBenchmark which showed a 10% increase in time spent in the "encode" benchmark. The generic benchmark encodes/decodes many cabal Except for the builder benchmarks, I don't have any indication that other code has been slowed down. Another idea would be to further improve strings. We could try the old trick; class Binary a where
--- ...
putList :: [a] -> Put
putList = defaultPutList
defaultPutList :: [a] -> Put
defaultPutList = ...
instance Binary Char where
put = ...
putList = {- use bytestring builder to write the whole thing in one go -}
instance Binary a => Binary [a] where
-- ...
put = putList ByteString Builder says that should be more efficient. |
I'll work on merging this and will try to release it unless I run into something unexpected. |
Lennart Kolmodin notifications@github.com writes:
|
Why did you use the functions from |
Lennart Kolmodin notifications@github.com writes:
However, if you want to tighten up the bounds a bit I suspect you can |
Aha, ok. No, I think we can leave it then. When using I also tried the
I think that would motivate changing the I'll wrap this up in a series of patches and merge it together with your work. On a side note, while working on this I ran into something quite interesting. Try this;
That is very unintuitive to me. What's going on? |
I'll try to merge the changes this Sunday. Until then, you can have a look at this new branch at https://github.com/kolmodin/binary/tree/pr/bytestring-builder |
Merged, but still need some time to wrap things up for the release. |
This is a continuation of the effort moving
binary
tobytestring
'sBuilder
, started in #65. This branch is a rebase of the original branch. The performance story isn't so different from last year,There are a few places where performance could certainly be improved, although this appears to be a net improvement. As expected, the regression in
Host endian/1MB of Word8 in chunks of 16
persists, due to GHC #10012. It's still quite unclear what should be done about this.Regardless, I have observed at least one instance in the wild where the intelligence that
bytestring
'sBuilder
applies to deciding whether to add a chunk or copy would help remarkably (asbinary
'sBuilder
ends up generating lazy bytestrings with many unreasonably small chunks).Given the fact that the benchmarks seem to be a net improvement, I think we should consider merging this and examine how to improve performance further (which will likely require compiler work)