Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upNagle #283
Conversation
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
kevinburke
Nov 18, 2013
Contributor
I deleted my remote branch, that closed the old PR. This one is cleaner now
|
I deleted my remote branch, that closed the old PR. This one is cleaner now |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Looks fairly sane. Is there anything left to do here? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
kevinburke
Nov 18, 2013
Contributor
Yeah - what do you think about making this configurable with a flag passed to the connectionpool?
|
Yeah - what do you think about making this configurable with a flag passed to the connectionpool? |
shazow
reviewed
Nov 18, 2013
| } | ||
| class HTTPConnection(_HTTPConnection, object): |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
shazow
Nov 18, 2013
Collaborator
Yeah - what do you think about making this configurable with a flag passed to the connectionpool?
I'm -1 to exposing yet another flag to the public interface for now, but perhaps this is a better compromise: What if we add a disable_nagle = True to the connection class, that people can override if they want? Then we can check if self.disable_nagle: ... before disabling it.
I'm -1 to exposing yet another flag to the public interface for now, but perhaps this is a better compromise: What if we add a |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Ok, updated |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Ping @HonzaKral, this is relevant to your interests. :) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
HonzaKral
commented
Nov 18, 2013
|
Thanks for the ping, and for the code obviously :) It looks good. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
shazow
Nov 18, 2013
Collaborator
Disable Nagle's Algorithm on the socket for non-proxies. (Issue #254)
How are we leaving Nagle enabled for proxies? (Am I missing something?)
How are we leaving Nagle enabled for proxies? (Am I missing something?) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
kevinburke
Nov 19, 2013
Contributor
I'm not sure what was meant by that comment. We can only disable Nagle (set socket options) in places where we actually create the socket. I grepped the source code for other references to sock or socket (places where we could set the socket option) and couldn't find anything.
I'm not too familiar with proxies though, it's possible I'm missing something.
|
I'm not sure what was meant by that comment. We can only disable Nagle (set socket options) in places where we actually create the socket. I grepped the source code for other references to I'm not too familiar with proxies though, it's possible I'm missing something. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
shazow
Nov 19, 2013
Collaborator
I think this optimization is harmful for proxies, since the underlying data transmission is less fragmented. At least if you look at other libs like httplib2, they forego disabling nagle in proxies.
Perhaps what we need to do is change ProxyManager so that it overrides PoolManager._new_pool(...), calls the super, but sets the returned constructed pool's tcp_nodelay=0 right before returning it (and add a note there why we do it). Does that make sense?
@HonzaKral Are you aware of any of the details re nagle and proxies?
|
I think this optimization is harmful for proxies, since the underlying data transmission is less fragmented. At least if you look at other libs like httplib2, they forego disabling nagle in proxies. Perhaps what we need to do is change @HonzaKral Are you aware of any of the details re nagle and proxies? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
HonzaKral
Nov 19, 2013
@shazow no, I am not aware of any differences and from the nature of things I don't understand how it would be harmful. But then again there is a reason why I am not a network programmer ;)
HonzaKral
commented
Nov 19, 2013
|
@shazow no, I am not aware of any differences and from the nature of things I don't understand how it would be harmful. But then again there is a reason why I am not a network programmer ;) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
kevinburke
Nov 20, 2013
Contributor
@shazow I agree that packets can get a little smaller. I guess as a general note, it's also possible/likely people are implementing proxies outside of Python, for example connecting to HAProxy or Squid running on the same machine.
I'm a little more hesitant to disable this by default... it is useful for my usecase (a time-critical API where we absolutely want packets sent as fast as possible) and @HonzaKral's use case as well, but not sure it is useful in the general case.
Browsing other HTTP clients it seems like they generally leave it off by default. This is by no means an extensive list.
- http://docs.oracle.com/javase/1.5.0/docs/api/java/net/SocketOptions.html#TCP_NODELAY
- https://bugs.ruby-lang.org/issues/8681
- http://linux.die.net/man/3/curl_easy_setopt (scroll down a ways)
For completeness, it does look like this library sets it.
|
@shazow I agree that packets can get a little smaller. I guess as a general note, it's also possible/likely people are implementing proxies outside of Python, for example connecting to HAProxy or Squid running on the same machine. I'm a little more hesitant to disable this by default... it is useful for my usecase (a time-critical API where we absolutely want packets sent as fast as possible) and @HonzaKral's use case as well, but not sure it is useful in the general case. Browsing other HTTP clients it seems like they generally leave it off by default. This is by no means an extensive list.
For completeness, it does look like this library sets it. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
shazow
Nov 20, 2013
Collaborator
Also https://code.google.com/p/httplib2/source/browse/python2/httplib2/__init__.py#886 Though the py3 version of httplib2 does not have any such thing.
Thinking of it rationally, since the Nagle algorithm clumps together smaller packets into one send, it makes sense to keep it enabled for proxies, which would have all packets going to the same place, thus would have more benefit from Nagle.
|
Also https://code.google.com/p/httplib2/source/browse/python2/httplib2/__init__.py#886 Though the py3 version of httplib2 does not have any such thing. Thinking of it rationally, since the Nagle algorithm clumps together smaller packets into one send, it makes sense to keep it enabled for proxies, which would have all packets going to the same place, thus would have more benefit from Nagle. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
kevinburke
Jan 16, 2014
Contributor
Sorry... picking this back up again. That's fair. I haven't worked too much with proxies and thought of them as two distinct HTTP hops, kind of like Squid, instead of a single request that is made by way of a middle server.
|
Sorry... picking this back up again. That's fair. I haven't worked too much with proxies and thought of them as two distinct HTTP hops, kind of like Squid, instead of a single request that is made by way of a middle server. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
shazow
Jan 16, 2014
Collaborator
@kevinburke Thanks for picking this up again, Kevin.
Is this good to be merged on your end?
|
@kevinburke Thanks for picking this up again, Kevin. Is this good to be merged on your end? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
kevinburke
Jan 16, 2014
Contributor
Just need to figure out how to configure the setting for proxies...
Kevin Burke | Twilio
phone: 925.271.7005 | kev.inburke.com
On Wed, Jan 15, 2014 at 5:48 PM, Andrey Petrov notifications@github.comwrote:
@kevinburke https://github.com/kevinburke Thanks for picking this up
again, Kevin.Is this good to be merged on your end?
—
Reply to this email directly or view it on GitHubhttps://github.com/shazow/urllib3/pull/283#issuecomment-32435440
.
|
Just need to figure out how to configure the setting for proxies... Kevin Burke | Twilio On Wed, Jan 15, 2014 at 5:48 PM, Andrey Petrov notifications@github.comwrote:
|
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
kevinburke
Jan 16, 2014
Contributor
Pushed code that I think does what we want; I am worried by the lack of testing so I am adding tests that the socket options are set the way we expect.
|
Pushed code that I think does what we want; I am worried by the lack of testing so I am adding tests that the socket options are set the way we expect. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
shazow
Jan 16, 2014
Collaborator
Could you git rebase master; git push --force ... to get rid of the extraneous commits and make it mergeable?
I am adding tests that the socket options are set the way we expect.
Excellent, thank you.
Let me know when I should do a final review and merge. :)
|
Could you
Excellent, thank you. Let me know when I should do a final review and merge. :) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
kevinburke
Jan 16, 2014
Contributor
Ok, per your comment in the other PR I changed back the names. I also updated some documentation references
|
Ok, per your comment in the other PR I changed back the names. I also updated some documentation references |
added a commit
that referenced
this pull request
Jan 16, 2014
shazow
merged commit 951ea12
into
urllib3:master
Jan 16, 2014
1 check passed
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
shazow
Jan 16, 2014
Collaborator
Strange how the PR attributes these commits to me, but oh well. :) Thanks again, Kevin!
|
Strange how the PR attributes these commits to me, but oh well. :) Thanks again, Kevin! |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
kevinburke
Jan 16, 2014
Contributor
Yeah I think it's cause I squashed all of my commits onto yours... I'm sure
I could fix it if I knew how to git
On Thursday, January 16, 2014, Andrey Petrov notifications@github.com
wrote:
Strange how the PR attributes these commits to me, but oh well. :) Thanks
again, Kevin!—
Reply to this email directly or view it on GitHubhttps://github.com/shazow/urllib3/pull/283#issuecomment-32537418
.
Kevin Burke | Twilio
phone: 925.271.7005 | kev.inburke.com
|
Yeah I think it's cause I squashed all of my commits onto yours... I'm sure On Thursday, January 16, 2014, Andrey Petrov notifications@github.com
Kevin Burke | Twilio |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
shazow
Jan 16, 2014
Collaborator
The squash prolly wasn't necessary, just a plain rebase would have done it.
|
The squash prolly wasn't necessary, just a plain rebase would have done it. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
HonzaKral
Feb 28, 2014
This is an important change for us, can we maybe get a release with this in it?
HonzaKral
commented
Feb 28, 2014
|
This is an important change for us, can we maybe get a release with this in it? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
shazow
Feb 28, 2014
Collaborator
@HonzaKral I've been waiting for the Retry PR before pushing v1.8 but I guess there's no real reason to wait. I'll try to push this out in the next few days. Sorry for the delay. Don't hesitate to bug me like this. :)
|
@HonzaKral I've been waiting for the |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
@HonzaKral Good news, v1.8 is published. :) Enjoy! |
kevinburke commentedNov 18, 2013
No description provided.