Conversation
Why 16KB
|
| Feature | Small Quantum (e.g., 1KB) | 16KB Quantum (Optimized) | Large Quantum (e.g., 128KB) |
|---|---|---|---|
| CPU Overhead | High (Heavy scheduling) | Low (Efficient) | Minimal |
| Multiplexing | Granular / Very Fair | Balanced | Poor (Coarsened) |
| Throughput | Suboptimal | High | Maximal |
| Latency (TTFB) | Low | Low | High (Potential blocking) |
Implementation Example (Netty)
// Initialize the distributor with the current connection
WeightedFairQueueByteDistributor dist = new WeightedFairQueueByteDistributor(connection);
// Optimization: 16KB quantum size to balance fairness and high-throughput performance.
// This aligns with the default HTTP/2 MAX_FRAME_SIZE.
dist.allocationQuantum(16 * 1024);
// Apply the distributor to the remote flow controller
remoteFlowController.byteDistributor(dist);
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 3.3 #15983 +/- ##
============================================
- Coverage 60.76% 60.73% -0.03%
+ Complexity 11769 11767 -2
============================================
Files 1948 1949 +1
Lines 88752 88760 +8
Branches 13382 13382
============================================
- Hits 53926 53908 -18
- Misses 29305 29323 +18
- Partials 5521 5529 +8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| * @return a fully initialized {@link Http2RemoteFlowController} instance. | ||
| */ | ||
| public static Http2RemoteFlowController newController(Http2Connection connection) { | ||
| WeightedFairQueueByteDistributor dist = new WeightedFairQueueByteDistributor(connection); |
There was a problem hiding this comment.
UniformStreamByteDistributor might be a better choice?
There was a problem hiding this comment.
No!
Example:
Suppose you have a connection performing two operations simultaneously:
- Stream A: Downloading a 1GB log file (Weight: 16).
- Stream B: A very short control command "STOP_SERVICE" (Weight: 16).
- With
Uniform: It sends 16KB of logs, then 16KB of the command, cycling back and forth. If the network is congested, the critical control command might have to wait in line for a significant amount of time behind the massive log data. - With
WFQ: It can be configured to give Stream B a higher weight. Even if the weights are equal, the WFQ scheduling algorithm manages the "virtual clock" more precisely when handling concurrent streams, ensuring that the control command can be interleaved and dispatched through the data stream at the fastest possible speed.
This reverts commit 2daf878.
What is the purpose of the change?
This PR introduces the TripleHttp2RemoteFlowController, a specialized flow controller for the Triple protocol. It extends Netty's DefaultHttp2RemoteFlowController and optimizes the byte distribution strategy to enhance throughput and performance in high-concurrency scenarios.
Checklist