{"action":"created","issue":{"url":"https://api.github.com/repos/apple/swift-nio/issues/127","repository_url":"https://api.github.com/repos/apple/swift-nio","labels_url":"https://api.github.com/repos/apple/swift-nio/issues/127/labels{/name}","comments_url":"https://api.github.com/repos/apple/swift-nio/issues/127/comments","events_url":"https://api.github.com/repos/apple/swift-nio/issues/127/events","html_url":"https://github.com/apple/swift-nio/issues/127","id":304197410,"number":127,"title":"Too many calls to futex","user":{"login":"toffaletti","id":145012,"avatar_url":"https://avatars0.githubusercontent.com/u/145012?v=4","gravatar_id":"","url":"https://api.github.com/users/toffaletti","html_url":"https://github.com/toffaletti","followers_url":"https://api.github.com/users/toffaletti/followers","following_url":"https://api.github.com/users/toffaletti/following{/other_user}","gists_url":"https://api.github.com/users/toffaletti/gists{/gist_id}","starred_url":"https://api.github.com/users/toffaletti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/toffaletti/subscriptions","organizations_url":"https://api.github.com/users/toffaletti/orgs","repos_url":"https://api.github.com/users/toffaletti/repos","events_url":"https://api.github.com/users/toffaletti/events{/privacy}","received_events_url":"https://api.github.com/users/toffaletti/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-03-11T21:48:06Z","updated_at":"2018-03-11T22:28:20Z","closed_at":null,"author_association":"NONE","body":"### Expected behavior\r\nI expect there not to be so many futex calls.\r\n\r\n### Actual behavior\r\n\r\n```\r\n916   20:12:30 epoll_create(128)        = 3 <0.000055>                                                                                                                         \r\n916   20:12:30 futex(0x667b10, FUTEX_WAKE_PRIVATE, 2147483647) = 0 <0.000023>\r\n916   20:12:30 futex(0x667b20, FUTEX_WAKE_PRIVATE, 2147483647) = 0 <0.000033>\r\n916   20:12:30 eventfd2(0, EFD_CLOEXEC|EFD_NONBLOCK) = 4 <0.000064>\r\n916   20:12:30 futex(0x667af0, FUTEX_WAKE_PRIVATE, 2147483647) = 0 <0.000032>\r\n916   20:12:30 futex(0x667b00, FUTEX_WAKE_PRIVATE, 2147483647) = 0 <0.000022>\r\n916   20:12:30 timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC|TFD_NONBLOCK) = 5 <0.000058>\r\n916   20:12:30 futex(0x667b60, FUTEX_WAKE_PRIVATE, 2147483647) = 0 <0.000022>\r\n916   20:12:30 futex(0x667b80, FUTEX_WAKE_PRIVATE, 2147483647) = 0 <0.000033>\r\n916   20:12:30 futex(0x667b90, FUTEX_WAKE_PRIVATE, 2147483647) = 0 <0.000032>\r\n916   20:12:30 futex(0x667b30, FUTEX_WAKE_PRIVATE, 2147483647) = 0 <0.000023>\r\n916   20:12:30 epoll_ctl(3, EPOLL_CTL_ADD, 4, {EPOLLIN|EPOLLERR|EPOLLRDHUP, {u32=4, u64=4}}) = 0 <0.000068>\r\n916   20:12:30 futex(0x667ba0, FUTEX_WAKE_PRIVATE, 2147483647) = 0 <0.000020>\r\n916   20:12:30 epoll_ctl(3, EPOLL_CTL_ADD, 5, {EPOLLIN|EPOLLERR|EPOLLRDHUP|EPOLLET, {u32=5, u64=5}}) = 0 <0.000053>\r\n916   20:12:30 futex(0x6686c8, FUTEX_WAKE_PRIVATE, 2147483647) = 0 <0.000068>\r\n916   20:12:30 futex(0x6680b0, FUTEX_WAKE_PRIVATE, 2147483647) = 0 <0.000056>\r\n916   20:12:30 futex(0x7f81323e9530, FUTEX_WAKE_PRIVATE, 2147483647) = 0 <0.000064>\r\n916   20:12:30 futex(0x7f81323e9928, FUTEX_WAKE_PRIVATE, 2147483647) = 0 <0.000068>\r\n```\r\n\r\n### Steps to reproduce\r\n\r\n1. `docker run --security-opt seccomp:unconfined -v$CWD:/code -it --rm swiftnio`\r\n2. `cd /code && swift build`\r\n3. `strace -s 1024 -fF -tT -o trace.out ./.build/x86_64-unknown-linux/debug/NIOHTTP1Server 0.0.0.0 8888 .`\r\n\r\n### If possible, minimal yet complete reproducer code (or URL to code)\r\n\r\n\r\nThere are no futex calls here:\r\n```\r\nroot@1ba3a0b6d2c0:/code# cat epoll.c \r\n#include <sys/epoll.h>\r\n\r\nint main() {\r\n    int fd = epoll_create(1);\r\n    epoll_wait(fd, 0, 0, 0);\r\n    return 0;\r\n}\r\nroot@1ba3a0b6d2c0:/code# clang epoll.c \r\nroot@1ba3a0b6d2c0:/code# strace -s 1024 -f -tT ./a.out \r\n21:46:15 execve(\"./a.out\", [\"./a.out\"], [/* 11 vars */]) = 0 <0.001591>\r\n21:46:15 brk(NULL)                      = 0x1c96000 <0.000028>\r\n21:46:15 access(\"/etc/ld.so.nohwcap\", F_OK) = -1 ENOENT (No such file or directory) <0.000200>\r\n21:46:15 access(\"/etc/ld.so.preload\", R_OK) = -1 ENOENT (No such file or directory) <0.000012>\r\n21:46:15 open(\"/etc/ld.so.cache\", O_RDONLY|O_CLOEXEC) = 3 <0.000253>\r\n21:46:15 fstat(3, {st_mode=S_IFREG|0644, st_size=18870, ...}) = 0 <0.000017>\r\n21:46:15 mmap(NULL, 18870, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f74ce3e6000 <0.000023>\r\n21:46:15 close(3)                       = 0 <0.000015>\r\n21:46:15 access(\"/etc/ld.so.nohwcap\", F_OK) = -1 ENOENT (No such file or directory) <0.000036>\r\n21:46:15 open(\"/lib/x86_64-linux-gnu/libc.so.6\", O_RDONLY|O_CLOEXEC) = 3 <0.000022>\r\n21:46:15 read(3, \"\\177ELF\\2\\1\\1\\3\\0\\0\\0\\0\\0\\0\\0\\0\\3\\0>\\0\\1\\0\\0\\0P\\t\\2\\0\\0\\0\\0\\0@\\0\\0\\0\\0\\0\\0\\0\\270r\\34\\0\\0\\0\\0\\0\\0\\0\\0\\0@\\0008\\0\\n\\0@\\0H\\0G\\0\\6\\0\\0\\0\\5\\0\\0\\0@\\0\\0\\0\\0\\0\\0\\0@\\0\\0\\0\\0\\0\\0\\0@\\0\\0\\0\\0\\0\\0\\0000\\2\\0\\0\\0\\0\\0\\0000\\2\\0\\0\\0\\0\\0\\0\\10\\0\\0\\0\\0\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f\\31\\0\\0\\0\\0\\0\\274T\\0\\0\\0\\0\\0\\0\\274T\\0\\0\\0\\0\\0\\0\\4\\0\\0\\0\\0\\0\\0\\0Q\\345td\\6\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\20\\0\\0\\0\\0\\0\\0\\0R\\345td\\4\\0\\0\\0\\300\\7\\34\\0\\0\\0\\0\\0\\300\\7<\\0\\0\\0\\0\\0\\300\\7<\\0\\0\\0\\0\\0@8\\0\\0\\0\\0\\0\\0@8\\0\\0\\0\\0\\0\\0\\1\\0\\0\\0\\0\\0\\0\\0\\4\\0\\0\\0\\24\\0\\0\\0\\3\\0\\0\\0GNU\\0\\2658\\32Ey\\6\\322y\\0078\\\"\\245\\316\\262LK\\376\\371M\\333\\4\\0\\0\\0\\20\\0\\0\\0\\1\\0\\0\\0GNU\\0\\0\\0\\0\\0\\2\\0\\0\\0\\6\\0\\0\\0 \\0\\0\\0\\0\\0\\0\\0\\363\\3\\0\\0\\n\\0\\0\\0\\0\\1\\0\\0\\16\\0\\0\\0\\0000\\20D\\240 \\2\\1\\210\\3\\346\\220\\305E\\214\\0\\304\\0\\10\\0\\5\\204\\0`\\300\\200\\0\\r\\212\\f\\0\\4\\20\\0\\210@2\\10*@\\210T<, \\0162H&\\204\\300\\214\\4\\10\\0\\2\\2\\16\\241\\254\\32\\4f\\300\\0\\3002\\0\\300\\0P\\1 \\201\\10\\204\\v  ($\\0\\4 Z\\0\\20X\\200\\312DB(\\0\\6\\200\\20\\30B\\0 @\\200\\0IP\\0Q\\212@\\22\\0\\0\\0\\0\\10\\0\\0\\21\\20\", 832) = 832 <0.000024>\r\n21:46:15 fstat(3, {st_mode=S_IFREG|0755, st_size=1868984, ...}) = 0 <0.000013>\r\n21:46:15 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f74ce3e5000 <0.000111>\r\n21:46:15 mmap(NULL, 3971488, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f74cddfc000 <0.000057>\r\n21:46:15 mprotect(0x7f74cdfbc000, 2097152, PROT_NONE) = 0 <0.000041>\r\n21:46:15 mmap(0x7f74ce1bc000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1c0000) = 0x7f74ce1bc000 <0.000044>\r\n21:46:15 mmap(0x7f74ce1c2000, 14752, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f74ce1c2000 <0.000019>\r\n21:46:15 close(3)                       = 0 <0.000013>\r\n21:46:15 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f74ce3e4000 <0.000020>\r\n21:46:15 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f74ce3e3000 <0.000011>\r\n21:46:15 arch_prctl(ARCH_SET_FS, 0x7f74ce3e4700) = 0 <0.000159>\r\n21:46:15 mprotect(0x7f74ce1bc000, 16384, PROT_READ) = 0 <0.000030>\r\n21:46:15 mprotect(0x600000, 4096, PROT_READ) = 0 <0.000068>\r\n21:46:15 mprotect(0x7f74ce3eb000, 4096, PROT_READ) = 0 <0.000024>\r\n21:46:15 munmap(0x7f74ce3e6000, 18870)  = 0 <0.000019>\r\n21:46:15 epoll_create(1)                = 3 <0.000044>\r\n21:46:15 epoll_wait(3, NULL, 0, 0)      = -1 EINVAL (Invalid argument) <0.000015>\r\n21:46:15 exit_group(0)                  = ?\r\n21:46:15 +++ exited with 0 +++\r\n```\r\n\r\n### SwiftNIO version/commit hash\r\n\r\nc8d198020717b8bbb4c3be4e47c06aab4085c7fc\r\n\r\n### Swift & OS version (output of `swift --version && uname -a`)\r\n\r\n> Swift version 4.0 (swift-4.0-RELEASE)\r\nTarget: x86_64-unknown-linux-gnu\r\nLinux 1ba3a0b6d2c0 4.9.60-linuxkit-aufs #1 SMP Mon Nov 6 16:00:12 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux"},"comment":{"url":"https://api.github.com/repos/apple/swift-nio/issues/comments/372155378","html_url":"https://github.com/apple/swift-nio/issues/127#issuecomment-372155378","issue_url":"https://api.github.com/repos/apple/swift-nio/issues/127","id":372155378,"user":{"login":"toffaletti","id":145012,"avatar_url":"https://avatars0.githubusercontent.com/u/145012?v=4","gravatar_id":"","url":"https://api.github.com/users/toffaletti","html_url":"https://github.com/toffaletti","followers_url":"https://api.github.com/users/toffaletti/followers","following_url":"https://api.github.com/users/toffaletti/following{/other_user}","gists_url":"https://api.github.com/users/toffaletti/gists{/gist_id}","starred_url":"https://api.github.com/users/toffaletti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/toffaletti/subscriptions","organizations_url":"https://api.github.com/users/toffaletti/orgs","repos_url":"https://api.github.com/users/toffaletti/repos","events_url":"https://api.github.com/users/toffaletti/events{/privacy}","received_events_url":"https://api.github.com/users/toffaletti/received_events","type":"User","site_admin":false},"created_at":"2018-03-11T22:28:20Z","updated_at":"2018-03-11T22:28:20Z","author_association":"NONE","body":"I have a minimal reproducer in a branch https://github.com/toffaletti/swift-nio/blob/wtfutex/Sources/WTFutex/main.swift"}}
{"actor":{"display_login":"toffaletti"}}