Skip to content

Conversation

szuecs
Copy link
Member

@szuecs szuecs commented Jul 4, 2025

The goal is to simplify the code and use a simple stack data structure with a mutex instead of multiple chains of calls through channels, which all have a lock. We observed in lifo() filters that there is lock contention on high load that reduces linear scalability by number of cores on a single machine.

Here we use 2 goroutines for the TCP accept handler. One that accepts and push on stack and the other that is a throttled hot loop that does stack pop() and sends it to our internal Accept() via channel.

@szuecs szuecs force-pushed the optimize/tcp-lifo branch from ed05740 to 8c1f711 Compare July 15, 2025 08:42
szuecs added 4 commits August 21, 2025 10:04
…ause ReadHeaderTimeoutServer and ReadTimeoutServer are not the right timeouts to use for a tcp queuerefactor: create metrics.NoMetrics to not have to check for nil accessing metrics.Metrics, this might be even an optimization because of omitting branches and compiler can likely figure out that we call an empty body function

test: add good coverage for StackListener and a benchmark
benchmark: stackListner and queueListener

Signed-off-by: Sandor Szücs <[email protected]>
Signed-off-by: Sandor Szücs <[email protected]>
@szuecs szuecs force-pushed the optimize/tcp-lifo branch from 8c1f711 to ad4fe67 Compare August 21, 2025 08:06
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