Permalink
Browse files

Initiate reading of client data right after accept()ing it. Improves …

…performance by 3.2%
  • Loading branch information...
1 parent 13d2439 commit 8c400d01b9ae621d2d7ffd4f0a955c14c792c74d @FooBarWidget FooBarWidget committed Mar 15, 2013
Showing with 11 additions and 0 deletions.
  1. +1 −0 NEWS
  2. +4 −0 ext/common/EventedBufferedInput.h
  3. +6 −0 ext/common/agents/HelperAgent/RequestHandler.h
View
1 NEWS
@@ -3,6 +3,7 @@ Release 4.0.0 release candidate 6
* WebSocket support on Nginx. Requires Nginx >= 1.3.15.
* Improved RVM support.
+ * Performance optimizations.
* Various bug fixes.
@@ -285,6 +285,10 @@ class EventedBufferedInput: public enable_shared_from_this< EventedBufferedInput
return state == END_OF_STREAM;
}
+ void readNow() {
+ onReadable(watcher, 0);
+ }
+
const FileDescriptor &getFd() const {
return fd;
}
@@ -1251,6 +1251,7 @@ class RequestHandler {
void onAcceptable(ev::io &io, int revents) {
bool endReached = false;
unsigned int count = 0;
+ ClientPtr acceptedClients[10];
while (!endReached && count < 10) {
FileDescriptor fd = acceptNonBlockingSocket(requestSocket);
@@ -1279,11 +1280,16 @@ class RequestHandler {
ClientPtr client = make_shared<Client>();
client->associate(this, fd);
clients.insert(make_pair<int, ClientPtr>(fd, client));
+ acceptedClients[count] = client;
count++;
RH_DEBUG(client, "New client accepted; new client count = " << clients.size());
}
}
+ for (unsigned int i = 0; i < count; i++) {
+ acceptedClients[i]->clientInput->readNow();
+ }
+
if (OXT_LIKELY(!clients.empty())) {
inactivityTimer.stop();
}

0 comments on commit 8c400d0

Please sign in to comment.