ssm-lang / Scoria

This is an embedding of the Sparse Synchronous Model, in Haskell!
BSD 3-Clause "New" or "Revised" License
4 stars 0 forks source link

Inefficient distribution of priorities #66

Open j-hui opened 3 years ago

j-hui commented 3 years ago

the way we are currently using the priority and depth, we are evenly distributing the priorities among the forked children.

However, I would imagine a common pattern would be something like this:

main =
  fork outputHandler | actualMain

where most of the interesting stuff starts in actualMain (e.g., forking more processes), while outputHandler is just a leaf process that evaluates output. This means that half of the priorities are effectively wasted on outputHandler.

Is there a better way to distribute the priorities among children, if we know that a process is a leaf process? (tagging @sedwards-lab since he came up with the original approach)

sedwards-lab commented 3 years ago

There almost certainly is a better way to do it if you know how many child processes you're ever going to have. The basic idea is that each child is given a range of priorities, which it then subdivides across its children. By default, it divides its range into powers of two and distributes them equally among children to avoid complicated arithmetic. The waste is primarily due to the "equally" part; if you know exactly how many levels each child will need, you can distribute them better.