joyent/node — pull request #5437 by isaacs (2013-05-08 23:29:31+00:00)
Title: Http more corking

Depends on #5434, hence the duplicate commit.

Make the `corked` flag a counter, so that you can cork multiple times and then uncork that many times to release the flow to _writev.

Then get rid of the http "hacky hot path" code in http.OutgoingMessage.end, instead using cork/uncork.

Significant improvements in a few benchmarks, and no statistically significant diffs in the others. Note that http benchmarks exhibit around 5% jitter. This could be improved by setting NODE_BENCH_RUNS higher to run it more times, but that takes literally forever.

```
http/chunked.js num=1 size=1 c=100: ./node: 9384.8 ./node-master: 9000.6 ............................ 4.27%
http/chunked.js num=1 size=64 c=100: ./node: 9169.6 ./node-master: 9125.9 ........................... 0.48%
http/chunked.js num=1 size=256 c=100: ./node: 9315.2 ./node-master: 8826.8 .......................... 5.53%
http/chunked.js num=4 size=1 c=100: ./node: 5553.3 ./node-master: 5354.9 ............................ 3.71%
http/chunked.js num=4 size=64 c=100: ./node: 5105.9 ./node-master: 5260.3 .......................... -2.94%
http/chunked.js num=4 size=256 c=100: ./node: 4880.2 ./node-master: 5165.1 ......................... -5.52%
http/chunked.js num=8 size=1 c=100: ./node: 3239.6 ./node-master: 3311.8 ........................... -2.18%
http/chunked.js num=8 size=64 c=100: ./node: 3121.4 ./node-master: 3190.8 .......................... -2.18%
http/chunked.js num=8 size=256 c=100: ./node: 3201.4 ./node-master: 3124.4 .......................... 2.46%
http/chunked.js num=16 size=1 c=100: ./node: 1649.9 ./node-master: 1607 ............................. 2.67%
http/chunked.js num=16 size=64 c=100: ./node: 1556.8 ./node-master: 1449.3 .......................... 7.42%
http/chunked.js num=16 size=256 c=100: ./node: 1562.3 ./node-master: 1391.2 ........................ 12.30%
http/cluster.js type=bytes length=4 c=50: ./node: 16043 ./node-master: 16527 ....................... -2.93%
http/cluster.js type=bytes length=4 c=500: ./node: 14294 ./node-master: 14168 ....................... 0.89%
http/cluster.js type=bytes length=1024 c=50: ./node: 14343 ./node-master: 14084 ..................... 1.84%
http/cluster.js type=bytes length=1024 c=500: ./node: 12926 ./node-master: 12841 .................... 0.66%
http/cluster.js type=bytes length=102400 c=50: ./node: 499.5 ./node-master: 491.18 .................. 1.69%
http/cluster.js type=bytes length=102400 c=500: ./node: 445.96 ./node-master: 440.62 ................ 1.21%
http/cluster.js type=buffer length=4 c=50: ./node: 14809 ./node-master: 14491 ....................... 2.19%
http/cluster.js type=buffer length=4 c=500: ./node: 13428 ./node-master: 13276 ...................... 1.14%
http/cluster.js type=buffer length=1024 c=50: ./node: 14589 ./node-master: 14378 .................... 1.47%
http/cluster.js type=buffer length=1024 c=500: ./node: 12380 ./node-master: 12813 .................. -3.38%
http/cluster.js type=buffer length=102400 c=50: ./node: 9315.5 ./node-master: 6970.6 ............... 33.64%
http/cluster.js type=buffer length=102400 c=500: ./node: 8596.4 ./node-master: 6123 ................ 40.40%
http/end-vs-write-end.js type=asc kb=64 c=100 method=write: ./node: 3194.7 ./node-master: 3024.3 .... 5.63%
http/end-vs-write-end.js type=asc kb=64 c=100 method=end : ./node: 2747 ./node-master: 3091.5 .... -11.14%
http/end-vs-write-end.js type=asc kb=128 c=100 method=write: ./node: 1659.8 ./node-master: 1532.6 ... 8.30%
http/end-vs-write-end.js type=asc kb=128 c=100 method=end : ./node: 1509.5 ./node-master: 1647.2 .. -8.36%
http/end-vs-write-end.js type=asc kb=256 c=100 method=write: ./node: 987.42 ./node-master: 930.36 ... 6.13%
http/end-vs-write-end.js type=asc kb=256 c=100 method=end : ./node: 812.56 ./node-master: 934.77 . -13.07%
http/end-vs-write-end.js type=asc kb=1024 c=100 method=write: ./node: 218.22 ./node-master: 207.8 ... 5.01%
http/end-vs-write-end.js type=asc kb=1024 c=100 method=end : ./node: 233.61 ./node-master: 212.11 . 10.14%
http/end-vs-write-end.js type=utf kb=64 c=100 method=write: ./node: 4679.5 ./node-master: 4583.4 .... 2.10%
http/end-vs-write-end.js type=utf kb=64 c=100 method=end : ./node: 4692.1 ./node-master: 4648.7 .... 0.93%
http/end-vs-write-end.js type=utf kb=128 c=100 method=write: ./node: 2203.3 ./node-master: 2093.8 ... 5.23%
http/end-vs-write-end.js type=utf kb=128 c=100 method=end : ./node: 2275.7 ./node-master: 2219.6 ... 2.53%
http/end-vs-write-end.js type=utf kb=256 c=100 method=write: ./node: 1338.3 ./node-master: 1292.9 ... 3.51%
http/end-vs-write-end.js type=utf kb=256 c=100 method=end : ./node: 1223.2 ./node-master: 1350.8 .. -9.45%
http/end-vs-write-end.js type=utf kb=1024 c=100 method=write: ./node: 388.35 ./node-master: 373.6 ... 3.95%
http/end-vs-write-end.js type=utf kb=1024 c=100 method=end : ./node: 342.19 ./node-master: 379.1 .. -9.74%
http/end-vs-write-end.js type=buf kb=64 c=100 method=write: ./node: 7215.8 ./node-master: 6983.3 .... 3.33%
http/end-vs-write-end.js type=buf kb=64 c=100 method=end : ./node: 7728.8 ./node-master: 6221.9 ... 24.22%
http/end-vs-write-end.js type=buf kb=128 c=100 method=write: ./node: 5427.4 ./node-master: 5194.9 ... 4.48%
http/end-vs-write-end.js type=buf kb=128 c=100 method=end : ./node: 5968 ./node-master: 4833.7 .... 23.47%
http/end-vs-write-end.js type=buf kb=256 c=100 method=write: ./node: 3862.2 ./node-master: 3527.2 ... 9.50%
http/end-vs-write-end.js type=buf kb=256 c=100 method=end : ./node: 4163.1 ./node-master: 3439 .... 21.06%
http/end-vs-write-end.js type=buf kb=1024 c=100 method=write: ./node: 1380.7 ./node-master: 1308.4 .. 5.53%
http/end-vs-write-end.js type=buf kb=1024 c=100 method=end : ./node: 1249.7 ./node-master: 1316.2 . -5.05%
http/simple.js type=bytes length=4 c=50: ./node: 11778 ./node-master: 12410 ........................ -5.09%
http/simple.js type=bytes length=4 c=500: ./node: 10282 ./node-master: 9883.1 ....................... 4.04%
http/simple.js type=bytes length=1024 c=50: ./node: 10550 ./node-master: 10559 ..................... -0.09%
http/simple.js type=bytes length=1024 c=500: ./node: 9650.6 ./node-master: 9221.9 ................... 4.65%
http/simple.js type=bytes length=102400 c=50: ./node: 354.34 ./node-master: 354.57 ................. -0.06%
http/simple.js type=bytes length=102400 c=500: ./node: 321.55 ./node-master: 317.76 ................. 1.19%
http/simple.js type=buffer length=4 c=50: ./node: 10775 ./node-master: 10818 ....................... -0.40%
http/simple.js type=buffer length=4 c=500: ./node: 10446 ./node-master: 10253 ....................... 1.88%
http/simple.js type=buffer length=1024 c=50: ./node: 10939 ./node-master: 11292 .................... -3.13%
http/simple.js type=buffer length=1024 c=500: ./node: 10585 ./node-master: 10801 ................... -2.00%
http/simple.js type=buffer length=102400 c=50: ./node: 7027.6 ./node-master: 5200.6 ................ 35.13%
http/simple.js type=buffer length=102400 c=500: ./node: 6100.7 ./node-master: 4523.5 ............... 34.87%
```