Skip to content

fix(gateway): default to 1 TUN thread on single-core systems#8765

Merged
thomaseizinger merged 4 commits intomainfrom
chore/default-num-threads
Apr 13, 2025
Merged

fix(gateway): default to 1 TUN thread on single-core systems#8765
thomaseizinger merged 4 commits intomainfrom
chore/default-num-threads

Conversation

@thomaseizinger
Copy link
Copy Markdown
Member

On single-core systems, spawning more than one TUN thread results in contention that hurts performance more than it helps.

Resolves: #8760

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 13, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
firezone ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 13, 2025 1:40am

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (1)

rust/gateway/src/main.rs:282

  • Consider adding a validation check in the FromStr implementation for NumThreads to ensure the parsed thread count is non-zero. Passing 0 might cause runtime issues when initializing the TUN device manager.
Ok(Self(s.parse()?))

@jamilbk
Copy link
Copy Markdown
Member

jamilbk commented Apr 13, 2025

Good call on Changelog entry!

@thomaseizinger
Copy link
Copy Markdown
Member Author

Note that this is for the Gateway only. On Linux clients, we will always default to 2 TUN threads. I guess it is unlikely that we run the Linux client on a system with only a single CPU.

@thomaseizinger thomaseizinger added this pull request to the merge queue Apr 13, 2025
Merged via the queue into main with commit e0f9482 Apr 13, 2025
114 checks passed
@thomaseizinger thomaseizinger deleted the chore/default-num-threads branch April 13, 2025 02:11
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.

Never default FIREZONE_NUM_TUN_THREADS to more than the number of CPU cores available

3 participants