Thread (7 messages) 7 messages, 4 authors, 2012-07-09

Re: [RFC] Introduce to batch variants of accept() and epoll_ctl() syscall

From: Changli Gao <hidden>
Date: 2012-06-15 04:30:09
Also in: lkml

On Fri, Jun 15, 2012 at 12:13 PM, Li Yu [off-list ref] wrote:
Hi,

 We encounter a performance problem in a large scale computer
cluster, which needs to handle a lot of incoming concurrent TCP
connection requests.

 The top shows the kernel is most cpu hog, the testing is simple,
just a accept() -> epoll_ctl(ADD) loop, the ratio of cpu util sys% to
si% is about 2:5.

 I also asked some experienced webserver/proxy developers in my team
for suggestions, it seem that behavior of many userland programs already
called accept() multiple times after it is waked up by
epoll_wait(). And the common action is adding the fd that accept()
return into epoll interface by epoll_ctl() syscall then.

 Therefore, I think that we'd better to introduce to batch variants of
accept() and epoll_ctl() syscall, just like sendmmsg() or recvmmsg().

 For accept(), we may need a new syscall, it may like this,

 struct accept_result {
     int fd;
     struct sockaddr addr;
     socklen_t addr_len;
 };

 int maccept4(int fd, int flags, int nr_accept_result, struct
accept_result *results);

 For epoll_ctl(), there are two means to extend it, I prefer to extend
current interface instead of introduce to new syscall. We may introduce
to a new flag EPOLL_CTL_BATCH. If userland call epoll_ctl() with this
flag set, the meaning of last two arguments of epoll_ctl() change, .e.g:

 struct batch_epoll_event batch_event[] = {
        {
             .fd = a_newsock_fd;
             .epoll_event = { ... };
        },
        ...
 };

 ret = epoll_ctl(fd, EPOLL_CTL_ADD|EPOLL_CTL_BATCH, nr_batch_events,
batch_events);
I think it is good idea. Would you please implement a prototype and
give some numbers? This kind of data may help selling this idea.
Thanks.

-- 
Regards,
Changli Gao(xiaosuo@gmail.com)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help