You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
perf(adaptor,proxy): cut per-request copies and allocations
adaptor (net/http -> fiber path in handlerFunc):
- Build the fasthttp request directly into the pooled RequestCtx instead
of filling a standalone Request and CopyTo-ing it across. Init2 only
touches connection metadata and buffer-retention flags, so in-place
construction is exactly fasthttp's own Init order minus the full
header+body copy. A fresh-body 1MB request drops ~35% in ns/op and
four allocations.
- Pool the noopConn together with the RequestCtx and share one stateless
disabledLogger, removing two per-request allocations.
- resolveRemoteAddr takes a fast path for numeric ip:port literals — the
only form net/http servers produce — via utils.ParseIPv4/ParseIPv6
and a strict decimal port parse, skipping net.ResolveTCPAddr's
resolver machinery; hostnames and service ports still fall back to
it. A new test pins the fast path to ResolveTCPAddr's results,
including IPv6 zones and leading-zero forms.
proxy:
- Strip Connection-listed headers by iterating the header value bytes
in place instead of materializing a string copy and a name slice:
BenchmarkStripHopByHop_WithConnection goes from 1565ns/72B/3allocs
to ~958ns with zero allocations. The names alias the value buffers,
which is sound because fasthttp's Del re-slices the entry list
without rewriting other entries' buffers. The fuzz harness now
exercises deletion against a real header.
- followRedirects renders each hop's URL once instead of twice,
removing a URL.String() allocation per hop.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E5sm1LHEnvEVDRGsHWFfKK
0 commit comments