lurk-rs icon indicating copy to clipboard operation
lurk-rs copied to clipboard

LEM consumes too many slots

Open arthurpaulino opened this issue 1 year ago • 2 comments

Even after #674, the number of slots for the LEM remains too high.

For example, hash6 slots are only used to construct and deconstruct functions. And yet, we are using 3 slots of that kind. 2 would seem fine because we do deconstruct a function to construct another in the same path once.

Is this correct?

arthurpaulino avatar Sep 15 '23 16:09 arthurpaulino

In order to solve this issue, we will have to do some path analysis in the slot allocation algorithm. As of now, in a sequence of func calls we just add the slots taken by each func. To make it optimal, we'd have to take the maximum slot usage for each possible path going through all funcs, ignoring the impossible paths. Doing it naively is very bad however, since the paths grow exponentially. There should be some good heuristic however, to compute, at least an approximation to the optimal slot allocation

gabriel-barrett avatar Sep 18 '23 23:09 gabriel-barrett

Slot allocation needs to follow all the paths. It should definitely be finite. Can't you effectively inline all the funcs?

The 'right' answer is probably to get this hooked up to FOIL, but I guess you need to figure out something more short-term.

I'm not sure what this exponential growth is about. LEM is only creating flat circuits, and relatively small ones. There aren't that many actual paths to follow, right?

porcuquine avatar Sep 19 '23 00:09 porcuquine