quic/server: wire SharedThreadedPacketWriter into QuicServer and QuicServerWorker#451
Open
afrind wants to merge 4 commits into
Open
quic/server: wire SharedThreadedPacketWriter into QuicServer and QuicServerWorker#451afrind wants to merge 4 commits into
afrind wants to merge 4 commits into
Conversation
Uses eventfd on Linux (EFD_NONBLOCK; counter semantics coalesce multiple flush() calls) and a non-blocking self-pipe on macOS. Wraps a lock-free folly::ProducerConsumerQueue for the data path. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Defines the write/flush/getResult contract for pluggable packet writers. BufQuicBatchResult is moved from IoBufQuicBatch.h to break an include cycle (IoBufQuicBatch → QuicBatchWriter → StateData). Adds conn.packetWriter (unique_ptr<QuicPacketWriter>) to QuicConnectionStateBase; null on all existing paths. Conditionalizes write/flush sites on packetWriter so the inline path is unchanged when no writer is installed. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Drains an EventFdQueue<PacketEntry> on a dedicated EventBase, batching
packets with writemGSO and UDP_SEGMENT (GSO) coalescing where supported.
Key design points:
- GSO chains are restricted to same-connection packets; connIds_ is a flat
per-slot vector (one entry per mmsg slot, the chain-opener's connId).
segsInChain tracks the segment count per chain so the maxSegmentsPerMsg
cap is applied to segments appended, not the mmsg slot index.
- Drain-thread arrays (bufs_, addrs_, opts_, connIds_, segCounts_) are
preallocated to maxMsgsPerCall_ at construction; no per-batch heap
allocation.
- bufs_ is preserved across EAGAIN so retryAndDrain resends the identical
batch via EPOLLOUT without rebuilding.
- maxMsgsBeforeYield (default 10) controls drain-thread fairness.
ConnectionPacketWriter is a per-connection adaptor that forwards write/flush
to the shared writer with the connection's connId attached.
QuicTransportBaseLite gains scheduleWrite() to let the drain thread signal
the connection EVB when the producer should resume after backpressure.
Six USDT tracepoints (shared_packet_writer_{queue_full,enqueue,batch_result,
partial_send,drain_done,yield}) instrument the enqueue and drain paths.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ServerWorker QuicServer::setDrainEventBase() propagates a drain EventBase to each worker. Each worker constructs a SharedThreadedPacketWriter backed by its listening AsyncUDPSocket and installs a ConnectionPacketWriter into every new connection before accept(). queueCapacity is fixed at 4096; maxSegmentsPerMsg is taken from transportSettings_.maxBatchSize. Fatal-error and resume-producer callbacks close connections and call scheduleWrite() respectively. QuicTransportBaseLite gains setPacketWriter() so the worker can install a ConnectionPacketWriter after connection creation. workerQuicEvb_ resolves pre-existing TODO comments in bind() and applyAllSocketOptions(). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@afrind has imported this pull request. If you are a Meta employee, you can view this in D105351238. |
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.
QuicServer::setDrainEventBase() propagates a drain EventBase to each worker.
Each worker constructs a SharedThreadedPacketWriter backed by its listening
AsyncUDPSocket and installs a ConnectionPacketWriter into every new connection
before accept(). queueCapacity is fixed at 4096; maxSegmentsPerMsg is taken
from transportSettings_.maxBatchSize. Fatal-error and resume-producer callbacks
close connections and call scheduleWrite() respectively.
QuicTransportBaseLite gains setPacketWriter() so the worker can install a
ConnectionPacketWriter after connection creation. workerQuicEvb_ resolves
pre-existing TODO comments in bind() and applyAllSocketOptions().