Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize occurrence analysis #1328

Merged
merged 2 commits into from
Jul 15, 2023

Conversation

axch
Copy link
Collaborator

@axch axch commented Jul 14, 2023

It was quadratic, because it would recompute the free variables of the rest of the block at every decl. Now it doesn't do that, using the same free variables trick that DCE uses for the same purpose.

On the BFGS example, this speeds up occurrence analysis itself by 60-70%, and (according to the profiler) is worth something like a 7% improvement to compilation time end-to-end.

The implementation was a little subtle because I had to make sure that the Access map's keys were exactly the free variables, without extras. Before this, extras were ok, because names were just looked up in there, but now the absence of a name is also meaningful, so has to be correct.

@axch axch requested a review from dougalm July 14, 2023 21:10
axch added 2 commits July 14, 2023 17:20
…y computed, instead of re-traversing the term.

Pull out a little common machinery between this and DCE, where we also
do this optimization.

On the BFGS example, this speeds up occurrence analysis by 60-70%, and
(according to the profiler) is worth something like a 7% improvement
to compilation time end-to-end.

Also make two minor improvements to classes relating to WriterT1 that
came up while experimenting with this.
`censored` is inspired by `censor` from `MonadWriter`, but (i) can't
reuse that name, and (ii) adverbs are better here anyway because we
are modifying actions.
@axch axch force-pushed the optimize-occurrence-analysis branch from ff3393d to aa8a786 Compare July 14, 2023 21:21
@axch axch merged commit c9ab62c into google-research:main Jul 15, 2023
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.

1 participant