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

Add multi-core concurrent packet processing #2234

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

joseph-henry
Copy link
Contributor

ZeroTier on multiple threads

This alpha-quality patch enables concurrent processing of packets in the RX and TX directions and appears to improve performance significantly in many situations (but also make some worse). It automatically scales thread count according to std::thread::hardware_concurrency() and can optionally be overridden at start time by setting the ZT_PACKET_PROCESSING_CONCURRENCY environment variable. You can enable CPU pinning at start time via ZT_CPU_PINNING=1.

This has only been tested on Linux and FreeBSD and is not fully implemented in macOS so don't even try.

Example usage (ZT_PACKET_PROCESSING_CONCURRENCY is entirely optional since it'll automatically use all cores):

ZT_CPU_PINNING=1 ZT_PACKET_PROCESSING_CONCURRENCY=4 ./zerotier-one

To force ZeroTier onto one thread:

ZT_PACKET_PROCESSING_CONCURRENCY=1 ./zerotier-one

@laduke
Copy link
Contributor

laduke commented Feb 29, 2024

Awesome!
Can you make it not compile on mac, windows, etc? I know you know it doesn't work there, but it's worth testing ifdefs.
I made myself a branch with all the current PRs, and this one makes that branch not work on my mac (obviously).
I'm not sure if it's feasible to make it local.conf setting, so we can get the code in, but not enabled by default, but that would be cool IMO.

@laduke laduke added this to the 1.14.0 milestone Mar 5, 2024
@joseph-henry joseph-henry removed this from the 1.14.0 milestone Mar 14, 2024
@Sandros94
Copy link

I wonder if this could improve performance on smaller cpus like the ones in commercial NASs

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.

None yet

3 participants