haskell-distributed / distributed-process

Cloud Haskell core libraries
http://haskell-distributed.github.io
711 stars 96 forks source link

Enable GC of connections without losing ordering constraints #411

Open mboes opened 9 years ago

mboes commented 9 years ago

From @edsko on November 7, 2012 9:56

When process A sends a message to process B, we must open a connection from A to B and, currently, keep that connection open for the duration of A's lifetime in order to maintain ordering guarantees. If A sends messages to lots of different processes (think of a server responding to clients) this will result in a space leak.

What we need is a way to garbage collect connections when they are no longer used, but still maintain ordering guarantees. There are (at least) two ways in which we might implement this:

Client side seems the easier way to solve this problem.

Copied from original issue: haskell-distributed/distributed-process#64

mboes commented 9 years ago

From @edsko on November 7, 2012 9:59

A related issue is when do we garbage collect connections. One option is to clear them periodically after some timeout period. Another possibility is to collect them when process A has no further references process B (using weak references somehow). The main difficulty there is that ProcessId at the moment is a stateless object, and must be as long as we have pure decoding (ProcessIds are serializable, after all), unless we resort to unsafePerformIO trickery.

mboes commented 9 years ago

From @edsko on November 7, 2012 12:50

Note that there is a manual workaround for people for whom this is an important issue: you can manually cleanup connections by using reconnect. This is described in more detail in a recent blog post.

facundominguez commented 8 years ago

Using usend instead of send avoids this problem, because usend does not create a connection per process pair. The problem would come up still at a different scale when having too many nodes.