Perf: reduce per-exchange allocations on HTTP/1.1 hot path#631
Merged
Conversation
Skips the per-exchange x-fluxzy-live-edit header scan when not running under Fluxzy Desktop, removing a LINQ allocation and full header walk from the HTTP/1.1 hot path.
Replace List<IDisposable> + MemoryPool<char>.Shared with two inline char[] slots backed by ArrayPool<char>.Shared (plus lazy overflow List). Saves a List allocation per scope and the IMemoryOwner wrapper per rent on the HTTP/1.1 hot path.
RequestHeader.InitSettings and ResponseHeader's constructor plus ReadKeepAliveSettings used First/Any/LastOrDefault on the indexer, each allocating a yield-return iterator per call. Added TryGetFirstHeader, TryGetLastHeader, HasHeaderValueEqualsAny, and HasHeaderValueContains helpers on Header that iterate the backing List directly with its struct enumerator, and rewrote the callers accordingly.
This was referenced Apr 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three small allocation cuts on the HTTP/1.1 MITM path:
x-fluxzy-live-editheader scan behind theFluxzyDesktopVersionenv var (exposed asFluxzySharedSetting.LiveEditEnabled). Standalone fluxzy no longer walks every request's headers looking for a desktop-only debug flag.ExchangeScopenow uses two inlinechar[]?slots plus a lazy overflow list, renting directly fromArrayPool<char>.Shared. Drops the unconditionalList<IDisposable>allocation and theIMemoryOwnerwrapper thatMemoryPool<char>.Shared.Rentreturns per header buffer.TryGetFirstHeader,TryGetLastHeader,HasHeaderValueEqualsAny, andHasHeaderValueContainshelpers onHeaderthat iterate the backingList<HeaderField>via its struct enumerator. RewroteRequestHeader.InitSettings, theResponseHeaderconstructors, andReadKeepAliveSettingsto use them, removing the yield-return iterator allocations from eachFirst/Any/LastOrDefaultcall.Targeting the
UseProxy=True, ServeH2=False, ResponseBodyLength=0row inProxyThroughputBenchmark(~7.7 µs, ~12.6 KB/op).