Comparing and Evaluating Epoll, Select and Poll Event Mechanisms
Comparing and Evaluating Epoll, Select and Poll Event Mechanisms
http://gelato.uwaterloo.ca
The Problem and Goals
• Increase peak performance
• Sustain peak performance under overload
Responses/sec
Requests/sec
Better understand apps and interaction with kernel
2
Server Phases
get events
select(),poll(),epoll_wait()
3
select and poll
FD_SET(fd, &readable);
rdfds = readable; wrfds = writable;
n = select(max, rdfds, wrfds, exfds, &tout);
if (FD_ISSET(fd, rdfds)) { read }
FD_SET(fd, &writable);
FD_CLR(fd, &readable);
array[i].events = POLLIN;
n = poll(array, max, &tout);
if (array[i].revents & POLLIN) { read }
array[i].events = POLLOUT;
4
epoll
epfd = epoll_create(max_fds);
evt.data.fd = fd;
evt.events = EPOLLIN;
epoll_ctl(epfd, EPOLL_CTL_ADD, fd, &evt);
evt.data.fd = fd;
evt.events = EPOLLOUT;
epoll_ctl(epfd, EPOLL_CTL_MOD, fd, &evt);
5
Motivation
22,000 req/sec
9
Reducing epoll_ctlv calls
10
Reducing epoll_ctlv calls
11
Reducing epoll_ctlv calls
12
Reducing epoll_ctlv calls
22,000 req/sec
13
gprof results @ 22,000 req/s
Syscall epoll epoll2 ctlv edge
read 20.95 20.08 21.41 22.19
close 14.05 13.02 14.90 14.14
epoll_wait 7.15 12.56 6.01 6.52
epoll_ctl 16.34 10.27 5.98 11.06
epoll_ctlv 9.28
sockopt 9.13 7.57 9.13 9.08
accept 9.51 9.05 9.76 9.30
write 5.06 4.13 5.10 5.31
fcntl 3.34 3.14 3.37 3.34
sendfile 2.70 3.00 2.71 3.91
replies/sec 13,026 13,598 13,343 13,665
14
gprof results @ 22,000 req/s
Syscall epoll epoll2 ctlv edge
read 20.95 20.08 21.41 22.19
close 14.05 13.02 14.90 14.14
epoll_wait 7.15 12.56 6.01 6.52
epoll_ctl 16.34 10.27 5.98 11.06
epoll_ctlv 9.28
sockopt 9.13 7.57 9.13 9.08
accept 9.51 9.05 9.76 9.30
write 5.06 4.13 5.10 5.31
fcntl 3.34 3.14 3.37 3.34
sendfile 2.70 3.00 2.71 3.91
replies/sec 13,026 13,598 13,343 13,665
15
gprof results @ 22,000 req/s
Syscall epoll epoll2 ctlv edge
read 20.95 20.08 21.41 22.19
close 14.05 13.02 14.90 14.14
epoll_wait 7.15 12.56 6.01 6.52
epoll_ctl 16.34 10.27 5.98 11.06
epoll_ctlv 9.28
sockopt 9.13 7.57 9.13 9.08
accept 9.51 9.05 9.76 9.30
write 5.06 4.13 5.10 5.31
fcntl 3.34 3.14 3.37 3.34
sendfile 2.70 3.00 2.71 3.91
replies/sec 13,026 13,598 13,343 13,665
16
gprof results @ 22,000 req/s
Syscall epoll epoll2 ctlv edge
read 20.95 20.08 21.41 22.19
close 14.05 13.02 14.90 14.14
epoll_wait 7.15 12.56 6.01 6.52
epoll_ctl 16.34 10.27 5.98 11.06
epoll_ctlv 9.28
sockopt 9.13 7.57 9.13 9.08
accept 9.51 9.05 9.76 9.30
write 5.06 4.13 5.10 5.31
fcntl 3.34 3.14 3.37 3.34
sendfile 2.70 3.00 2.71 3.91
replies/sec 13,026 13,598 13,343 13,665
17
1 Byte File: 10,000 idle conns
18
SPECweb99-like Workload
19
SPECweb99-like: 10,000 idle conns
20
Itanium Results: 1 byte file