Another liveness hack #63
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
andat_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.