hexresearch / hschain

Other
4 stars 0 forks source link

Performance optimizartions of gossip #520

Open Shimuuar opened 4 years ago

Shimuuar commented 4 years ago

It turns out that current implementation of gossip is suboptimal. What have been observed:

  1. In dioxane benchmarks incresing block size makes throughtput of network worse. This hints that gossip could be superlinear in block size and/or delays from sending large block makes delays introduced by sending large block slows things down

  2. Gossip takes a lot of space in profile:

Screenshot_20191224_144806

What could be done

There're many ways in which we can attack problem.

  1. Monomorphize monad which is used by gossip. It doesn't call any user-provided callbacks so we pay performance price of polymorphic bind but don't use it!

    2.Try to optimize gossip state machine. It's not clear that there are a lot of opportunity there but every bit helps

  2. Maybe we need to rework network abstraction/state machine. Currently TCP assumtionsa re baked quite deeply into NetworkAPI

  3. Maybe gossiping block in small chunks (#21) will improve performance as well

Shimuuar commented 4 years ago

Another possibility of performance optimization is caching serialized messages before they're sent. This way we save on serializing same message repeatedly

Shimuuar commented 4 years ago

Also as @romcheck suggested that we should add metrics for the time needed to send/receive message over network