diff options
Diffstat (limited to 'lib/http.js')
-rw-r--r-- | lib/http.js | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/http.js b/lib/http.js index 2bceaa0152..dacedd4477 100644 --- a/lib/http.js +++ b/lib/http.js @@ -855,6 +855,14 @@ OutgoingMessage.prototype.end = function(data, encoding) { this.connection.writable && this.connection._httpMessage === this; + // The benefits of the hot-path optimization below start to fall + // off when the buffer size gets up near 128KB, because the cost + // of the copy is more than the cost of the extra write() call. + // Switch to the write/end method at that point. Heuristics and + // magic numbers are awful, but slow http responses are worse. + if (hot && Buffer.isBuffer(data) && data.length > 120 * 1024) + hot = false; + if (hot) { // Hot path. They're doing // res.writeHead(); |