mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 15:27:13 +03:00
e2d1a43146
Summary: On the LFS Server, we've noted that LFS batch requests from Mercurial have about ~40ms latency, but that the same request sent through curl doesn't. Those requests, when sent through curl, complete in < 1ms, so thats a lot of overhead. After adding more logging in the LFS server (D18636703), it turned out that that is because the body of the request shows up 40ms after the request itself. After capturing the traffic on the backend (D18689109), it turned out that Mercurial is sending the headers and the response body in 2 separate TCP packets. The reason for that is delayed TCP acks. What happens is that when we call `h.endheaders()`, that calls `send(2)`, which in turns send the packet with the headers. Later, when we call `h.send(data)`, we make another `send(2)` syscall, but that doesn't go over the wire immediately: because of Nagle's algorithm, we wait for an ACK for the first packet we send before sending a new one, and because of delayed ACKs, the ACK takes 40ms for this ACK to show up (which is over 40 times the roundtrip latency!). This diff passes the data to `h.endheaders()`, which in Python's httplib will concatenate the headers and the data into a single `send(2)` syscall if the data isn't a file-like object (which it isn't for batch requests), and otherwise fall back to doing exactly what we're doing right now. This will result in everything in a single packet if we're fetching a single file (and AFAICT, without further delay if we're fetching enough files that the request doesn't fit in a single packet). An alternative approach would be to set `TCP_NODELAY` on our socket here, but for now this seems less intrusive and just as effective, so I've opted for that approach. Reviewed By: farnz Differential Revision: D18811419 fbshipit-source-id: 4cf5719e5eed90e5dd994e6c8861aceb69373d89 |
||
---|---|---|
.. | ||
benchmarks | ||
cli | ||
docs | ||
fs | ||
integration | ||
locale | ||
py | ||
scm | ||
scripts | ||
test_support | ||
test-data | ||
third-party | ||
win | ||
.gitignore | ||
Eden.project.toml |