Skip to content

perf: reuse HTTP client transport instead of cloning it - #1095

Merged
qdm12 merged 1 commit into
masterfrom
perf/fix-http-connection-pooling
Apr 10, 2026
Merged

qdm12 merged 1 commit into
masterfrom
perf/fix-http-connection-pooling

Conversation

@fredericrous

Copy link
Copy Markdown
Collaborator

Summary

  • makeLogClient() was creating a new http.Client with transport.Clone(), giving it a separate connection pool
  • TCP+TLS connections were never reused between update cycles — every cycle paid for new handshakes
  • Now wraps the original client's transport with loggingRoundTripper directly, preserving the connection pool and keep-alive behavior
  • Net effect: -12 lines, simpler code, fewer allocations, real network savings

Fixes #1094

Test plan

  • go build ./... compiles cleanly
  • go test ./... — all tests pass including Test_LogClient
  • Manual: verify debug logging still works when enabled
  • Manual: verify DNS updates succeed with the shared transport

🤖 Generated with Claude Code

makeLogClient() was creating a new http.Client with a cloned transport,
which gave it a separate connection pool. This meant TCP+TLS connections
were never reused between update cycles.

Now wraps the original client's transport with the logging round tripper
directly, preserving the connection pool and keep-alive behavior.

Fixes #1094

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

@qdm12 qdm12 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I'm not sure why the transport was clone anyway

@qdm12
qdm12 merged commit 730e2dd into master Apr 10, 2026
5 checks passed
@qdm12
qdm12 deleted the perf/fix-http-connection-pooling branch April 10, 2026 16:58
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.

perf: makeLogClient clones transport, defeating HTTP connection pooling

2 participants