Skip to content

Commit 044106c

Browse files
committed
QQ: optimise memory for message references.
Currently a message references' smallest representation is an improper list with to integer terms, the Raft index and the message size in bytes. This has a heap overhead of 2 words + 2 words for the cons cell in the queue data structure. This commit introduces a new more compact form that is used if the Raft index is less than 44 bits and the message size is less than 32KiB. In this case the Raft index and message size is packed into a 59 bit integer which is the largest unsigned integer that is still an immedate term and thus has 0 heap overhead as the integer value fits into the pointer word completely. This reduces per message overhead to the 2 words for the cons cell and thus halves message memory use for a lot of scenarios. If a message cannot be packed it will fall back to the current list based representation.
1 parent 186cd03 commit 044106c

File tree

4 files changed

+154
-74
lines changed

4 files changed

+154
-74
lines changed

0 commit comments

Comments
 (0)