]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: epoll: epoll_events should be allocated according to global.tune.maxpollevents
authorGodbach <nylzhaowei@gmail.com>
Wed, 17 Dec 2014 08:14:26 +0000 (16:14 +0800)
committerWilly Tarreau <w@1wt.eu>
Wed, 17 Dec 2014 16:04:53 +0000 (17:04 +0100)
Willy: commit f2e8ee2b introduced an optimization in the old speculative epoll
code, which implemented its own event cache. It was needed to store that many
events (it was bound to maxsock/4 btw). Now the event cache lives on its own
and we don't need this anymore. And since events are allocated on the kernel
side, we only need to allocate the events we want to return.

As a result, absmaxevents will be not used anymore. Just remove the definition
and the comment of it, replace it with global.tune.maxpollevents. It is also an
optimization of memory usage for large amounts of sockets.

Signed-off-by: Godbach <nylzhaowei@gmail.com>
src/ev_epoll.c

index 755c6fa58182c2a365c0ca591a9d08a583728185..c52d07521adb10b8e860aa446993c897218448fe 100644 (file)
@@ -29,7 +29,6 @@
 #include <proto/task.h>
 
 
-static int absmaxevents = 0;    // absolute maximum amounts of polled events
 
 /* private data */
 static struct epoll_event *epoll_events;
@@ -195,10 +194,8 @@ REGPRM1 static int _do_init(struct poller *p)
        if (epoll_fd < 0)
                goto fail_fd;
 
-       /* See comments at the top of the file about this formula. */
-       absmaxevents = MAX(global.tune.maxpollevents, global.maxsock);
        epoll_events = (struct epoll_event*)
-               calloc(1, sizeof(struct epoll_event) * absmaxevents);
+               calloc(1, sizeof(struct epoll_event) * global.tune.maxpollevents);
 
        if (epoll_events == NULL)
                goto fail_ee;