Send content-length instead of chunked transfer#6
Conversation
|
I think content-length better matches the use case I'm interested in, but I don't want to merge this until I understand teh results: how the hheck are urllib3 and requests faster than just reading off a socket! |
|
Try making the socket buffered. Add the line |
|
With: diff --git a/bench_socket.py b/bench_socket.py
index 09f1c7d..4e27687 100644
--- a/bench_socket.py
+++ b/bench_socket.py
@@ -11,8 +11,9 @@ def main():
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("localhost", 8080))
s.sendall(b"GET / HTTP/1.1\r\n\r\n")
+ s = s.makefile('rb')
while True:
- sys.stdout.write(s.recv(CHUNK_SIZE))
+ sys.stdout.write(s.read(CHUNK_SIZE))
if __name__ == "__main__":applied, the results are: which don't look substantially different? |
|
Hmm, interesting. Seems requests and urllib3 are still magical. We do set TCP_NODELAY. To my knowledge TCP_NODELAY shouldn't provide a performance boost in this case, but maybe... |
|
As I recall, |
|
if the horribly named TCP_NODELAY is on, the sender will send packets as I understand it, if it's set in the client, it'd only really affect data Kevin Burke On Fri, Dec 5, 2014 at 11:11 AM, Ian Cordasco notifications@github.com
|
With this the results look like:
Which is... unexpected