jrsonnet icon indicating copy to clipboard operation
jrsonnet copied to clipboard

WIP: Proper tco optimization

Open CertainLach opened this issue 2 years ago • 1 comments

C++ jsonnet does have proper TCO optimization. However, I haven't used this approach since it is hard to maintain in some cases, especially when it is used in most of the code. But now I got an idea: Why not implement a hybrid approach where TCO exists only for the main interpreter loop and not in the rest of the codebase, i.e. builtins? In this PR I explore this possibility, it may also allow for async builtins/std.parallelMap/huge optimizations in recursive functions/better GC root management strategies.

Stack traces and some other things are broken for now, not ready for use.

CertainLach avatar Jun 18 '23 13:06 CertainLach

Why not implement a hybrid approach where TCO exists only for the main interpreter loop and not in the rest of the codebase, i.e. builtins?

Builtins can be implemented too, I.e by utilizing generators/async-await

In cpp-jsonnet, there is a PR to implement manifestification inside of interpreter loop, and it looks like a cool idea https://github.com/google/jsonnet/pull/1142

CertainLach avatar Mar 09 '24 17:03 CertainLach