epoll

Is 'epoll' the essential reason that Tornadoweb(or Nginx) is so fast?

Tornadoweb and Nginx are popular web servers for the moment and many benchmarkings show that they have a better performance than Apache under certain circumstances. So my question is: Is 'epoll' the most essential reason that make them so fast? And what can I learn from that if I want to write a good socket server? ...

Epoll in EPOLLET mode returning 2 EPOLLIN before reading from the socket

The epoll manpage says that a fd registered with EPOLLET(edge triggered) shouldn't notify twice EPOLLIN if no read has been done. So after an EPOLLIN you need to empty the buffer before epoll_wait being able to return a new EPOLLIN on new data. However I'm experiencing problems with this approach as I'm seeing duplicated EPOLLIN event...

Determine how much can I write into a filehandle; copying data from one FH to the other.

How to determine if I can write the given number of bytes to a filehandle (socket actually)? (Alternatively, how to "unread" the data I had read from other filehandle?) I want something like: n = how_much_can_I_write(w_handle); n = read(r_handle, buf, n); assert(n==write(w_handle, buf, n)); Both filehandles (r_handle and w_handle) ...

Client connections with epoll

Hi, I'm programming an application(client/server) in C++ for linux using epoll y pthreads but I don't know how to handle the connect() calls for attach a new connection in the descriptor list if a loop with epoll_wait() is running(Edge-triggered), How to can I do it?... I could to use a dummy file descriptor to trigger an event and scap...

non blocking tcp connect with epoll

My linux application is performing non-blocking TCP connect syscall and then use epoll_wait to detect three way handshake completion. Sometimes epoll_wait returns with both POLLOUT & POLLERR revents set for the same socket descriptor. I would like to understand what's going on at TCP level. I'm not able to reproduce it on demand. My gue...

epoll_wait: maxevents

int epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout); I'm a little confused about the maxevents parameter. Let's say I want to write a server that can handle up to 10k connections. Would I define maxevents as 10000 then, or should it be be lower for some reason? ...

Boost Asio On Linux Not Using Epoll

I was under the impression that boost::asio would use an epoll setup by default instead of a select implementation, but after running some tests it looks like my setup is using select. OS: RHEL 4 Kernel:2.6 GCC:3.4.6 I wrote a little test program to verify which reactor header was being used, and it looks like its using the select reac...

epoll: Distinguishing "listener" FDs

How can I distinguish between "listener" file descriptors and "client" file descriptors? Here's what I saw in the manpage example: if(events[n].data.fd == listener) { ... } else { ... } 'But what if I don't have access to listener? Sorry if this is a vague question. I'm not quite sure how to word it. ...

Where can I get the latest information about aio on Linux 2.6.x

Recently I am learning how to write a high performance web server.There is a experiment by RedHat says that epoll is faster than aio. someone says that because aio in Linux kernel is implemented with pthread. It's difficult for me to find latest information to prove this.Also I don't know is epoll still better than aio now on Linux?So I ...

why the EPOLLOUT is always triggered even when it is in EdgeTriggered mode ?

after reading the epoll man, i thought the EPOLLOUT will only be triggered when the fd comes writeable from unwriteable. but i tried on stdout and it's always triggered EPOLLOUT and i didn't write anything into stdout. why is that ? thanks ...

Solaris /dev/poll support in Perl

Has anyone any experience using /dev/poll (the Solaris equivalent of the Linux epoll method) with Perl, either via a module or directly in their application? There's not much about this subject I can find through Google. ...

Are there any major performance differences between epoll and kqueue?

My development machine is a MacBook (which of course has kqueue). However, in production we're running Linux (which of course uses epoll). Obviously, to know the performance characteristics of my code I need to run it using epoll. That said, is performance that I see under kqueue a decent approximation of what I'll see with epoll? Or...

Proper handling of EWOULDBLOCK with polling on a non-blocking socket

I've been working on a polling TCP daemon for some time now. Recently, I've read that non-blocking sockets can sometimes throw an EWOULDBLOCK error during a send() or recv(). My understanding is that if recv() throws an EWOULDBLOCK, this (usually) means that there's nothing to receive. But what I'm unclear on is under what circumstances ...

Is there any way to emulate epoll_wait with kqueue/kevent?

I have a list of a bunch of file descriptors that I have created kevents for, and I'm trying to figure out if there's any way to get the number of them that are ready for read or write access. Is there any way to get a list of "ready" file descriptors, like what epoll_wait provides? ...

Multithreading UDP server with epoll?

Hi all, I'd like to develop a multithreaded UDP server in C/Linux. The service is running on a single port x, thus there's only the possibility to bind a single UDP socket to it. In order to work under high loads, I have n threads (statically defined), say 1 thread per CPU. Work could be delivered to the thread using epoll_wait, so thre...

How to read multiple file descriptors using epoll_select with EPOLLET?

man epoll: The suggested way to use epoll as an edge-triggered (EPOLLET) interface is as follows: i with nonblocking file descriptors; and ii by waiting for an event only after read(2) or write(2) return EAGAIN. Imagine we have two fds: the first is passive, data available only sometimes, the second is active, data only som...

select vs poll vs epoll

Iam designing a new server which needs to support thousands( somewhere between 100,000 sessions) of udp connections. What is the best polling method to use for socket FD's. I have read that epoll is better than select/poll. Any input or suggestions on which one to use. Thanks. ...