Skip to content

Schedules

A schedule answers one question: something changed, so what runs, and in which order? coeval keeps this question out of the meaning of a document. The meaning says what a value is. The schedule says when to compute it.

Schedule When it computes Where it fits
Pull When a reader asks for a value. A change only marks the readers as old. Signals in a browser
Push When a value changes. Its readers compute in the order of the graph, until the values stop changing. A reactive store with epochs
Demand When a cell is read, one time for each run, with a check for cycles A spreadsheet
Once One time, in the written order A server, or a command line

Three formula cards read the inputs a and b. Change a, then read a cell. Each column is one schedule. A lit cell computed in the last step, and a count shows how many times each cell computed.

a = 2, b = 3. The cells start with their values.

Push

A change computes each reader at once, in the order of the graph.

c
add
ref
no path
ref
no path
∅×0
d
multiply
ref
no path
number
2
∅×0
e
multiply
ref
no path
number
10
∅×0

Computations: 0

Pull

A change marks the readers as old. A read computes what is old.

c
add
ref
no path
ref
no path
∅×0
d
multiply
ref
no path
number
2
∅×0
e
multiply
ref
no path
number
10
∅×0

Computations: 0

Demand

Each read computes what it needs, one time for each cell.

c
add
ref
no path
ref
no path
∅×0
d
multiply
ref
no path
number
2
∅×0
e
multiply
ref
no path
number
10
∅×0

Computations: 0

Once

Each read computes each cell again, as a page that a server renders.

c
add
ref
no path
ref
no path
∅×0
d
multiply
ref
no path
number
2
∅×0
e
multiply
ref
no path
number
10
∅×0

Computations: 0

Select Change a, then Read d. Each schedule computes other cells at other times. A lit cell computed in the last step.

For the derive side, each schedule gives the same values. This is the benefit of pure work. Thus each host can choose its own schedule. A browser can pull, a store with epochs can push, and a server can compute a page once.

For the run side, the program itself gives the order. The schedule only starts the run on its trigger.

A schedule needs two things:

  • The graph of the data. Each kind declares what it reads, in its contract. From the contracts, a tool can make the graph of a document before it runs.
  • The side of each kind. A schedule can repeat derive work, and it must not repeat a run.

From the graph, a static analysis gives three results before the start. It finds the cycles, an order for a push schedule, and the independent groups of nodes. Independent groups can compute at the same time.