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

constprop: Add facility for widening arguments before constprop #54036

Merged
merged 1 commit into from
Apr 11, 2024

Conversation

Keno
Copy link
Member

@Keno Keno commented Apr 11, 2024

There are various situations where we may want to constprop with something other than the most precise concrete arguments in order to make the resulting cache more useful to other call sites. One particular example of this might be a method where non-concrete inference already discovered that one argument is unused:

function foo(a, b::DispatchOnly)
    expensive_to_compile(a)
end

Right now, we will generally perform constprop for every different value of b, even though we already have the information that b is unused.

Another example is external absints that may want to treat certain types fully symbolically. They may want to substitute concrete values for an abstract domain.

This adds the facility to do both of these things by

  1. Adding an appropriate interp hook in the constprop path
  2. Adding a WidendedSimpleArgtypes wrapper that's like SimpleArgtypes but works around an issue where we would override cache information using values from concrete eval, which is not legal if the argtypes were widened.

@Keno Keno requested a review from aviatesk April 11, 2024 04:29
Copy link
Member

@aviatesk aviatesk left a comment

Choose a reason for hiding this comment

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

It could be a valuable move to use WidenedArgtypes for boosting cache hits when there are unused arguments. Should I go ahead and try implementing it (maybe it not be that simple as it likely requires something like EA though)?

base/compiler/abstractinterpretation.jl Outdated Show resolved Hide resolved
There are various situations where we may want to constprop with
something other than the most precise concrete arguments in order
to make the resulting cache more useful to other call sites. One
particular example of this might be a method where non-concrete
inference already discovered that one argument is unused:

```
function foo(a, b::DispatchOnly)
    expensive_to_compile(a)
end
```

Right now, we will generally perform constprop for every different
value of `b`, even though we already have the information that `b`
is unused.

Another example is external absints that may want to treat certain
types fully symbolically. They may want to substitute concrete values
for an abstract domain.

This adds the facility to do both of these things by
1. Adding an appropriate interp hook in the constprop path
2. Adding a WidendedSimpleArgtypes wrapper that's like SimpleArgtypes but
   works around an issue where we would override cache information using
   values from concrete eval, which is not legal if the argtypes were
   widened.
@Keno Keno force-pushed the kf/widenconstargtypes branch from 694efe8 to 1d2caf5 Compare April 11, 2024 06:52
@Keno
Copy link
Member Author

Keno commented Apr 11, 2024

It could be a valuable move to use WidenedArgtypes for boosting cache hits when there are unused arguments. Should I go ahead and try implementing it (maybe it not be that simple as it likely requires something like EA though)?

Yes, that's the natural extension of this PR - I just didn't try it yet. I think EA may compute it as it goes, but yeah, it's not quite the same analysis.

@aviatesk aviatesk merged commit f085913 into master Apr 11, 2024
7 checks passed
@aviatesk aviatesk deleted the kf/widenconstargtypes branch April 11, 2024 14:11
aviatesk added a commit that referenced this pull request Apr 11, 2024
This commit implements the idea concept suggested in #54036 to stop
constant propagation for unused arguments. There are still some tasks
to complete, but I've turned it into a PR to facilitate benchmarking.
The pending tasks are as follows:
- [ ] incorporate used-ness information derived from abstract
      interpretation (this will address the `@test_broken` that is
      being added by this commit)
- [ ] apply `WidenedArgtypes` appropriately
aviatesk added a commit that referenced this pull request Apr 12, 2024
This commit implements the idea concept suggested in #54036 to stop
constant propagation for unused arguments. There are still some tasks
to complete, but I've turned it into a PR to facilitate benchmarking.
The pending tasks are as follows:
- [ ] incorporate used-ness information derived from abstract
      interpretation (this will address the `@test_broken` that is
      being added by this commit)
- [ ] apply `WidenedArgtypes` appropriately
aviatesk added a commit that referenced this pull request Apr 12, 2024
This commit implements the idea concept suggested in #54036 to stop
constant propagation for unused arguments. There are still some tasks
to complete, but I've turned it into a PR to facilitate benchmarking.
The pending tasks are as follows:
- [ ] incorporate used-ness information derived from abstract
      interpretation (this will address the `@test_broken` that is
      being added by this commit)
- [ ] apply `WidenedArgtypes` appropriately
aviatesk added a commit that referenced this pull request Apr 15, 2024
This commit implements the idea concept suggested in #54036 to stop
constant propagation for unused arguments. There are still some tasks
to complete, but I've turned it into a PR to facilitate benchmarking.
The pending tasks are as follows:
- [ ] incorporate used-ness information derived from abstract
      interpretation (this will address the `@test_broken` that is
      being added by this commit)
- [ ] apply `WidenedArgtypes` appropriately
aviatesk added a commit that referenced this pull request Apr 16, 2024
This commit implements the idea concept suggested in #54036 to stop
constant propagation for unused arguments. There are still some tasks
to complete, but I've turned it into a PR to facilitate benchmarking.
The pending tasks are as follows:
- [ ] incorporate used-ness information derived from abstract
      interpretation (this will address the `@test_broken` that is
      being added by this commit)
- [ ] apply `WidenedArgtypes` appropriately
aviatesk added a commit that referenced this pull request Apr 16, 2024
This commit implements the idea concept suggested in #54036 to stop
constant propagation for unused arguments. There are still some tasks
to complete, but I've turned it into a PR to facilitate benchmarking.
The pending tasks are as follows:
- [ ] incorporate used-ness information derived from abstract
      interpretation (this will address the `@test_broken` that is
      being added by this commit)
- [ ] apply `WidenedArgtypes` appropriately
aviatesk added a commit that referenced this pull request Apr 17, 2024
This commit implements the idea concept suggested in #54036 to stop
constant propagation for unused arguments. There are still some tasks
to complete, but I've turned it into a PR to facilitate benchmarking.
The pending tasks are as follows:
- [ ] incorporate used-ness information derived from abstract
      interpretation (this will address the `@test_broken` that is
      being added by this commit)
- [ ] apply `WidenedArgtypes` appropriately
aviatesk added a commit that referenced this pull request Apr 17, 2024
This commit implements the idea concept suggested in #54036 to stop
constant propagation for unused arguments. There are still some tasks
to complete, but I've turned it into a PR to facilitate benchmarking.
The pending tasks are as follows:
- [ ] incorporate used-ness information derived from abstract
      interpretation (this will address the `@test_broken` that is
      being added by this commit)
- [ ] apply `WidenedArgtypes` appropriately
aviatesk added a commit that referenced this pull request Apr 19, 2024
This commit implements the idea concept suggested in #54036 to stop
constant propagation for unused arguments. There are still some tasks
to complete, but I've turned it into a PR to facilitate benchmarking.
The pending tasks are as follows:
- [ ] incorporate used-ness information derived from abstract
      interpretation (this will address the `@test_broken` that is
      being added by this commit)
- [ ] apply `WidenedArgtypes` appropriately
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