Repository navigation
feat(linux): try to set rmem_max and wmem_max on startup - #10349
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
rmem_max and wmem_max on startuprmem_max and wmem_max on startup
There was a problem hiding this comment.
Pull Request Overview
This PR implements automatic tuning of Linux kernel UDP buffer sizes on startup to improve network performance. The default Linux send and receive buffer sizes are too small (~200KB), causing packet drops that correlate with receive buffer errors.
Key changes:
- Automatically sets
net.core.rmem_maxandnet.core.wmem_maxkernel parameters on startup for Linux headless client and Gateway - Increases buffer sizes from 1MB/10MB to 16MB/128MB for send/receive respectively
- Adds
FIREZONE_NO_INC_BUFenvironment variable to disable this behavior
Reviewed Changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| rust/headless-client/src/main.rs | Adds buffer size tuning logic and CLI option to headless client |
| rust/gateway/src/main.rs | Adds buffer size tuning logic and CLI option to Gateway |
| rust/connlib/socket-factory/src/lib.rs | Increases default buffer size constants |
| rust/headless-client/Cargo.toml | Adds socket-factory dependency |
| website/src/app/kb/deploy/gateways/readme.mdx | Updates documentation with new buffer tuning behavior |
| .github/workflows/ci.yml | Updates CI to manually set buffer sizes and check for UDP errors |
4cb5011 to
c8453f0
Compare
There was a problem hiding this comment.
I've guarded this on TCP tests because only those have flow-control.
klochowicz
left a comment
There was a problem hiding this comment.
looks good, just a couple of nitpicks.
There was a problem hiding this comment.
I find it way easier to parse & think about flags when they're formed in positive way, like even as as an end user I'd rather configure INCREASE_BUFFER=0 or TELEMETRY=false (btw: does clap parse true and false from these well? ). some goes for code, it's easier to read.
then again, you're just conforming to existing convention here, so feel free to ignore this comment. :)
There was a problem hiding this comment.
perhaps extract common function?
There was a problem hiding this comment.
I would add a warning that nowother processes on the system can request larger buffers as well, which can have an impact on overall performance if they do.
(perhaps redundant if we applied the suggestion above)
jamilbk
left a comment
There was a problem hiding this comment.
Just want to verify since this is a somewhat substantial system-wide change there won't be any undesired side effects that might cause an issue?
To be honest, the only thing I can say here is "time will tell"? It is only changing the max values, not the default so unless a program is requesting larger buffers, there should be no difference. |
c7eb7d1 to
3171079
Compare
The default send and receive buffer sizes on Linux are too small (only ~200 KB). Checking
nstatafter an iperf run revealed that the number of dropped packets in the first interval directly correlates with the number of receive buffer errors reported bynstat.We already try to increase the send and receive buffer sizes for our UDP socket but unfortunately, we cannot increase them beyond what the system limits them to. To workaround this, we try to set
rmem_maxandwmem_maxduring startup of the Linux headless client and Gateway. This behaviour can be disabled by settingFIREZONE_NO_INC_BUF=true.This doesn't work in Docker unfortunately, so we set the values manually in the CI perf tests and verify after the test that we didn't encounter any send and receive buffer errors.
It is yet to be determined how we should deal with this problem for all the GUI clients. See #10350 as an issue tracking that.
Unfortunately, this doesn't fix all packet drops during the first iperf interval. With this PR, we now see packet drops on the interface itself.