joyent/node — pull request #8293 by JacksonTian (2014-08-30 14:27:07+00:00)
Title: http: avoid use 'binary' encoding in 'res.end()'

Use `binary` will cause `new Buffer()`. It makes `response.end()` slow.

In my test case, `res.end('hello world!');` 47% faster than `res.write('hello world!');res.end();`

Trace these calls, `res.end(data)` use `writev()` path, res.end() use `writeBuffer()` path.

Because use `binary` encoding, the final path is：

```
handle.writeBuffer(req, new Buffer(data, encoding));
```

The `new Buffer()` make it slowly. So change encoding from `binary` to `utf8` to avoid string -> buffer conversion. This patch make my hello world test case speed up 70%.

Test case and benchmark result are here: https://gist.github.com/JacksonTian/382a1ed51e5992fd5e70