Consider garbage collecting events from source to subscriber in Spider

Open
#540 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Quiet
Tech stack
haskell
Domain
backend

Research direction

No files or tests are named. Start by tracing the implementations of switch, the primitive combinators, Adjustable, and the incremental merge functions to understand their event-lifecycle bookkeeping. Done would mean a decided design and coverage showing that EventDead propagates when an event can no longer produce values, without breaking existing event propagation.

Written by the indexing model from the issue text.

Description

We currently unsubscribe from events when "no one is listening", but I think we could do something when "there's nothing to listen for". When an event becomes never via a switch, or from its trigger getting garbage collected, we could propagate an EventDead message. All primitive combinators would then optimize for this, doing the necessary bookkeeping to be able to propagate EventDead when they know they won't produce any more events.

I think this can be understood as "as GC is to manual memory management, so EventDead is to Adjustable"? (Or the incremental family of merge functions?)

Cost

  • Each event propagation has to case on the value. Dead-marking can happen in a side channel, just as height adjustment does.
  • ...

Advantages

  • Write ever-accumulating merges without having to worry about bookkeeping.
  • You could implement, using regular FRP code, optimizations for types like "join-semilattice with a top", which can never change once the top is reached.
  • ...
Dominant language
Haskell
Stars
1.1k
Forks
150
Avg merge
34m
Merged PRs (30d)
4

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from reflex-frp/reflex

All issues in reflex-frp/reflex

Similar issues

More Haskell issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.