From Dyna
Jump to: navigation, search

DynaMO is the planned Dyna Module for Optimization. Its job will be to observe your running Dyna program and make recommendations about how to speed it up.

The Dyna compiler currently does its best via compile-time analysis of your Dyna program. But it faces dozens of choices where the optimal decision depends on how your program is actually used. (For example, the precise choice of data structures, the kinds of indices maintained for fast chart lookup, the ordering of if-then tests, and the best way to transform your program.)

This appears to put the compiler at a disadvantage with respect to hand-written code. If you were doing the compiler's job by hand, you might be able to make these decisions intelligently, based on your intuition about what typical runs will look like.

Fortunately, the compiler can develop its own "intuition" by observing your program in action on typical data.

The compiler will eventually support a special "DynaMO" flag that adds profiling code (rather like the -p or -pg options on C++ compilers). The resulting program will run slower because it keeps statistics as it goes. However, it will produce a list of suggestions of two sorts:

  • Add a particular pragma declaration to your program. This will not change the behavior but will speed up the program, for example by using different data structures.
  • Consider adding a particular restrictive declaration to your program. For example, it is quite easy to write a lattice parser in Dyna, but if you are actually running it on strings, then DynaMO will notice that your sentence positions are always integers (rather than lattice nodes), and encourage you to declare them as such for efficiency. Similarly, it is easy to write general rules for manipulating finite-state automata, but DynaMO may notice that your automata are deterministic in practice, and encourage you to add a determinism declaration for efficiency. Such declarations constitute (checked or unchecked) promises about what the input will look like.

To get a faster program, you'll add the recommended declarations and turn profiling off.

Personal tools