Saturday, March 17, 2007

Speculation on unknowns

Here is a way to use all those extra cores for program understanding. If the a function argument is given the pseudo-value DontKnow as an argument, we can try to determine that the value of the function does not depend on that parameter. There are three ways: static analysis, dynamic tagging of the parameter to see if it is ever read, and speculative execution. Speculative execution works only for pure functions on finite enumerable types, hopefully something small like Boolean. A separate thread is spawned for each possible value of the DontKnow argument, and the results are compared for equality. This becomes tricky for higher order functions. Lazy evaluation sometimes lessens the computational load.

This is an application of parallel processing not to increase performance, but to aid a programmer who might be working with unfamiliar difficult to understand code.

Static analysis can be done at compile time, but can also be done just-in-time when the values of the regular known parameters are known. It, too, may be an extra thread.

No comments :