Skip to content

Commit 503646e

Browse files
spikehfacebook-github-bot
authored andcommitted
folly async io_uring: bump EVB start time on IoSqeBase completion
Summary: `EventHandler::libeventCallback()` calls `EventBase::bumpHandlingTime()` which sets the `startTime_` of an EVB loop iteration if it wasn't already set. If no `EventHandler`s are run, then `startTime_` is bumped just before running loop callbacks. The io_uring based `IoUringBackend` and `AsyncIoUringSocket` do not use `EventHandler`. Thus the `startTime_` of an EVB loop iteration is not being set correctly upon handling the first piece of I/O work via the various `IoSqeBase` types. Fix this by adding the EventBase to that an IoSqeBase is tied to, and call `EventBase::bumpHandlingTime()` when completing an IoSqeBase i.e. invoking its callback. Reviewed By: yfeldblum Differential Revision: D68537153 fbshipit-source-id: 9e991213d69ffa32778e06a0fb447b0514bebba5
1 parent e85d6ee commit 503646e

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

folly/io/async/IoUringBackend.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,9 @@ void IoSqeBase::internalCallback(const io_uring_cqe* cqe) noexcept {
477477
if (!(cqe->flags & IORING_CQE_F_MORE)) {
478478
inFlight_ = false;
479479
}
480+
if (evb_) {
481+
evb_->bumpHandlingTime();
482+
}
480483
if (cancelled_) {
481484
callbackCancelled(cqe);
482485
} else {

folly/io/async/IoUringBackend.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include <folly/Optional.h>
3737
#include <folly/Range.h>
3838
#include <folly/io/IOBuf.h>
39+
#include <folly/io/async/EventBase.h>
3940
#include <folly/io/async/EventBaseBackendBase.h>
4041
#include <folly/io/async/IoUringBase.h>
4142
#include <folly/io/async/Liburing.h>

folly/io/async/IoUringBase.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ struct io_uring_cqe;
2727
namespace folly {
2828

2929
class IoUringBackend;
30+
class EventBase;
3031

3132
struct IoSqeBase
3233
: boost::intrusive::list_base_hook<
@@ -57,6 +58,7 @@ struct IoSqeBase
5758
bool inFlight() const { return inFlight_; }
5859
bool cancelled() const { return cancelled_; }
5960
void markCancelled() { cancelled_ = true; }
61+
void setEventBase(EventBase* evb) { evb_ = evb; }
6062

6163
protected:
6264
// This is used if you want to prepare this sqe for reuse, but will manage the
@@ -72,6 +74,7 @@ struct IoSqeBase
7274

7375
bool inFlight_ = false;
7476
bool cancelled_ = false;
77+
EventBase* evb_ = nullptr;
7578
Type type_;
7679
};
7780

0 commit comments

Comments
 (0)