-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Optimize any repeated calls to proto unmarshal and get signers in ante handlers #16738
Comments
First, I would aggregate via a quick grep where we have unmarshal and GetSigners calls. Then I would probably use a generic cache to cache those values s.t. the cache can be passed between ante decorators. |
there are other similar cases, for example in ethermint we have duplicated |
A generalized way would be to have an ante-handler "manager" that simple contains the entire chain and a cache. Then any call could look like: v, ok := cache.Get(getParamsKey)
if ok {
params, ok = v.(Params)
if !ok {
// error
}
} else {
params = GetParams()
// set cache
} Not pretty, but it's generalized. |
lets focus on the changes from getsigner as this may a performance regression. @elias-orijtech any chance you can prioritise this? |
Sure. I think I need more detail, so I'll bring it up in today's call. |
Thanks @elias-orijtech! We can keep it simple for now. |
Is this urgent, or can it wait for my return from vacation start of August? |
its kind of urgent to benchmark this, maybe @odeke-em can jump in? dont want to hold you from vacation |
I took a look at this today, but got stuck on the deep dependency on At @kocubinski's suggestion, I'm aiming for converting
however, the
This doesn't seem immediately fixable, because If anyone has any ideas on how to proceed, I have some time tomorrow as well. |
Why do we need to use rapid at all for benchmarks? |
We don't, but rapidproto is what conveniently generates messages that I assume is close the production messages. Is there another, more suitable, package for generating such messages? |
I would just generate a message or two by hand. What we really want to see here is the time saved by repeated calls on the same method(s) on a given tx, so I don't imagine fuzzing a message type will show us a great deal of insight. |
to avoid duplication could we not do something at compile time where we find all the messages and their signers so when messages come in we already know which value is the signer, this may help avoid any performance regression. cc @kocubinski |
@odeke-em can you post your findings here so we can close this issue |
Thanks @tac0turtle! SynopsisSo some good news, from examining a bunch of profiles, we don't have regressions from repeated calls to proto.Unmarshal and we actually some improvements in the antehandler calls Deep diveFrom examining That change I believe comes from this improvement
82659a7#diff-b94baf116534b68c0bc48cb6f in which if the Tx's .GetSigners method returns a non-nil error it doesn't process any more and indeed the profile picture shows no other processing happens except calling the next ante handler The only places I could see successive calls to proto.Unmarshal were in the obvious place: Wholesome transaction's lifetime profiling through simappI profiled simapp runs for simapp.TestFullAppSimulation, examined results and plenty of profiles between v0.47.0 and v0.50.X, there were 3 extra proto.Unmarshal calls in v0.50.X (139 calls) vs v0.47.0 (136 calls) but I didn't notice any repeated calls to proto.Unmarshal out of the ordinary VerdictI believe that we can go forth with the current release! However myself and @elias-orijtech should and shall be vigilant about getting continuous profiles and examining them then some continuous audits for performance improvements, it shaves the number of AnteHandlers called from 12 down to 2 just in that call for DeliverMsgs |
No description provided.
The text was updated successfully, but these errors were encountered: