fare / projects

Various projects you might work on
5 stars 0 forks source link

Interactive evaluation with instant feedback #11

Open fare opened 4 years ago

fare commented 4 years ago

Implement for your interactive environment an adaptive evaluation strategy that provides low-latency feedback.

First, see if you have already compiled the code with high optimization and high debugging, at which point you'll use that version.

If the user request involves new code, first run it with no optimization, no debugging, but set a timer to interrupt after a "jiffy", some small fraction of a second, say one or a few hundredth of a second. After a jiffy, you know the computation isn't completely trivial, so restart with a little optimization, but still no debugging. After another jiffy, you now know the computation is to some degree problematic, so recompile with a little optimization and a lot of debugging. Finally, ever increase the optimization level as the code runs, but with exponential backoff for jiffy duration.

Result: by the time the user's brain even registers any latency in getting a result (in say 1/10th of a second), the computer can display useful feedback for the user to debug any issue.

As for displaying the feedback, well, it can be done nearly instantly. Indeed, any data structure display is O(1): just recurse through the data structure to output information to a stream, but cut the stream as soon as the information goes past the allotted fragment of the interactive display, which is finite and bounded. Or equivalently, start to display a single object as an interactive box that expands with more details when the user clicks, then simulate a user that clicks on every box breadth-first until the expanded boxes fill the allotted area. If novice game programmers can display a rich 3D world at 25+ frames per second at 4K resolution, but your user feedback including partial results and stack traces take many seconds to show, then your are pretty incompetent as a programming language implementer.

fare commented 4 years ago

Emmanuel Oga suggests to look at https://www.stopify.org/