Skip to content

rabbit_fifo: Use optimised tuple for delayed keys#15649

Merged
kjnilsson merged 2 commits intora-v3from
md/ra-v3-delayed-optimised-tuple
Mar 9, 2026
Merged

rabbit_fifo: Use optimised tuple for delayed keys#15649
kjnilsson merged 2 commits intora-v3from
md/ra-v3-delayed-optimised-tuple

Conversation

@the-mikedavis
Copy link
Copy Markdown
Collaborator

@the-mikedavis the-mikedavis commented Mar 5, 2026

This is a very small space-saving measure. {ReadyAtMillis, MsgIdx} becomes [ReadyAtMillis | MsgIdx] for the #delayed{} state, saving a small number of bytes per key when serialized. This optimised tuple type is already used in a few other places in rabbit_fifo for a similar space-saving effect.

There is also a commit to remove #delayed.len since the tree size is already tracked at the top-level tuple of a gb_trees:tree().

@the-mikedavis the-mikedavis force-pushed the md/ra-v3-delayed-optimised-tuple branch from 1899d53 to acbd708 Compare March 6, 2026 02:16
@the-mikedavis the-mikedavis marked this pull request as ready for review March 6, 2026 02:28
@the-mikedavis the-mikedavis requested a review from kjnilsson March 6, 2026 03:02
This is a very small space-saving measure. `{ReadyAtMillis, MsgIdx}`
becomes `[ReadyAtMillis | MsgIdx]` for the `#delayed{}` state, saving a
small number of bytes per key when serialized. This optimised tuple type
is already used in a few other places in `rabbit_fifo` for a similar
space-saving effect.
`gb_trees:size/1` is constant time - the size is stored at the top-level
tuple.

    -doc "Returns the number of nodes in `Tree`.".
    -spec size(Tree) -> non_neg_integer() when
          Tree :: tree().
    size({Size, _}) when is_integer(Size), Size >= 0 ->
        Size.

So we don't need to manually track the tree size with a len field. This
change removes the field.
@the-mikedavis the-mikedavis force-pushed the md/ra-v3-delayed-optimised-tuple branch from acbd708 to 8498e10 Compare March 6, 2026 15:39
@kjnilsson kjnilsson merged commit a0e9b40 into ra-v3 Mar 9, 2026
184 of 185 checks passed
@kjnilsson kjnilsson deleted the md/ra-v3-delayed-optimised-tuple branch March 9, 2026 10:00
@michaelklishin michaelklishin added this to the 4.3.0 milestone Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants