libp2p / go-libp2p-pubsub

The PubSub implementation for go-libp2p
https://github.com/libp2p/specs/tree/master/pubsub
Other
317 stars 182 forks source link

feat: re-generate protobufs with gogofaster #422

Closed Stebalien closed 3 years ago

Stebalien commented 3 years ago

This removes the pointer indirection from all values and saves us an allocation. We never actually try to distinguish between a field being missing and the "zero" value anyways.

Stebalien commented 3 years ago

Motivation: pubsub does a noticeable amount of allocation. We were noticing this on a gateway due to pubsub handshake messages.

Stebalien commented 3 years ago

It looks like this is changing the number of messages we're sending, possibly because we're sending "zero values"? We shouldn't be doing that, but it looks like that might be the case.

vyzo commented 3 years ago

yeah, the test failure is interesting -- rerunning to see if it is a fluke.

Stebalien commented 3 years ago

I think that's what might be happening with the test failure.

Ah... we're likely checking "is this slice nil". Unfortunately, if I change:

var x *[]byte
if x == nil
var x []byte
if x == nil

Nothing will break. Will check.

Stebalien commented 3 years ago

Ok, found it. It's because the topic ID will always be encoded now, even if unset. This is more complicated than it's worth for now.