Repository navigation
Description
- A brief description
The reproducing steps for this issue are identical to those in #616 . However, that issue appears to have been fixed. Now that it has been fixed, this secondary effect has become visible.
This feels to me like epoll_wait() is not waiting. But I'll let y'all evaluate the use case.
- Expected results
curl should successfully download the file. After the file transfer completes, curl should exit and the http_examples process should consume negligible CPU
- Actual results (with terminal output if applicable)
** curl does successfully download the file. (Yay! #616 has been fixed!)
** curl does exit as expected upon a successful download
** http_examples does NOT decrease in CPU utilization after the download finishes. It continues to peg a CPU core. It continues to work just fine other than the excessive CPU consumption, but system performance (and battery life) overall is reduced somewhat 'cause random process pegging a CPU core.
Applications that open multiple independent Boost::Asio sockets may peg more than one CPU core.
- Your Windows build number
15007
- Steps / All commands required to reproduce the error from a brand new installation
Initial Setup -- run the following commands in WSL:
sudo apt-get install build-essential git cmake libboost-all-dev
git clone https://github.com/eidheim/Simple-Web-Server.git
cd Simple-Web-Server
cmake .
make -j4
dd if=/dev/zero of=web/big.dat bs=1048576 count=300
Steps to reproduce:
Open up two WSL console windows
In one, do cd Simple-Web-Server ; ./http_examples. Give the server process a couple seconds to start up.
In the other, do curl http://localhost:8080/big.dat >/dev/null
- Strace of the failing command
When http_examples is spinning after the download completes, it emits a continuous stream of the following:
(...)
epoll_wait(4, [{EPOLLIN, {u32=2952795492, u64=140663131739492}}], 128, -1) = 1
timerfd_settime(5, 0, {it_interval={0, 0}, it_value={300, 0}}, {it_interval={0, 0}, it_value={299, 999716000}}) = 0
epoll_wait(4, [{EPOLLIN, {u32=2952795492, u64=140663131739492}}], 128, -1) = 1
timerfd_settime(5, 0, {it_interval={0, 0}, it_value={300, 0}}, {it_interval={0, 0}, it_value={299, 999740000}}) = 0
epoll_wait(4, [{EPOLLIN, {u32=2952795492, u64=140663131739492}}], 128, -1) = 1
timerfd_settime(5, 0, {it_interval={0, 0}, it_value={300, 0}}, {it_interval={0, 0}, it_value={299, 999742000}}) = 0
epoll_wait(4, [{EPOLLIN, {u32=2952795492, u64=140663131739492}}], 128, -1) = 1
timerfd_settime(5, 0, {it_interval={0, 0}, it_value={300, 0}}, {it_interval={0, 0}, it_value={299, 999726000}}) = 0
epoll_wait(4, [{EPOLLIN, {u32=2952795492, u64=140663131739492}}], 128, -1) = 1
timerfd_settime(5, 0, {it_interval={0, 0}, it_value={300, 0}}, {it_interval={0, 0}, it_value={299, 999702000}}) = 0
epoll_wait(4, [{EPOLLIN, {u32=2952795492, u64=140663131739492}}], 128, -1) = 1
(...)
The following lines from the strace look relevant to the configuration of fd's 4 and 5, used above:
$ grep ' = 4$' strace.txt.9092
epoll_create1(EPOLL_CLOEXEC) = 4
$ grep '^[^(]*(4,' strace.txt.9092 | grep -v epoll_wait
epoll_ctl(4, EPOLL_CTL_ADD, 3, {EPOLLIN|EPOLLERR|EPOLLET, {u32=2952795480, u64=140663131739480}}) = 0
epoll_ctl(4, EPOLL_CTL_ADD, 5, {EPOLLIN|EPOLLERR, {u32=2952795492, u64=140663131739492}}) = 0
epoll_ctl(4, EPOLL_CTL_ADD, 6, {EPOLLIN|EPOLLPRI|EPOLLERR|EPOLLHUP|EPOLLET, {u32=2952796688, u64=140663131740688}}) = 0
epoll_ctl(4, EPOLL_CTL_MOD, 6, {EPOLLIN|EPOLLPRI|EPOLLERR|EPOLLHUP|EPOLLET, {u32=2952796688, u64=140663131740688}}) = 0
epoll_ctl(4, EPOLL_CTL_ADD, 11, {EPOLLIN|EPOLLPRI|EPOLLERR|EPOLLHUP|EPOLLET, {u32=2952797024, u64=140663131741024}}) = 0
epoll_ctl(4, EPOLL_CTL_MOD, 6, {EPOLLIN|EPOLLPRI|EPOLLERR|EPOLLHUP|EPOLLET, {u32=2952796688, u64=140663131740688}}) = 0
epoll_ctl(4, EPOLL_CTL_ADD, 12, {EPOLLIN|EPOLLPRI|EPOLLERR|EPOLLHUP|EPOLLET, {u32=2952803024, u64=140663131747024}}) = 0
epoll_ctl(4, EPOLL_CTL_MOD, 6, {EPOLLIN|EPOLLPRI|EPOLLERR|EPOLLHUP|EPOLLET, {u32=2952796688, u64=140663131740688}}) = 0
epoll_ctl(4, EPOLL_CTL_DEL, 11, 0x7feeb62cf860) = 0
epoll_ctl(4, EPOLL_CTL_DEL, 12, 0x7feeb62cf8e0) = 0
$ grep ' = 5$' strace.txt.9092
timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC) = 5
$ grep '^[^(]*(5,' strace.txt.9092 | grep -v timerfd_settime
# No lines match
I can post the full strace if it would be useful; let me know. In particular, I haven't checked whether this behavior is sensitive to the configuration of the file descriptors that are being watched.
See our contributing instructions for assistance.
Activity
aseering commentedon Jan 18, 2017
This isn't blocking me from doing anything since affected services continue to work just fine. But I imagine that, come summer, I will get tired of my laptop acting as a space heater :-)
therealkenc commentedon Jan 18, 2017
It spins even without the curl step, after fd 11 is closed and removed from the epoll set (your curl is fd 12). Wonder what the trigger is. If
epoll_wait()didn't work, libuv (ie, all of node) should have spun a long time ago. Issue title can be changed to "epoll_wait() doesn't" for comedic value.[-]Boost::Asio-based apps consume excessive CPU[/-][+]epoll_wait() doesn't.[/+]aseering commentedon Jan 18, 2017
"title": sure, why not :-)
therealkenc commentedon Jan 18, 2017
Here's specific point where the strace diverges from native:
That very last
epoll_wait()with last parameter (ie timeout) 0 should return 0 (ie empty) but it returns 1, and continues to return 1 forever. File descriptor 11 is the client socket and is the mostly likely culprit, but strangely a little test case worked. It isn't timerfd 5, which won't go off for 300 seconds. Good catch.sunilmut commentedon Jan 18, 2017
Adam Seering (@aseering) - Thanks for these
gems:). The problem is with thetimerfd(therealkenc almost had abulls eye:)). Whentimerfd_settimeis called, it should actually reset the EPOLL, which was not happening. This bug was always present, but never got noticed (because of it's specific use-case). The CR is out for review.sunilmut commentedon Jan 18, 2017
The fix is in the dev branch and should soon hit the release build. Thanks Adam Seering (@aseering) and therealkenc.