spacemeshos / go-spacemesh

Go Implementation of the Spacemesh protocol full node. 💾⏰💪
https://spacemesh.io
MIT License
748 stars 211 forks source link

optimize proposals handler #4177

Closed dshulyak closed 1 year ago

dshulyak commented 1 year ago

it takes an unreasonably long time to process proposal message that includes active set. image

there might be other easy optimizations, it makes sense to get the profile for a handler and optimize just by looking at top time spenders.

ideal solution will use tortoise state to check what do we have in it. since we are relying on tortoise to decode ballot - everything relevant must be available, otherwise this is critical undefined behavior. if something is not found tortoise can return next error:

type ErrorMissingData struct {
     Activations []ID
     Ballots []ID
}

there is also a simpler alternative. add lru cache, but it should be large enough to fit all atxs in the epoch, so it is most likely will require https://github.com/spacemeshos/go-spacemesh/issues/4164 . and generally it will be less clean compared to using tortoise state.

dshulyak commented 1 year ago

this is as expected due to the check in fetcher

image