Loading src/quic.cpp +26 −2 Original line number Diff line number Diff line Loading @@ -1718,9 +1718,17 @@ void quic::handshake_after_accept() { pmtudTick(); } // Collect pending dispatches before releasing lock // Collect pending dispatches before releasing lock. Re-reserving right // after the move (which leaves _pending_dispatches at capacity 0) // trades one allocation now, sized for the whole next batch, for what // would otherwise be several reallocations later as push_back() grows // it 1->2->4->... from scratch on the next round of incremental // dispatches (F49) — using this batch's size as the hint since batch // sizes are typically steady under sustained load. size_t dispatch_batch_hint = _pending_dispatches.size(); dispatches = std::move(_pending_dispatches); _pending_dispatches.clear(); _pending_dispatches.reserve(dispatch_batch_hint); } // Release _quic_mutex // Dispatch stream callbacks outside the lock Loading Loading @@ -1980,8 +1988,12 @@ void quic::accept(std::unique_ptr<socket>& csock, bool nonblock) { } if (!existing->_pending_dispatches.empty()) { // See the intra-connection dispatch call sites' comment on // why capacity is re-reserved right after the move (F49). size_t dispatch_batch_hint = existing->_pending_dispatches.size(); std::vector<PendingDispatch> dispatches = std::move(existing->_pending_dispatches); existing->_pending_dispatches.clear(); existing->_pending_dispatches.reserve(dispatch_batch_hint); child_lock.unlock(); quic::scheduleDispatches(existing, std::move(dispatches)); child_lock.lock(); Loading Loading @@ -2154,8 +2166,12 @@ void quic::accept(std::unique_ptr<socket>& csock, bool nonblock) { // Dispatch stream callbacks off-thread (see scheduleDispatches) if (!existing->_pending_dispatches.empty()) { // See the intra-connection dispatch call sites' comment on // why capacity is re-reserved right after the move (F49). size_t dispatch_batch_hint = existing->_pending_dispatches.size(); std::vector<PendingDispatch> dispatches = std::move(existing->_pending_dispatches); existing->_pending_dispatches.clear(); existing->_pending_dispatches.reserve(dispatch_batch_hint); child_lock.unlock(); quic::scheduleDispatches(existing, std::move(dispatches)); child_lock.lock(); Loading Loading @@ -3687,9 +3703,13 @@ size_t quic::recvData(buffer& data, int flags) { pmtudTick(); } // Collect pending dispatches before releasing lock // Collect pending dispatches before releasing lock (see the other // call site's comment on why capacity is re-reserved after the // move — F49). size_t dispatch_batch_hint = _pending_dispatches.size(); dispatches = std::move(_pending_dispatches); _pending_dispatches.clear(); _pending_dispatches.reserve(dispatch_batch_hint); } // mutex released Loading Loading @@ -6874,8 +6894,12 @@ void quic::pumpIncoming() { [&](const std::shared_ptr<quic>& p) { return p.get() == t; }); if (pin_it != pins.end()) { std::shared_ptr<quic> target_pin = *pin_it; // See the other dispatch call sites' comment on why // capacity is re-reserved right after the move (F49). size_t dispatch_batch_hint = t->_pending_dispatches.size(); std::vector<PendingDispatch> dispatches = std::move(t->_pending_dispatches); t->_pending_dispatches.clear(); t->_pending_dispatches.reserve(dispatch_batch_hint); target_lock.unlock(); quic::scheduleDispatches(target_pin, std::move(dispatches)); target_lock.lock(); Loading Loading
src/quic.cpp +26 −2 Original line number Diff line number Diff line Loading @@ -1718,9 +1718,17 @@ void quic::handshake_after_accept() { pmtudTick(); } // Collect pending dispatches before releasing lock // Collect pending dispatches before releasing lock. Re-reserving right // after the move (which leaves _pending_dispatches at capacity 0) // trades one allocation now, sized for the whole next batch, for what // would otherwise be several reallocations later as push_back() grows // it 1->2->4->... from scratch on the next round of incremental // dispatches (F49) — using this batch's size as the hint since batch // sizes are typically steady under sustained load. size_t dispatch_batch_hint = _pending_dispatches.size(); dispatches = std::move(_pending_dispatches); _pending_dispatches.clear(); _pending_dispatches.reserve(dispatch_batch_hint); } // Release _quic_mutex // Dispatch stream callbacks outside the lock Loading Loading @@ -1980,8 +1988,12 @@ void quic::accept(std::unique_ptr<socket>& csock, bool nonblock) { } if (!existing->_pending_dispatches.empty()) { // See the intra-connection dispatch call sites' comment on // why capacity is re-reserved right after the move (F49). size_t dispatch_batch_hint = existing->_pending_dispatches.size(); std::vector<PendingDispatch> dispatches = std::move(existing->_pending_dispatches); existing->_pending_dispatches.clear(); existing->_pending_dispatches.reserve(dispatch_batch_hint); child_lock.unlock(); quic::scheduleDispatches(existing, std::move(dispatches)); child_lock.lock(); Loading Loading @@ -2154,8 +2166,12 @@ void quic::accept(std::unique_ptr<socket>& csock, bool nonblock) { // Dispatch stream callbacks off-thread (see scheduleDispatches) if (!existing->_pending_dispatches.empty()) { // See the intra-connection dispatch call sites' comment on // why capacity is re-reserved right after the move (F49). size_t dispatch_batch_hint = existing->_pending_dispatches.size(); std::vector<PendingDispatch> dispatches = std::move(existing->_pending_dispatches); existing->_pending_dispatches.clear(); existing->_pending_dispatches.reserve(dispatch_batch_hint); child_lock.unlock(); quic::scheduleDispatches(existing, std::move(dispatches)); child_lock.lock(); Loading Loading @@ -3687,9 +3703,13 @@ size_t quic::recvData(buffer& data, int flags) { pmtudTick(); } // Collect pending dispatches before releasing lock // Collect pending dispatches before releasing lock (see the other // call site's comment on why capacity is re-reserved after the // move — F49). size_t dispatch_batch_hint = _pending_dispatches.size(); dispatches = std::move(_pending_dispatches); _pending_dispatches.clear(); _pending_dispatches.reserve(dispatch_batch_hint); } // mutex released Loading Loading @@ -6874,8 +6894,12 @@ void quic::pumpIncoming() { [&](const std::shared_ptr<quic>& p) { return p.get() == t; }); if (pin_it != pins.end()) { std::shared_ptr<quic> target_pin = *pin_it; // See the other dispatch call sites' comment on why // capacity is re-reserved right after the move (F49). size_t dispatch_batch_hint = t->_pending_dispatches.size(); std::vector<PendingDispatch> dispatches = std::move(t->_pending_dispatches); t->_pending_dispatches.clear(); t->_pending_dispatches.reserve(dispatch_batch_hint); target_lock.unlock(); quic::scheduleDispatches(target_pin, std::move(dispatches)); target_lock.lock(); Loading