Open omelkonian opened 2 years ago
A little more context: Back in 2010 @UlfNorell and I noticed that some Agda code that should be linear wasn't, and found a way to make the code faster. The problem is described in the commit comment. The solution we chose was to replace a meta-variable application α A n
with its instantiation A
. However, instantiating meta-variables can lead to other problems. Perhaps it would make sense to perform this kind of instantiation when the solution is sufficiently small (and the size of the solution can be computed quickly).
The slowdown here seems to be a constant factor. It's expected, and it's entirely because of the overhead of the extra inserted meta (with the construction/deconstruction of the unfolding and the extra application).
As I mentioned in the README, currently there's no optimization of elaboration output at all. It makes sense to inline small and linear solutions, and in fact I did exactly this in the old smalltt branch.
There are IMO two complementary ways to add inlining:
In the current Agda Implementor's Meeting, we are trying to ~steal~find ideas in
smalltt
to improve Agda's performance. In the process of doing so, in the context of deciding whether to instantiate meta-variables eagerly/early or lazily/later, we came across a benchmark in Agda which exhibits the case where not instantiating a meta-variable renders subsequent term traversals more costly in an exponential fashion.We ported this example to smalltt and it seems that indeed introducing a variable leads to a significant performance hit, while Agda is unaffected currently: