Skip to content
Snippets Groups Projects
Commit bab3c557 authored by Martin Karsten's avatar Martin Karsten
Browse files

- undo yield-before-poll-then-block for fibre polling -> no tangible effect

- other clerical updates related to polling
parent 540f9592
No related branches found
No related tags found
No related merge requests found
......@@ -48,7 +48,7 @@ bool TimerStats::print(ostream& os) {
bool PollerStats::print(ostream& os) {
if (events == 0) return false;
StatsObject::print(os);
os << events << polls << blocks;
os << polls << events;
return true;
}
......
......@@ -135,9 +135,8 @@ struct TimerStats : public StatsObject {
};
struct PollerStats : public StatsObject {
Average events;
Counter polls;
Counter blocks;
Average events;
PollerStats(void* o, const char* n = "Poller") : StatsObject(o, n) {}
bool print(ostream& os);
};
......
......@@ -29,8 +29,9 @@ inline void BasePoller::pollLoop(T& This, bool pollerFibre) {
SystemProcessor::setupFakeContext((StackContext*)&This, _friend<BasePoller>());
while (!This.pollTerminate) {
int evcnt = This.blockingPoll();
int statscnt = evcnt;
This.stats->polls.count();
for (;;) { // drain all events with non-blocking epoll_wait
This.stats->events.add(evcnt);
ProcessorResumeSet procSet;
for (int e = 0; e < evcnt; e += 1) {
#if __FreeBSD__
......@@ -54,27 +55,27 @@ inline void BasePoller::pollLoop(T& This, bool pollerFibre) {
p.first->bulkResume(p.second, _friend<BasePoller>());
}
if (evcnt < maxPoll) break;
This.stats->polls.count();
#if __FreeBSD__
static const timespec ts = Time::zero();
evcnt = kevent(This.pollFD, nullptr, 0, This.events, maxPoll, &ts);
#else // __linux__ below
evcnt = epoll_wait(This.pollFD, This.events, maxPoll, 0);
#endif
if (evcnt < 0) { GENASSERT1(errno == EINTR, errno); } // gracefully handle EINTR
if (evcnt < 0) { GENASSERT1(errno == EINTR, errno); evcnt = 0; } // gracefully handle EINTR
statscnt += evcnt;
This.stats->polls.count();
}
This.stats->events.add(statscnt);
}
}
inline int PollerThread::blockingPoll() {
stats->blocks.count();
stats->polls.count();
#if __FreeBSD__
int evcnt = kevent(pollFD, nullptr, 0, events, maxPoll, nullptr); // blocking
#else // __linux__ below
int evcnt = epoll_wait(pollFD, events, maxPoll, -1); // blocking
#endif
if (evcnt < 0) { GENASSERT1(errno == EINTR, errno); } // gracefully handle EINTR
if (evcnt < 0) { GENASSERT1(errno == EINTR, errno); evcnt = 0; } // gracefully handle EINTR
if (paused) pauseSem.P();
return evcnt;
}
......@@ -121,23 +122,16 @@ void PollerFibre::stop() {
}
inline int PollerFibre::blockingPoll() {
Fibre::yield();
for(;;) {
stats->polls.count();
eventScope.blockPollFD(pollFD);
#if __FreeBSD__
static const timespec ts = Time::zero();
int evcnt = kevent(pollFD, nullptr, 0, events, maxPoll, &ts);
static const timespec ts = Time::zero();
int evcnt = kevent(pollFD, nullptr, 0, events, maxPoll, &ts);
#else // __linux__ below
int evcnt = epoll_wait(pollFD, events, maxPoll, 0);
int evcnt = epoll_wait(pollFD, events, maxPoll, 0);
#endif
if (evcnt < 0) { GENASSERT1(errno == EINTR, errno); } // gracefully handle EINTR
if (evcnt > 0) {
if (paused) pauseSem.P();
return evcnt;
}
stats->blocks.count();
eventScope.blockPollFD(pollFD);
}
if (evcnt < 0) { GENASSERT1(errno == EINTR, errno); evcnt = 0; } // gracefully handle EINTR
if (paused) pauseSem.P();
return evcnt;
}
#else
......
......@@ -34,7 +34,7 @@ public: // RegistrationStatus
static const int Write = 0x2;
protected:
static const int maxPoll = 256;
static const int maxPoll = 1024;
#if __FreeBSD__
struct kevent events[maxPoll];
#else // __linux__ below
......
......@@ -30,7 +30,7 @@
//#define TESTING_POLLER_FIBRES 1 // vs. per-cluster poller pthread
//#define TESTING_POLLER_IDLEWAIT 1 // vs. wake up poller thread anytime
//#define TESTING_POLLER_IDLETIMEDWAIT 5000 // vs. wait indefinitely for idle (usecs)
//#define TESTING_POLLER_IDLETIMEDWAIT 10000 // vs. wait indefinitely for idle (usecs)
#define TESTING_BULK_RESUME 1 // vs. individual resume
#define TESTING_LAZY_FD_REGISTRATION 1 // vs. eager registration after fd creation
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment