Skip to content

Another liveness hack#63

Merged
lthls merged 7 commits intoocaml-flambda:flambda2.0-stablefrom
lthls:another_liveness_hack
Apr 6, 2020
Merged

Another liveness hack#63
lthls merged 7 commits intoocaml-flambda:flambda2.0-stablefrom
lthls:another_liveness_hack

Conversation

@lthls
Copy link
Copy Markdown

@lthls lthls commented Mar 18, 2020

This tries to avoid exponential blow-up in liveness.
The initial idea from @chambart was to notice if we're recomputing the live set of an expression with the same arguments, in which case we can reuse the previous result.
However, there was a bug because the previous result was read from the live field of the next instruction, which can contain an initial empty set or the result of a previous run, but doesn't mean it is actually the result of the analysis.
In addition, the env parameter needs to be compared too, and it is not stored anywhere.
So I introduced a cache that remembers, for each handler, the last arguments (env and at_join) and result (before_handler) of the last time we went through it.
Of course, this doesn't help much, because the environment will likely be different each time (otherwise we wouldn't get called again), so I cached the restriction of the environment to the free continuations of the handler, which should be safe and still avoid the exponential blow-up.

I haven't run the libbigarray test yet, but will try it and report if it compiles in a reasonable amount of time.

@lthls
Copy link
Copy Markdown
Author

lthls commented Mar 18, 2020

Preliminary results seem to indicate that liveness works fine, but something else allocates a lot and I couldn't get past the OOM killer. I will look further.

@lthls
Copy link
Copy Markdown
Author

lthls commented Mar 18, 2020

So apparently, Spill has the same problem. Guess I'll go for the same solution...

@lthls lthls force-pushed the another_liveness_hack branch from 0c7ff2b to 7d47581 Compare March 20, 2020 13:31
@lthls
Copy link
Copy Markdown
Author

lthls commented Apr 6, 2020

Merging for now, as it blocks further testing, but this should still be reviewed

@lthls lthls merged commit 35d86f3 into ocaml-flambda:flambda2.0-stable Apr 6, 2020
mshinwell pushed a commit that referenced this pull request Apr 7, 2020
* Avoid exponential case in liveness

* Avoid quadratic cases for free conts

* Remove mutable state from spill

* Remove leftover debug

* Use cache for reload

* Remove useless reference in spill

* Add cache for spill

Co-authored-by: Pierre Chambart <pierre.chambart@ocamlpro.com>
lthls added a commit that referenced this pull request Sep 29, 2020
* Avoid exponential case in liveness

* Avoid quadratic cases for free conts

* Remove mutable state from spill

* Remove leftover debug

* Use cache for reload

* Remove useless reference in spill

* Add cache for spill

Co-authored-by: Pierre Chambart <pierre.chambart@ocamlpro.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants