RESOLVED FIXED 102079
Disable Nagle algorithm on WebSocket implementation
https://bugs.webkit.org/show_bug.cgi?id=102079
Summary Disable Nagle algorithm on WebSocket implementation
Takashi Toyoshima
Reported 2012-11-13 06:32:20 PST
WebSocket users need to send and receive small packets without latency. But, currently CF port has a flaky latency issue in some environment. This is because CF port doesn't disable Nagle. Combination of Nagle and delayed-ACK causes performance problem. I confirm performance regression happens on communicating from Japan to US using laptop machine over Wifi. I can see the same problem in Safari for OS X and iOS.
Attachments
Patch (2.28 KB, patch)
2012-11-13 06:42 PST, Takashi Toyoshima
buildbot: commit-queue-
Patch (2.42 KB, patch)
2012-11-27 06:47 PST, Takashi Toyoshima
buildbot: commit-queue-
Patch (2.31 KB, patch)
2012-12-06 06:06 PST, Takashi Toyoshima
buildbot: commit-queue-
Patch (1.83 KB, patch)
2012-12-10 21:21 PST, Takashi Toyoshima
buildbot: commit-queue-
Patch (2.97 KB, patch)
2012-12-20 01:25 PST, Takashi Toyoshima
buildbot: commit-queue-
Patch (3.00 KB, patch)
2012-12-20 06:23 PST, Takashi Toyoshima
buildbot: commit-queue-
Patch (1.78 KB, patch)
2012-12-20 06:53 PST, Takashi Toyoshima
ap: review+
ap: commit-queue-
Patch (1.87 KB, patch)
2012-12-20 21:41 PST, Takashi Toyoshima
no flags
Takashi Toyoshima
Comment 1 2012-11-13 06:33:02 PST
FYI, Chrome disables Nagle and doesn't have this problem.
Takashi Toyoshima
Comment 2 2012-11-13 06:42:52 PST
Build Bot
Comment 3 2012-11-13 07:11:18 PST
Alexey Proskuryakov
Comment 4 2012-11-13 10:31:45 PST
10>..\platform\network\cf\SocketStreamHandleCFNet.cpp(41) : fatal error C1083: Cannot open include file: 'netinet/in.h': No such file or directory
Alexey Proskuryakov
Comment 5 2012-11-13 10:51:20 PST
Is the issue you are seeing the one described here <http://www.stuartcheshire.org/papers/NagleDelayedAck/>? Can you please provide a more detailed description of the issue, and attach a tcpdump capture?
Takashi Toyoshima
Comment 6 2012-11-14 03:56:41 PST
Hi Alexey, I sent some data related to this problem in email directly.
Alexey Proskuryakov
Comment 7 2012-11-14 21:28:48 PST
Takashi Toyoshima
Comment 8 2012-11-27 06:47:17 PST
Created attachment 176258 [details] Patch Previous patch fails to set NODELAY.
Build Bot
Comment 9 2012-11-27 07:14:50 PST
Takashi Toyoshima
Comment 10 2012-12-06 06:06:18 PST
Created attachment 178004 [details] Patch Hopefully, this will fix cf/win build.
Takashi Toyoshima
Comment 11 2012-12-06 06:07:29 PST
Comment on attachment 178004 [details] Patch fix MIME Type and patch flag.
Build Bot
Comment 12 2012-12-06 06:43:29 PST
Alexey Proskuryakov
Comment 13 2012-12-06 09:56:06 PST
I think that we should use an SPI here: CFStreamCreatePairWithSocketToHost(0, host.get(), port(), &readStream, &writeStream); + CFWriteStreamSetProperty(writeStream, _kCFStreamSocketSetNoDelay, kCFBooleanTrue); and define the symbol at the top of the file: #if PLATFORM(WIN) #define EXTERN extern "C" __declspec(dllimport) #else #define EXTERN extern "C" #endif EXTERN const CFStringRef _kCFStreamSocketSetNoDelay;
Takashi Toyoshima
Comment 14 2012-12-10 21:21:20 PST
Created attachment 178705 [details] Patch Thanks. Your suggestion works fine!
Build Bot
Comment 15 2012-12-10 21:49:10 PST
Takashi Toyoshima
Comment 16 2012-12-11 00:45:39 PST
16> Creating library C:\cygwin\home\buildbot\WebKit\WebKitBuild\Debug\lib\WebKit.lib and object C:\cygwin\home\buildbot\WebKit\WebKitBuild\Debug\lib\WebKit.exp 16>WebCore.lib(SocketStreamHandleCFNet.obj) : error LNK2001: unresolved external symbol __imp___kCFStreamSocketSetNoDelay 16>C:\cygwin\home\buildbot\WebKit\WebKitBuild\Debug\bin\WebKit.dll : fatal error LNK1120: 1 unresolved externals Oops, stub lib doesn't have an entry for _kCFStreamSocketSetNoDelay seemingly. I'll try the 3rd patch with include wsock2.h.
Takashi Toyoshima
Comment 17 2012-12-20 01:25:04 PST
Created attachment 180294 [details] Patch I'm sorry but I still don't have perfect build environment for CF/WIN. So could you allow me to post a patch for try.
Build Bot
Comment 18 2012-12-20 05:12:18 PST
Takashi Toyoshima
Comment 19 2012-12-20 06:23:59 PST
Build Bot
Comment 20 2012-12-20 06:43:29 PST
Takashi Toyoshima
Comment 21 2012-12-20 06:53:13 PST
Created attachment 180335 [details] Patch Hum... can I give up to support CF/Win...
Alexey Proskuryakov
Comment 22 2012-12-20 09:22:38 PST
Comment on attachment 180335 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=180335&action=review > Source/WebCore/platform/network/cf/SocketStreamHandleCFNet.cpp:282 > + CFWriteStreamSetProperty(writeStream, _kCFStreamSocketSetNoDelay, kCFBooleanTrue); Please add a comment here: // <rdar://problem/12855587> _kCFStreamSocketSetNoDelay is not exported on Windows
Takashi Toyoshima
Comment 23 2012-12-20 21:41:06 PST
WebKit Review Bot
Comment 24 2012-12-20 21:42:51 PST
Comment on attachment 180479 [details] Patch Rejecting attachment 180479 [details] from review queue. toyoshim@chromium.org does not have reviewer permissions according to http://trac.webkit.org/browser/trunk/Tools/Scripts/webkitpy/common/config/committers.py. - If you do not have reviewer rights please read http://webkit.org/coding/contributing.html for instructions on how to use bugzilla flags. - If you have reviewer rights please correct the error in Tools/Scripts/webkitpy/common/config/committers.py by adding yourself to the file (no review needed). The commit-queue restarts itself every 2 hours. After restart the commit-queue will correctly respect your reviewer rights.
WebKit Review Bot
Comment 25 2012-12-20 22:08:26 PST
Comment on attachment 180479 [details] Patch Clearing flags on attachment: 180479 Committed r138348: <http://trac.webkit.org/changeset/138348>
WebKit Review Bot
Comment 26 2012-12-20 22:08:31 PST
All reviewed patches have been landed. Closing bug.
Ryosuke Niwa
Comment 27 2012-12-20 23:07:03 PST
This caused a build failure on Mac: http://build.webkit.org/builders/Apple%20Lion%20Debug%20%28Build%29/builds/9716/steps/compile-webkit/logs/stdio Undefined symbols for architecture x86_64: "__kCFStreamSocketSetNoDelay", referenced from: __ZN7WebCore18SocketStreamHandle13createStreamsEv in SocketStreamHandleCFNet.o ld: symbol(s) not found for architecture x86_64
Alexey Proskuryakov
Comment 28 2012-12-20 23:26:30 PST
Disabled this new code on Lion in r138351 as a build fix.
Takashi Toyoshima
Comment 29 2012-12-20 23:34:34 PST
ap: thanks!
Ryosuke Niwa
Comment 30 2012-12-20 23:43:29 PST
Takashi Toyoshima
Comment 31 2012-12-20 23:53:57 PST
rniwa: Thanks! To my great relief, iOS supports _kCFStreamSocketSetNoDelay ;-)
Note You need to log in before you can comment on or make changes to this bug.