-
Notifications
You must be signed in to change notification settings - Fork 71
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
feat: add borsh::object_length
helper
#236
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
group base new
----- ---- ---
ser_account/borsh::object_length(obj).unwrap()/idx=0; size=191 1.00 0.4±0.01ns 415.3 GB/sec 1.00 0.4±0.01ns 415.3 GB/sec
ser_account/borsh::object_length(obj).unwrap()/idx=1; size=168 1.00 0.4±0.01ns 363.5 GB/sec 1.00 0.4±0.01ns 363.5 GB/sec
ser_account/borsh::object_length(obj).unwrap()/idx=2; size=90 1.00 0.4±0.01ns 199.3 GB/sec 1.00 0.4±0.01ns 199.3 GB/sec
ser_account/borsh::to_vec(obj).unwrap().len()/idx=0; size=191 1.00 19.1±0.33ns 9.3 GB/sec 1.00 19.1±0.33ns 9.3 GB/sec
ser_account/borsh::to_vec(obj).unwrap().len()/idx=1; size=168 1.00 18.2±0.23ns 8.6 GB/sec 1.00 18.2±0.23ns 8.6 GB/sec
ser_account/borsh::to_vec(obj).unwrap().len()/idx=2; size=90 1.00 19.2±1.26ns 4.4 GB/sec 1.00 19.2±1.26ns 4.4 GB/sec |
dj8yfo
force-pushed
the
borsh_object_length
branch
2 times, most recently
from
September 28, 2023 13:56
c29a813
to
b2408cb
Compare
dj8yfo
force-pushed
the
borsh_object_length
branch
3 times, most recently
from
September 28, 2023 17:47
f5c5be3
to
fc803e5
Compare
dj8yfo
commented
Sep 28, 2023
self.len = match res { | ||
Some(res) => res, | ||
None => { | ||
return Err(ErrorKind::OutOfMemory.into()); |
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.
replacing this line with
return Err(Error::new(ErrorKind::InvalidData, "overflow"));
results in much slower bench
time: [+1707.9% +1716.3% +1726.3%] (p = 0.00 < 0.05)
thrpt: [-94.524% -94.494% -94.469%]
Performance has regressed.
dj8yfo
force-pushed
the
borsh_object_length
branch
from
September 28, 2023 17:57
fc803e5
to
e5e1bf6
Compare
frol
approved these changes
Sep 28, 2023
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.
Thank you for baking it into borsh!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
resolves #23
in scope of work on nearcore update it was noticed that
pattern
borsh_obj.try_to_vec().unwrap().len()
was used quite a few times,thus it may be a slight optimization to replace this pattern with computing length without memory allocation: