This page provides some notes and thoughts (primarily from Arthur Peters) about performance optimization of ORC.

Optimizing execution of limted-sequence: limit(f) >x> g#

This pattern is interesting in that in a sense it is the most "sequential" of the operators as it does not even allow the 2 expressions to run in parallel: when f publishes it is terminated and then g is started. Because of this sequential execution this could be executed as a goto with a parameter in compiled code. This means that for cases where it is applicable the result is faster than normal sequential and uses less stack space.

Optimizing execution of the sequential operator: f >x> g#

For cases where the g does very little work (this will need a heuristic), this could be implemented as a function call replacing each publication of f. This would remove the parallelism but would still match the semantics and would avoid spawning of thread or internal token scheduling.

Extra work vs process management costs#

The pruning operators (including the optimized sequential-pruning operator) both conceptually terminate an expression after it publishes. However there is no guarantee how long after. This provides an optimization opportunity in that sometimes it may not be worth terminating an expression instead just letting it run. A case where this is true might be something like:
def f() = Ref() >r> (2 | (r := 2) >> stop)
x <x< f
The cost of storing a value in the ref is probably less than terminating the expression, so it is better to just let it run.

However in other cases termination is very important for performance:

def f() = Ref() >r> (2 | metro() >> expensive(r) >> stop)
x <x< f
In this case allowing expensive(r) to run indefinitely is useless and a performance problem. This means that it will be an important trade off (not unlike inlining) as to whether the likely amount of work that will occur after it should have been terminated is more than the cost of terminating it. A heuristic will be needed.

Add new attachment

Only authorized users are allowed to upload new attachments.
« This page (revision-3) was last changed on 01-Oct-2013 14:21 by Arthur Peters