| 1 | Ideally, you want to make a static binary, otherwise the dynamic |
|---|
| 2 | linker pollutes your address space with shared libs right in the |
|---|
| 3 | middle. (NOTE: actually, this shouldn't matter so much anymore, now |
|---|
| 4 | that we only allocate huge, fixed-size slabs) |
|---|
| 5 | |
|---|
| 6 | Make sure your libevent has epoll (Linux) or kqueue (BSD) support. |
|---|
| 7 | Using poll or select only is slow, and works for testing, but |
|---|
| 8 | shouldn't be used for high-traffic memcache installations. |
|---|
| 9 | |
|---|
| 10 | To build libevent with epoll on Linux, you need two things. First, |
|---|
| 11 | you need /usr/include/sys/epoll.h . To get it, you can install the |
|---|
| 12 | userspace epoll library, epoll-lib. The link to the latest version |
|---|
| 13 | is buried inside |
|---|
| 14 | http://www.xmailserver.org/linux-patches/nio-improve.html ; currently |
|---|
| 15 | it's http://www.xmailserver.org/linux-patches/epoll-lib-0.9.tar.gz . |
|---|
| 16 | If you're having any trouble building/installing it, you can just copy |
|---|
| 17 | epoll.h from that tarball to /usr/include/sys as that's the only thing |
|---|
| 18 | from there that libevent really needs. |
|---|
| 19 | |
|---|
| 20 | Secondly, you need to declare syscall numbers of epoll syscalls, so |
|---|
| 21 | libevent can use them. Put these declarations somewhere |
|---|
| 22 | inside <sys/epoll.h>: |
|---|
| 23 | |
|---|
| 24 | #define __NR_epoll_create 254 |
|---|
| 25 | #define __NR_epoll_ctl 255 |
|---|
| 26 | #define __NR_epoll_wait 256 |
|---|
| 27 | |
|---|
| 28 | After this you should be able to build libevent with epoll support. |
|---|
| 29 | Once you build/install libevent, you don't need <sys/epoll.h> to |
|---|
| 30 | compile memcache or link it against libevent. Don't forget that for epoll |
|---|
| 31 | support to actually work at runtime you need to use a kernel with epoll |
|---|
| 32 | support patch applied, as explained in the README file. |
|---|
| 33 | |
|---|
| 34 | BSD users are luckier, and will get kqueue support by default. |
|---|
| 35 | |
|---|
| 36 | |
|---|
| 37 | |
|---|