Add Payload.serializedSize() 11/101211/9
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 18 May 2022 07:15:22 +0000 (09:15 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 26 May 2022 18:08:35 +0000 (20:08 +0200)
There is a rather big difference in payload sizing when we consider
how big an entry is: in-memory size can easily be "zero", which can
translate to a serialized size of hundreds of bytes. This difference
is problematic, as we use the former to estimate how many payloads
we can squeeze in AppendEntries and we compare that to the configured
payload limit. Even when there is some (32KiB by default) cushion, we
can end up blowing past the frame size.

Add Payload.serializedSize(), which should provide a semi-conservative
estimate of serialized size and use that to select the cut-off.

Also improve SimpleReplicatedLogEntry's estimates by performing a a
quick serialization operation -- which reduces potential waste for each
entry by 294 bytes, as our hard-coded estimate of 400 bytes was way too
conservative.

JIRA: CONTROLLER-2037
Change-Id: I5abe7d00db9e10f1c66e6db0f7c82854f9aa352d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>

No differences found