mirror of
https://github.com/facebookincubator/mvfst.git
synced 2025-11-07 22:46:22 +03:00
Add option to do an inline write after a read event.
Summary: Presently updateWriteLooper will always schedule a loop callback to do the write loop. Add an option to inline trigger the writes after the read event. Reviewed By: kvtsoy, sharmafb Differential Revision: D62192192 fbshipit-source-id: 30991608f57fbfa097a7522c0731d25b8e528345
This commit is contained in:
committed by
Facebook GitHub Bot
parent
a87f7bdbcb
commit
e81c40b2f7
@@ -1114,7 +1114,7 @@ void QuicTransportBase::updatePeekLooper() {
|
||||
}
|
||||
}
|
||||
|
||||
void QuicTransportBase::updateWriteLooper(bool thisIteration) {
|
||||
void QuicTransportBase::updateWriteLooper(bool thisIteration, bool runInline) {
|
||||
if (closeState_ == CloseState::CLOSED) {
|
||||
VLOG(10) << nodeToString(conn_->nodeType)
|
||||
<< " stopping write looper because conn closed " << *this;
|
||||
@@ -1141,7 +1141,7 @@ void QuicTransportBase::updateWriteLooper(bool thisIteration) {
|
||||
VLOG(10) << nodeToString(conn_->nodeType)
|
||||
<< " running write looper thisIteration=" << thisIteration << " "
|
||||
<< *this;
|
||||
writeLooper_->run(thisIteration);
|
||||
writeLooper_->run(thisIteration, runInline);
|
||||
if (conn_->loopDetectorCallback) {
|
||||
conn_->writeDebugState.needsWriteLoopDetect =
|
||||
(conn_->loopDetectorCallback != nullptr);
|
||||
@@ -1878,7 +1878,7 @@ void QuicTransportBase::onNetworkData(
|
||||
checkForClosedStream();
|
||||
updateReadLooper();
|
||||
updatePeekLooper();
|
||||
updateWriteLooper(true);
|
||||
updateWriteLooper(true, conn_->transportSettings.inlineWriteAfterRead);
|
||||
};
|
||||
try {
|
||||
conn_->lossState.totalBytesRecvd += networkData.getTotalData();
|
||||
|
||||
@@ -705,7 +705,7 @@ class QuicTransportBase : public QuicSocket,
|
||||
void invokeStreamsAvailableCallbacks();
|
||||
void updateReadLooper();
|
||||
void updatePeekLooper();
|
||||
void updateWriteLooper(bool thisIteration);
|
||||
void updateWriteLooper(bool thisIteration, bool runInline = false);
|
||||
void handlePingCallbacks();
|
||||
void handleKnobCallbacks();
|
||||
void handleAckEventCallbacks();
|
||||
|
||||
@@ -75,7 +75,7 @@ void FunctionLooper::runLoopCallback() noexcept {
|
||||
commonLoopBody();
|
||||
}
|
||||
|
||||
void FunctionLooper::run(bool thisIteration) noexcept {
|
||||
void FunctionLooper::run(bool thisIteration, bool runInline) noexcept {
|
||||
VLOG(10) << __func__ << ": " << type_;
|
||||
running_ = true;
|
||||
// Caller can call run() in func_. But if we are in pacing mode, we should
|
||||
@@ -85,6 +85,13 @@ void FunctionLooper::run(bool thisIteration) noexcept {
|
||||
<< " in loop body and using pacing - not rescheduling";
|
||||
return;
|
||||
}
|
||||
if (runInline) {
|
||||
// Running inline, manually trigger a loop body and cancel the loop
|
||||
// callback if it was scheduled.
|
||||
cancelLoopCallback();
|
||||
commonLoopBody();
|
||||
return;
|
||||
}
|
||||
if (isLoopCallbackScheduled() ||
|
||||
(!fireLoopEarly_ && pacingTimer_ && isTimerCallbackScheduled())) {
|
||||
VLOG(10) << __func__ << ": " << type_ << " already scheduled";
|
||||
|
||||
@@ -51,7 +51,7 @@ class FunctionLooper : public QuicEventBaseLoopCallback,
|
||||
* Starts running the loop callback in each loop iteration.
|
||||
* if this is already scheduled to run, run() will continue to run it.
|
||||
*/
|
||||
void run(bool thisIteration = false) noexcept;
|
||||
void run(bool thisIteration = false, bool runInline = false) noexcept;
|
||||
|
||||
void setPacingFunction(
|
||||
folly::Function<std::chrono::microseconds()>&& pacingFunc);
|
||||
|
||||
@@ -403,6 +403,9 @@ struct TransportSettings {
|
||||
bool checkIdleTimerOnWrite{false};
|
||||
// Whether to process callbacks per received packet.
|
||||
bool processCallbacksPerPacket{false};
|
||||
// Whether to trigger an inline write loop after we've read packets, rather
|
||||
// than deferring to a loop callback.
|
||||
bool inlineWriteAfterRead{false};
|
||||
};
|
||||
|
||||
} // namespace quic
|
||||
|
||||
Reference in New Issue
Block a user