Skip to content

tun: allocate GRO flow capacity on demand - #104

Open
unisequence wants to merge 1 commit into
tailscale:tailscalefrom
unisequence:lowmem/lazy-gro-capacities
Open

unisequence wants to merge 1 commit into
tailscale:tailscalefrom
unisequence:lowmem/lazy-gro-capacities

Conversation

@unisequence

Copy link
Copy Markdown

The Linux GRO tables reserve a full batch of flow entries and iov slots at construction, even when a TUN device is idle. Under the opt-in ts_lowmem build tag, start those slices at one flow and one packet plus header; append still grows to the existing batch limit as traffic requires. Default builds retain their original capacities.

On linux/amd64, BenchmarkLowMemoryGROInit measured 2,294,006–2,294,019 B/op in the default build and 69,872 B/op with ts_lowmem across three runs. This measures construction allocations, not steady-state daemon RSS. The tradeoff is additional allocations while previously cold flows first grow under load; grown backing arrays can remain allocated afterward. Full-batch growth and reset tests cover both TCP and UDP, including many distinct flows.

Validation: go test -tags ts_lowmem ./tun; default go test ./tun.

Signed-off-by: Murad Rabadanov <the21.21@mail.ru>
@unisequence
unisequence marked this pull request as ready for review September 26, 2026 15:25
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.

1 participant