Skip to content

smp-server: fewer threads and no retained TLS record per client - #1910

Open
shumvgolove wants to merge 3 commits into
masterfrom
sh/fix-conn-mem
Open

shumvgolove wants to merge 3 commits into
masterfrom
sh/fix-conn-mem

Conversation

@shumvgolove

Copy link
Copy Markdown
Collaborator

Each client connection kept memory for its whole lifetime that it did not need:

  • Last received TLS record. tls 1.9 updates its receive state lazily, so every connection kept a reference to the last ~16 KB record until the next one arrived. recvTLS now forces the state after each recvData. This applies to all TLS connections, including clients and proxy-to-relay connections.
  • Two send threads. Command responses and delivered messages had separate sending threads with a send lock. One send loop now handles both.
  • Per-client inactivity thread. Each client had its own thread to disconnect it when inactive. One server-wide thread now sweeps all clients; Client gets a closeTransport action. New test: "Inactive clients".

Threads per connection: 6 → 4.

Server live heap per connection (prodmix: 2000 connections, 22 subscriptions each, traffic):

Before After
busy, -ki2k 111.5 KiB 89.8 KiB
busy, default RTS 236.6 KiB 210.5 KiB
idle, -ki2k 90.2 KiB 68.6 KiB

About 0.8 GiB less at 40k connections. Details: docs/smp-server-memory.md on sh/fix-leak, finding 4.

@shumvgolove shumvgolove changed the title smp-server: fewer threads and no retained TLS record per client. smp-server: fewer threads and no retained TLS record per client Oct 1, 2026

This branch has not been deployed

No deployments
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