Config.uk, lwipopts.h: Expose TCP_MSL as configurable option#74
Open
harimishal1 wants to merge 1 commit intounikraft:stagingfrom
Open
Config.uk, lwipopts.h: Expose TCP_MSL as configurable option#74harimishal1 wants to merge 1 commit intounikraft:stagingfrom
harimishal1 wants to merge 1 commit intounikraft:stagingfrom
Conversation
lwIP's TCP_MSL (Maximum Segment Lifetime) determines how long connections remain in TIME_WAIT state (2 * TCP_MSL). The default 120-second TIME_WAIT causes severe performance degradation in applications that rapidly cycle TCP connections, as TIME_WAIT PCBs accumulate and stall new connection establishment. Add LWIP_TCP_MSL as a Kconfig integer option under the TCP configuration menu. The default remains 60000ms (preserving current RFC-compliant behavior). Applications with high connection churn (e.g. nginx under repeated benchmarks) can lower this value to reduce TIME_WAIT duration and improve throughput stability. Signed-off-by: misharu <harimishal1@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I was investigating this issue (catalog-core #77) about nginx's poor and unstable performance under repeated stress tests and traced the root cause to
lwIP'sTIME_WAITbehavior.When benchmarking nginx with
wrk -t 14 -d1m -c 30repeatedly, throughput alternates between~5,000 req/s and ~150 req/s. This happens because when connections close, they enterTIME_WAITfor2 * TCP_MSL = 120seconds. WithMEMP_MEM_MALLOC=1(heap mode), pool limits likeMEMP_NUM_TCP_PCBdon't actually bound allocations, so increasingLWIP_NUM_TCPCONhas no effect. The real issue is thatTIME_WAIT PCBsaccumulate and stall new connection establishment in the tcpip thread. I observed 20-30 second delays on TCP handshakes during "bad" runs.lwIPalready definesTCP_MSLwith an#ifndefguard intcp_priv.h, so it's designed to be overridable. This PR exposes it as a Kconfig option (LWIP_TCP_MSL), keeping the default at 60000ms so existing behavior is unchanged.I tested with nginx using TCP_MSL=5000 (TIME_WAIT = 10s):
Verified that c-http, cpp-http, click, and nginx all build correctly with the new option at the default value.