-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
sysctl: Enable linear RTO for thin TCP streams #4238
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
sysctl: Enable linear RTO for thin TCP streams #4238
Conversation
📝 WalkthroughWalkthroughAdds a sysctl configuration block enabling thin TCP linear timeouts by inserting Changes
Sequence Diagram(s)Not applicable — configuration-only change; no control-flow or runtime interaction modifications to diagram. Estimated code review effort🎯 2 (Simple) | ⏱️ ~7 minutes Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. 📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro Cache: Disabled due to data retention organization setting Knowledge Base: Disabled due to data retention organization setting 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
buildroot-external/rootfs-overlay/usr/lib/sysctl.d/25-thin-tcp.conf (2)
1-2: Enrich the comment with context and a reference to the kernel definitionHelps future maintainers understand scope (“thin” = packets_out < 4) and rationale at a glance.
Apply this diff to expand the header comment:
-# Enable linear timeouts for thin TCP streams +# Enable linear RTO backoff for "thin" TCP streams. +# "Thin" per kernel: tp->packets_out < 4 and not in initial slow start. +# Ref: tcp_stream_is_thin(tp) in include/net/tcp.h +# Rationale: reduce tail latency for API-style connections after sporadic loss. net.ipv4.tcp_thin_linear_timeouts = 1
2-2: Optional: Consider also enabling tcp_thin_dupack for thin flowsIf your goal is to further improve recovery on thin flows, enabling fast retransmit after 1 dup-ack for thin streams (tcp_thin_dupack) can help on high-loss/latency links. It’s a broader behavior change; evaluate carefully before adopting.
Potential addition:
net.ipv4.tcp_thin_linear_timeouts = 1 +net.ipv4.tcp_thin_dupack = 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
buildroot-external/rootfs-overlay/usr/lib/sysctl.d/25-thin-tcp.conf(1 hunks)
🔇 Additional comments (2)
buildroot-external/rootfs-overlay/usr/lib/sysctl.d/25-thin-tcp.conf (2)
2-2: LGTM: Enabling linear RTO for thin TCP flows is reasonable and low-riskThis aligns with the stated objective and should help reduce tail latency on API-style connections with very small inflight windows. Syntax and placement under /usr/lib/sysctl.d are correct for systemd-sysctl.
2-2: Confirm kernel config and no duplicate overrides
- Verified no other occurrences of
net.ipv4.tcp_thin_linear_timeoutsoutside of
buildroot-external/rootfs-overlay/usr/lib/sysctl.d/25-thin-tcp.conf:2.- No
CONFIG_TCP_THIN_LINEAR_TIMEOUTSreferences found in this repo; please ensure your kernel build enables this option so the sysctl takes effect.
a2919bd to
d0a3d8a
Compare
|
The first suggestion by code rabbit makes sense, I've added more details to the file's comment. The second suggestion doesn't make any sense, because this option was removed from the Linux-Kernel 4.11 - commit 4a7f600944114. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
buildroot-external/rootfs-overlay/usr/lib/sysctl.d/25-thin-tcp.conf (2)
1-4: Good rationale; add the canonical source link and a brief scope note.Inline the exact kernel link for traceability and clarify that non-thin flows remain unchanged.
# Ref: tcp_stream_is_thin(tp) in include/net/tcp.h +# Link: https://github.com/torvalds/linux/blob/90d970cade8e67e20b09bbfdc2f0b52064322921/include/net/tcp.h#L2231 # Rationale: reduce tail latency for API-style connections after sporadic loss. +# Note: Non-thin flows retain the default exponential RTO backoff; this only affects streams where tcp_stream_is_thin(tp) is true.
1-7: Optional: Consider enabling tcp_thin_dupack for even faster loss recovery on thin flows.This complements linear RTO by retransmitting on the first dupack for thin streams, which can further reduce tail latency for sparse API-style exchanges. Caveat: slightly more sensitive to reordering on certain networks.
# Rationale: reduce tail latency for API-style connections after sporadic loss. +# Optional: Retransmit on first dupack for thin streams (can further reduce tail latency). +# Caveat: More sensitive to reordering on some links. +# See: net.ipv4.tcp_thin_dupack (Documentation/networking/ip-sysctl) net.ipv4.tcp_thin_linear_timeouts = 1 +## Uncomment to enable more aggressive dupack behavior for thin streams +# net.ipv4.tcp_thin_dupack = 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
buildroot-external/rootfs-overlay/usr/lib/sysctl.d/25-thin-tcp.conf(1 hunks)
🔇 Additional comments (1)
buildroot-external/rootfs-overlay/usr/lib/sysctl.d/25-thin-tcp.conf (1)
6-6: LGTM: Enable linear RTO for thin streams – Verified no other instances ofnet.ipv4.tcp_thin_linear_timeoutsor other thin-TCP settings across the repo; this is a safe, scoped tuning.
Set net.ipv4.tcp_thin_linear_timeouts=1 to switch retransmission timeout (RTO) backoff from exponential to linear for 'thin' TCP flows. This reduces tail latency for API-style connections that typically have very few packets in flight, improving recovery from sporadic loss without changing anything for larger TCP transfers. Kernel definition: A flow is considered thin when 'tp->packets_out < 4' and while not in the initial slow start. See tcp_stream_is_thin(tp) in include/net/tcp.h.
d0a3d8a to
f20619e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
buildroot-external/rootfs-overlay/usr/lib/sysctl.d/20-network.conf (1)
9-13: Tighten wording and add a permalink to the kernel helper for future maintainersMinor doc nit: the helper checks “not in slow start” (not specifically “initial”). Including a stable permalink makes the intent auditable later.
-# "Thin" per kernel: tp->packets_out < 4 and not in initial slow start. -# Ref: tcp_stream_is_thin(tp) in include/net/tcp.h -# Rationale: reduce tail latency for API-style connections after sporadic loss. +# "Thin" per kernel: tp->packets_out < 4 and not in slow start. +# Ref: tcp_stream_is_thin(tp) in include/net/tcp.h: +# https://github.com/torvalds/linux/blob/90d970cade8e67e20b09bbfdc2f0b52064322921/include/net/tcp.h#L2231 +# Rationale: reduce tail latency for API-style connections after sporadic loss; no effect on larger transfers.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
buildroot-external/rootfs-overlay/usr/lib/sysctl.d/20-network.conf(1 hunks)
🔇 Additional comments (1)
buildroot-external/rootfs-overlay/usr/lib/sysctl.d/20-network.conf (1)
14-14: Verification Complete: No Conflicts and Broad Kernel Support Confirmed
- No other occurrences or overrides of
net.ipv4.tcp_thin_linear_timeoutsfound in the repo.- Confirmed present and not deprecated in Linux 6.1, 6.6, 6.10 (and later) kernels per kernel docs and source.
LGTM—enabling linear RTO for thin streams is a safe, targeted improvement.
sairon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see this change as aggressive as #4239 (as it only changes behavior for thin streams) but I have similar concerns as I raised in the other issue.
Eventually, any sysctl parameters can be changed by power users who know what they're doing via override in /etc/sysctl.d/ (which is writable on HAOS) but to make the change global, I'd like to see some measurable impact to be convinced the RFC violation is worth it.
|
@sairon while technically true, it violates the compliance with RFC 6298, the positive effect of doing something like this has been proven in real world applications quite often and is implemented as TLP with SACK-enabled streams. While both approaches cannot be 1:1 compared, the idea behind both is very similar. TLP is enabled by default in the Linux kernel. However, TLP's limitation of requiring RACK, which is requiring TCP SACK to work, makes it unavailable for non-SACK connections. Non-SACK connections are extremely niche, so not much effort are put into them anymore to improve anything about them. The only use case are very small TCP stacks, like the one in embedded devices, which is why knobs like the linear timeout switch in the Linux kernel exists in the first place - there's no RFC but there's a need to improve the recovery time on latency sensitive non-SACK connections, because there's no TLP available. Since Home Assistant is expected to communicate with a lot of embedded devices which do not support TCP SACK (all ESPHome devices for example come to mind here) enabling this setting does make sense IMHO. Especially since enabling it is not breaking any usecase. |
|
Okay, that makes sense. Let's go with the change, I just remove the extra newlines in the file. |
Set
net.ipv4.tcp_thin_linear_timeouts=1to switch retransmission timeout (RTO) backoff from exponential to linear for 'thin' TCP flows. This reduces tail latency for API-style connections that typically have very few packets in flight, improving recovery from sporadic loss without changing anything for larger TCP transfers.Kernel definition: A flow is considered thin when
tp->packets_out < 4and while not in the initial slow start.See tcp_stream_is_thin(tp) in include/net/tcp.h.
Summary by CodeRabbit