Skip to content
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

feat(multiplexer): Use single channel for muxer #133

Merged
merged 2 commits into from
Jun 20, 2022
Merged

Conversation

scarmuega
Copy link
Member

@scarmuega scarmuega commented Jun 20, 2022

The muxer loop uses a lock-free spin to iterate over available ingress channels to select the next payload to be muxed. This is not very efficient since we end up performing a lot of wasted cycles, even when using some backoff mechanism (such as the snooze function in the crossbeam crate).

This PR resolves the problem by relying on a single ingress channel, which provides a blocking mechanism using OS-primitives. This removes the need for a loop altogether. After some initial testing, we see that an example chainsync process against a local node maintains the same throughput (~1.5k blocks / sec) while drastically reducing the amount of required CPU (<4%).

The downside (?) is that now the muxer messages will processed in a FIFO fashion, instead of the randomized approach used in the actual implementation. This seems like a valid trade-off, possible even better for certain use-cases.

@scarmuega scarmuega marked this pull request as ready for review June 20, 2022 02:04
@scarmuega scarmuega merged commit 1984488 into main Jun 20, 2022
@scarmuega scarmuega deleted the feat/single-muxer branch June 20, 2022 19:06
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.

1 participant