Skip to content

Don't allocate in BTreeMap when only one postbox is needed #819

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

FelixMcFelix
Copy link
Collaborator

We keep track of MsgBlkChains in a BTreeMap today. Sadly this isn't a type which we can preallocate a desired capacity in and store per-CPU. As a result, for flamegraphs in the Rx pathway we can see a moderately chunky call into kmem_alloc within Postbox::post for chains which have one recipient.

This PR special-cases the single-recipient case so that we hold onto one chain and key on the heap until needed.

We keep track of `MsgBlkChain`s in a `BTreeMap` today. Sadly this isn't
a type which we can preallocate a desired capacity in and store per-CPU.
As a result, for flamegraphs in the Rx pathway we can see a moderately
chunky call into `kmem_alloc` within `Postbox::post` for chains which
have one recipient.

This PR special-cases the single-recipient case so that we hold onto one
chain and key on the heap until needed.
@FelixMcFelix FelixMcFelix added perf cleanup Code cleanliness labels Aug 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup Code cleanliness perf
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant