Commit f76a150a authored by Martin Karsten's avatar Martin Karsten
Browse files

- add stats counter for failed ready-queue dequeue attempts

- improve stats counter for user-blocking I/O calls (add for epoll_wait)
parent 19324187
......@@ -344,8 +344,10 @@ public:
#if defined(__linux__)
int epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout) {
RASSERT0(epfd >= 0 && epfd < fdCount);
stats->calls.count((int)(timeout != 0));
int ret = ::epoll_wait(epfd, events, maxevents, 0);
if (ret != 0 || timeout == 0) return ret;
stats->fails.count();
BasePoller*& poller = fdSyncVector[epfd].poller[true];
if (!poller) {
poller = &getPoller<true,false>(epfd);
......@@ -359,8 +361,10 @@ public:
for (;;) {
if (timeout < 0) sync.P();
else if (!sync.P(absTimeout)) return 0;
stats->calls.count();
ret = ::epoll_wait(epfd, events, maxevents, 0);
if (ret != 0) return ret;
stats->fails.count();
poller->setupFD(epfd, Poller::Modify, Poller::Input, Poller::Oneshot);
}
}
......
......@@ -41,6 +41,7 @@ class ReadyQueue {
Fred* f = queue[p].pop();
if (f) return f;
}
stats->queue.fail();
return nullptr;
}
......
......@@ -161,6 +161,7 @@ inline ostream& operator<<(ostream& os, const Distribution& x) {
struct Queue {
volatile Number qlen;
Counter fails;
Distribution qdist;
public:
Queue() : qlen(0) {}
......@@ -171,19 +172,24 @@ public:
void remove(Number n = 1) {
__atomic_sub_fetch( &qlen, n, __ATOMIC_RELAXED);
}
void fail() {
fails.count();
}
void aggregate(const Queue& x) {
qlen += x.qlen;
fails.aggregate(x.fails);
qdist.aggregate(x.qdist);
}
void reset() {
qlen = 0;
fails.reset();
qdist.reset();
}
};
inline ostream& operator<<(ostream& os, const Queue& x) {
if (x.qlen != 0) os << " QUEUE";
os << x.qdist;
if (x.qlen != 0) os << " Q: " << x.qlen;
os << " F:" << x.fails << x.qdist;
return os;
}
......
Supports Markdown
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