Skip to content

Zero alloc: more precise handling of recursive functions#2290

Merged
gretay-js merged 13 commits intomainfrom
zero_alloc_rec
Mar 28, 2024
Merged

Zero alloc: more precise handling of recursive functions#2290
gretay-js merged 13 commits intomainfrom
zero_alloc_rec

Conversation

@gretay-js
Copy link
Copy Markdown
Contributor

The analysis of recursive functions is precise with respect to the abstraction but not efficient. The intent is to make it easy to review for correctness. The idea is to save the body of Mach functions that contain unresolved calls (i.e., calls to functions that appears later in the same compilation unit and hence have not yet have a summary). Then, at the end of the compilation unit, computed the fixed point by reanalyzing these functions.

This PR may be easier to read commit-by-commit. The first commit deletes complicated tracking of dependencies for unresolved functions and conservative treats all unreasolved calls as Top. The second commit adds a very simple tracking of unresolved functions (no dependency tracking) and fixed point computation.

@gretay-js
Copy link
Copy Markdown
Contributor Author

The new fixpoint computation may have pathological cases with very high overhead on compilation time and memory, esp if we revert the order of functions back to source code order (see #2287). Benchmarking in progress.

Copy link
Copy Markdown
Contributor

@xclerc xclerc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was already pondering that during my first
review, but I think it would be useful to leave
a comment about why the fixpoint computations
are guaranteed to terminate. I agree it is fairly
obvious given the current domain, so perhaps
it is about documenting the properties that
must be observed on the domain to guarantee
the termination.

This allows us to get rid of a lot of machinery for tracking and
resolving unresolved depedencies. Conservative on functions that have
mutually recursive calls or forward calls.
1) Keep unresolved functions around until the end of the compilation unit
2) Naively compute fixed point at the end of the unit
t.approx should only be used for self rec that has no other unresolved
dependencies.
Pass [keep_witnesses ] as an argument to [Analysis.create] instead of
using default initial value and mutating it later.
@gretay-js gretay-js merged commit bc720fa into main Mar 28, 2024
@gretay-js gretay-js deleted the zero_alloc_rec branch March 28, 2024 14:14
gretay-js added a commit to gretay-js/flambda-backend that referenced this pull request Apr 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants