Closed Stebalien closed 3 years ago
Motivation: pubsub does a noticeable amount of allocation. We were noticing this on a gateway due to pubsub handshake messages.
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.
yeah, the test failure is interesting -- rerunning to see if it is a fluke.
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.
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.
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.