Re: [reactive] switching events = space leak?

7 views
Skip to first unread message

John Lato

unread,
Feb 6, 2013, 3:22:01 AM2/6/13
to reac...@haskell.org, d...@tr80.com
Hello,
 
From: Don Vincenze <d...@tr80.com>

Hi,

Is this list still alive ...

I am trying to learn the theory of FRP by reading the code of this
"reactive" library and Yampa. Not trying to get anything to actually
work here, analyzing implementations of the theory only serve to assess
the viability of it all. I.e. apart from bugs, is it stable, does it
scale?

For starters I'm worried about space leaks in switching events, e.g. see
the "Event of Events" that's the input to switchE. Those events are
lists that get produced by input producers but not consumed until
they're being switched into, is that right? So during this time of
producing but not consuming the list just grows = there is a space leak?

This can be a serious issue, however most modern FRP implementations (by which I mean at least reactive-banana, elerea, and sodium) have solutions.  I'm sure elm does as well, but I don't have experience with it.

I'm aware of two general approaches.  The first, used by elerea and sodium, enforces that the creation of signaling and switching constructs happen within a monad.  In this case the switching primitive looks something like

mSwitch :: Behavior (SGen a) -> SGen (Behavior a)

this function is responsible for ensuring that signals and behaviors are represented in the monad, and thus executed.

The other approach was introduced in Grapefruit, and to my knowledge is only used in Grapefruit and reactive-banana.  Instead of a signal generation monad, switchable constructs have an extra type parameter that's used to enforce aging.  apfelmus has written a bit about it at http://apfelmus.nfshost.com/blog/2012/09/03-frp-dynamic-event-switching-0-7.html .  Conceptually it's very similar to how the "st" parameter is used in the ST monad if you're familiar with that.

as to scaling, it is possible for a reactive network to scale to fairly large systems, but not all of them do.  I've been meaning to blog about this soon, maybe over the next week or two.

John L.

Don Vincenze

unread,
Feb 6, 2013, 8:25:34 AM2/6/13
to reac...@haskell.org
Wow thank you for all these pointers ... I must take the time to look into these libraries. Stuff like this doesn't come up when you Google "Functional Reactive Programming" or at least doesn't rank very high.
 
I'm not sure I understand the sodium approach (couldn't find switch in elerea). The aging/'trimming' approach in banana seems to rely on the events being switched into being known from the start, i.e. the point in time 'switch' starts executing. This way you can dynamically switch into a static set of events but not dynamically into a dynamic set of events.
 
In any case, considering such concerns seem to be transcend individual libraries/frameworks, you wouldn't know of any mailing list/forum that is more suitable for this discussion, i.e. a general FRP forum not tied to any library or one purely focused on theory?

John Lato

unread,
Feb 7, 2013, 7:13:13 PM2/7/13
to reac...@haskell.org
elerea itself doesn't follow the event/behavior distinction, so it looks quite a bit different from the others.  Also it doesn't have a particular switch combinator, rather switching behavior is enabled by the use of recursive-do bindings.

I think reactive-banana's approach is expressive enough to do as you suggest, but I haven't actually tried it yet.

I'd also be interested in a language-agnostic forum for FRP issues.

John L


at [1]http://apfelmus.nfshost.com/blog/2012/09/03-frp-dynamic-event-swi
tching-0-7.html
.  Conceptually it's very similar to how the "st"

parameter is used in the ST monad if you're familiar with that.

as to scaling, it is possible for a reactive network to scale to fairly
large systems, but not all of them do.  I've been meaning to blog about
this soon, maybe over the next week or two.

John L.

References

1. http://apfelmus.nfshost.com/blog/2012/09/03-frp-dynamic-event-switching-0-7.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/reactive/attachments/20130207/d4748a02/attachment.html>

------------------------------

_______________________________________________
Reactive mailing list
Reac...@haskell.org
http://www.haskell.org/mailman/listinfo/reactive


End of Reactive Digest, Vol 18, Issue 3
***************************************

Stefan Kersten

unread,
Feb 8, 2013, 4:59:38 AM2/8/13
to John Lato, apfe...@quantentunnel.de, reac...@haskell.org
On Feb 8, 2013, at 1:13 AM, John Lato wrote:
> elerea itself doesn't follow the event/behavior distinction, so it looks quite a bit different from the others. Also it doesn't have a particular switch combinator, rather switching behavior is enabled by the use of recursive-do bindings.
>
> I think reactive-banana's approach is expressive enough to do as you suggest, but I haven't actually tried it yet.

one sentence in the package documentation is holding me back from using event switching:

"There is currently no garbage collection for dynamically created events."

any ideas how much work it would be to to fix this? how does sodium compare in this regard?

(cc'ing reactive-banana's author in case he's interested in joining the discussion here ...)

sk

John Lato

unread,
Feb 10, 2013, 8:53:21 PM2/10/13
to Stefan Kersten, apfelmus, reac...@haskell.org
sodium and elerea both have garbage collection for dynamically created events.  However, in practice I find we often need to call performGC to make it happen, because ghc's runtime doesn't seem to schedule major gc's often enough.  But that may only be because we run our reactive app at full tilt, so there are very few unused cycles already.

I don't think it would be all that difficult to add support for this to reactive-banana, but Apfelmus indicated there are a few design issues that need to be resolved when I last discussed this with him.  That was a few months ago though, so maybe he's made some progress.

John
Reply all
Reply to author
Forward
0 new messages