-
Notifications
You must be signed in to change notification settings - Fork 499
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
xdr and horizon: Optimize compress-marshaling of ledger keys #4071
xdr and horizon: Optimize compress-marshaling of ledger keys #4071
Conversation
When writing this PR I started to wonder why don't we simply marshal the keys normally and hash them? This would:
In other words, do we really need this sort of compression if the result is opaque? |
a4be372
to
0373aa9
Compare
@bartekn PTAL |
0373aa9
to
c517dad
Compare
m = append(m, account...) | ||
dataName := []byte(strings.TrimRight(string(key.Data.DataName), "\x00")) | ||
m = append(m, dataName...) | ||
dataName := trimRightZeros([]byte(key.Data.DataName)) |
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 am surprised this casting to []byte
from string didn't cause an allocation. The escape analysis is probably getting better in Go (it wasn't nearly as good as I would had liked to)
15x CPU time improvement, all allocations were removed
Before:
After:
One of the remaning allocations is, in fact, caused by a call to PoolID.Encode which I think can be removed.