anoma / juvix

A language for intent-centric and declarative decentralised applications
https://docs.juvix.org
GNU General Public License v3.0
457 stars 53 forks source link

Nockma backend: reduce the number of things stored in closures #3042

Closed lukaszcz closed 1 month ago

lukaszcz commented 2 months ago

I believe it's not necessary to store all this stuff in closures, or some rarely used stuff can be moved to one "extra" field, the pointer to which would be just passed around most of the time.

The point is that at each function call you need to create a list with all these things. Hence, the length of this list has a significant impact on the overall running time.

In a purely functional programming language, function calls are the main way of transferring control ("loops" are implemented with function calls) and functions themselves are typically small. This means that the total number of operations performed is proportional (with a relatively small constant) to the number of function calls. Hence, any constant factor inefficiency in function call implementation translates to a comparable constant factor slowdown of the entire program. Function calls need to be as efficient as possible.