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