-
Notifications
You must be signed in to change notification settings - Fork 43
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
Improve performance of String and Vec<u8> #58
Conversation
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.
Is it possible that https://doc.rust-lang.org/std/io/struct.BufReader.html implements this very functionality?
I think we can use BufReader with raw fill_buf() functionality for a lot of what I did manually with read_exact |
Input Highlights for gas fess:Cost of Borsh input of (s: String) where s="" is 9,080,640,736 Full results: near/nearcore#1829 (comment) TODO: Add Vec<_> tests |
Could you rerun https://github.com/nearprotocol/borsh/tree/master/borsh-rs/benchmarks and re-generate the graphs? |
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.
Could you also update the benchmarks so that http://borsh.io/ picks them up?
Could you also bump the versions? |
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.
P.S. My github UI is chocking on 8k files :) Could we please remvoe the docs temporarily until we are through the reviews and then add them later before the merge?
Trying switch to |
See #62 for slice reader version. Need to fix benchmarks, but overall looks clean. Also once we switch serialize to |
* Switch to mut buf * Fix benchmarks:
Going to regenerate benchmarks with the slice run |
Merged buf slice branch, so it's ready to go (once the new benchmarks are added) |
@@ -1 +1,2 @@ | |||
docs/* linguist-vendored | |||
docs/criterion/** linguist-generated=true -diff |
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.
How is it different from linguist-vendored
and what does -diff
do?
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.
I don't know. It's used by nearcore
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.
Also I'm not sure why you would request changes based on the question? Which changes do I need to make?
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.
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.
I somehow failed to duckduckgo this info. It should've been a comment instead of request for changes.
Optimizing strings/vec reads using custom implementation for
Vec<u8>
with a bit of unsafe code, but without UB.Switching deserialization to use
&mut &[u8]
instead ofBufRead
. It allows us to switch toBorshError
instead ofstd::io::Error
in the future to go withno_std
.Test plan
String
andVec<T>