Commit 50135cdf authored by Dan Melnic's avatar Dan Melnic Committed by Facebook Github Bot

Add non persistent events overflow tests

Summary: Add non persistent events overflow tests

Reviewed By: danobi, kevin-vigor

Differential Revision: D19349804

fbshipit-source-id: 360d1f41d074b3d1af5f163213dadfc35f28c353
parent dec61fcb
......@@ -78,6 +78,13 @@ IoUringBackend::~IoUringBackend() {
void IoUringBackend::cleanup() {
if (ioRing_.ring_fd > 0) {
// release the nonsubmitted items from the submitList
while (!submitList_.empty()) {
auto* ioCb = &submitList_.front();
submitList_.pop_front();
releaseIoCb(ioCb);
}
// release the active events
while (!activeEvents_.empty()) {
auto* ioCb = &activeEvents_.front();
......
......@@ -407,7 +407,6 @@ int PollIoBackend::eb_event_del(Event& event) {
event_ref_flags(ev) &= ~EVLIST_INSERTED;
// not in use - we can cancel it
// TBD- batching
if (!iocb->useCount_ && !wasLinked) {
// io_cancel will attempt to cancel the event. the result is
// EINVAL - usually the event has already been delivered
......@@ -432,6 +431,11 @@ int PollIoBackend::eb_event_del(Event& event) {
}
return 0;
} else {
// we can have an EVLIST_ACTIVE event
// which does not have the EVLIST_INSERTED flag set
// so we need to release it here
releaseIoCb(iocb);
}
return -1;
......
......@@ -48,15 +48,11 @@ class EventFD : public folly::EventHandler {
if (!persist_) {
registerHandler(folly::EventHandler::READ);
}
size_t data;
if (sizeof(data) == folly::readNoInt(fd_, &data, sizeof(data))) {
CHECK_EQ(data, 1);
++num_;
if (total_ > 0) {
--total_;
if (total_ == 0) {
evb_->terminateLoopSoon();
}
++num_;
if (total_ > 0) {
--total_;
if (total_ == 0) {
evb_->terminateLoopSoon();
}
}
}
......@@ -93,14 +89,14 @@ class EventFD : public folly::EventHandler {
folly::EventBase* evb_;
};
void testOverflow(bool overflow) {
void testOverflow(bool overflow, bool persist) {
static constexpr size_t kBackendCapacity = 64;
static constexpr size_t kBackendMaxSubmit = 32;
// for overflow == true we use a greater than kBackendCapacity number of
// EventFD instances and lower when overflow == false
size_t kNumEventFds = overflow ? 2048 : 32;
static constexpr size_t kEventFdCount = 16;
auto total = kNumEventFds * kEventFdCount;
auto total = kNumEventFds * kEventFdCount + kEventFdCount / 2;
std::unique_ptr<folly::EventBaseBackendBase> backend;
......@@ -118,23 +114,31 @@ void testOverflow(bool overflow) {
eventsVec.reserve(kNumEventFds);
for (size_t i = 0; i < kNumEventFds; i++) {
eventsVec.emplace_back(
std::make_unique<EventFD>(kEventFdCount, total, true, &evb));
std::make_unique<EventFD>(kEventFdCount, total, persist, &evb));
}
evb.loopForever();
for (size_t i = 0; i < kNumEventFds; i++) {
CHECK_EQ(eventsVec[i]->getNum(), kEventFdCount);
CHECK_GE(eventsVec[i]->getNum(), kEventFdCount);
}
}
} // namespace
TEST(IoUringBackend, NoOverflow) {
testOverflow(false);
TEST(IoUringBackend, NoOverflowNoPersist) {
testOverflow(false, false);
}
TEST(IoUringBackend, Overflow) {
testOverflow(true);
TEST(IoUringBackend, OverflowNoPersist) {
testOverflow(true, false);
}
TEST(IoUringBackend, NoOverflowPersist) {
testOverflow(false, true);
}
TEST(IoUringBackend, OverflowPersist) {
testOverflow(true, true);
}
namespace folly {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment