-
Notifications
You must be signed in to change notification settings - Fork 850
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
High CPU usage for apache + php when transferring large files / sys/poll() returns wrong value #1540
Comments
Hi @garci66 -- thanks for posting this detailed bug report! For what it's worth, this sounds kind of similar to some other network issues that have been reported, some of which have been fixed in Insider builds and some of which have fixes pending. @sunilmut FYI. |
I saw similr reports but, so far, none that seemed related to poll() failing. Regardless, I'll launch a vm with an insider track and see if I can repro on it. |
@garci66 - Thank you for the detailed and clear bug report, this is very helpful. I will give your repro a shot today and see if the epoll issue is resolved. |
Thanks! I asume that this is not on any of the insiders' builds yet no? |
Ah I think I see what the issue was. Php5 isn't in the default packages in 16.04, once I followed these instructions I got things working: http://askubuntu.com/questions/756181/installing-php-5-6-on-xenial-16-04. Unfortunately I'm still seeing the issue that you describe, poll returning that the socket file descriptor is writable but the write failing with EAGAIN because the buffer is full. I will sync up with @sunilmut who owns this area and see if he has any ideas for a fix. |
Thanks! Good to know... too bad it's not yet fixed though... :( But great to see the work you guys are doing with WSL! |
Sunil and I took a closer look at this and this issue is fixed internally. The fix should be available in an upcoming Windows Insider build. |
Thanks @benhillis for brining this to my notice. To be precise, this is a duplicate of #1025, a fix for which should be available in an upcoming (mostly, next) insider build. Thanks @garci66 for the post and the detailed repro steps. Very useful (made it very easy to repro)! |
This should be fixed in 15002. Please validate and let us know if the issue persists. |
Thanks everyone. I'll wait for the upcoming build and validate on my test
VM
…On Jan 9, 2017 17:33, "Sunil Muthuswamy" ***@***.***> wrote:
This should be fixed in 15002
<https://msdn.microsoft.com/en-us/commandline/wsl/release_notes#build-15002>.
Please validate and let us know if the issue persists.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1540 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AKFd2HS0ONMqXDP9HwIdGkP45nTGUQcgks5rQpmFgaJpZM4LV7lO>
.
|
It's working great. Thanks! |
Description
When using apache + php to write a large buffer to the client, or using fpassthru to stream a large file, apache's serving thread will use 100% of a single core. The CPU usage is high regardless of whether the client is on localhost (from a native windows client like google chrome) or another client, on any platform (windows, android, etc). Slow clients simply exacerbate the problem since the file takes longer to download.
Expected results
The expected results is that apache uses low CPU when the amount of traffic being sent over the network is low.
Actual results
High CPU usage throughout the file transfer (each apache thread serving the client using 100% of its core, even if transferring only at 1Mbps)
Windows build:
Microsoft Windows [Version 10.0.14393]
Steps / All commands required to reproduce the error from a brand new installation
On a clean WSL console, install apache and PHP5:
apt install apache2 php5
Then copy the following file (garbage.php) to /var/www/html and make it executable (
chmod +x garbage.php
) - make sure to rename garbage.php.txt to garbage.php since github doesn't allow php files as in-line uploads.garbage.php.txt
Now, open a web browser on the windows side (I used google chrome, with network throttling on the tab, using its developer tools as shown below)
Then, on the "throttled" tab, browse to localhost/garbage.php and a file called random.dat will start downloading immediately.
On WSL's bash console, executing
top
will show the apache thread at 100% cpu for the core as shown below:While the download itself is proceeding at the rate-limit specified:
On the WSL host, it can be seen that apache is trying to do a write and failing most of the time due to the buffers being full. The write fails with EAGAIN and calls the poll function. Poll immediately returns with POLLOUT with almost no timeout, but the subsequent write fails again as the buffer is still full.
The exact same configuration / process running natively on a linux host runs as follows:
(The writev's buffer was truncated to help on the screen capture here)
As it can be seen, On linux, there are two subsequent writev calls, the first one suceeding to write 65520 bytes to the TCP stack and the immediate next failing due to EAGAIN. Then poll blocks for 250msec, returns with POLLOUT and the next write suceeds.
On the WSL process, the writev fails, poll is called and returns IMMEDIATELY with POLLOUT, in theory indicating that new writes could be done, but the next write call fails again.
The only successfull writev calls on WSL are the following:
Where the whole 1Megabyte buffer is written out. The additional write / gettimeofday are for debug messages inside the garbage.php file.
The following section includes the same part of the calls for the linux host:
If additional files are needed, please let me know. The issue is extremely straightforward to reproduce and happens every single time.
So far, it seems that the call to poll is returning immediately indicating that the buffer is ready to be written (the POLLOUT value) while it should be blocking/timing out. On linux we see that the call to poll blocks for roughly 220msecs, which is the time needed for the ~64Kbytes to be transmitted to the client at the 2Mbps rate limit applied by chrome.
The text was updated successfully, but these errors were encountered: