Repository navigation
Trivial patch: Break a cycle - #226
Conversation
|
Its trivial, but it breaks tests |
|
My bad, I should have been more careful. I pushed a second commit which updates the tests. I checked the travis build report : the failure seems unrelated to my patch. I tested on my computer with a fresh build of python 3.3.6, the tests passed. |
|
I am willing to breake test, but I need to see cycle references. Could you On Friday, January 9, 2015, Martin Richard [email protected] wrote:
|
Once the connection is closed, remove the references from the protocol to the reader and writer objects. It will effectively break a references cycle and allow a large group of objects to be freed thanks to the reference counting mechanism, instead of be garbage collected. This obviously a really trivial patch, but in a large application emitting a large amount of requests, it reduces the working time of the gc, and thus, the latency.
4a6601d to
190cb1e
Compare
|
I've got
so protocol => writer => protocol. Actually, the reader does not create a cycle, I made another patch, squashed the 3 commits, and now, the commit is trivial again - sorry for the noise. Thanks to objgraph this can be observed: The source to generate the graph is here https://gist.github.com/Martiusweb/82fa852c1ceebe730307 |
|
When did you take this graph, before or after connection_close get called? On Friday, January 9, 2015, Martin Richard [email protected] wrote:
|
|
Sort, connection_lost |
|
While it's not explicit, it's after connection_lost() since I read the whole response and (afaik) the default request mode is "Connection: close". When my patch is applied, the cycle is broken, and the only things which are garbage collected are caused by the way asyncio implements getaddrinfo(). |
|
LGTM |
|
@Martiusweb Thank you for your graph script, vey interesting. |
|
I'd prefer to fix cycle in first place. Writer should release protocol On Saturday, January 10, 2015, Ludovic Gasc [email protected]
|
|
I've filed https://code.google.com/p/tulip/issues/detail?id=217 and will make a patch after preliminary agreement. |
|
@asvetlov I think you should open it on bugs.python.org, there is a dedicated component to asyncio and gvanrossum, haypo and al answer usually pretty fast. |
|
I think doesn't matter. |

Once the connection is closed, remove the references from the protocol to the
reader and writer objects. It will effectively break a references cycle and
allow a large group of objects to be freed thanks to the reference counting
mechanism, instead of be garbage collected.
This obviously a really trivial patch, but in a large application emitting
a large amount of requests, it reduces the working time of the gc, and thus,
the latency.