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

Enable inference on throw blocks #47595

Conversation

oscardssmith
Copy link
Member

This removes the disabling of inference on error paths. This will need careful evaluation (probably a nanosoldier and package eval)

@KristofferC
Copy link
Member

KristofferC commented Nov 16, 2022

I feel like this is lacking some context. Clearly, the current choice was put there for some reason (#35982). So what has changed? What is the argument for spending inference time on code that will throw?

Also, I don't think this change any benchmarks or package tests, it would just infer more than it currently does.

If this is needed for some non-standard code usage (say GPU or similar) I think this should be applied only when explicitly enabled from a custom interpreter.

@aviatesk
Copy link
Member

What's the motivation? This feature is added and enabled intentionally since we figured out this is good for latency.

We should check impacts on latency carefully.

@oscardssmith
Copy link
Member Author

@KristofferC a lot of the motivation for this PR is that in between then and now we added the effect system and inferring tighter effects can help latency a bunch since it allows us to run constant folding more often.

@KristofferC
Copy link
Member

Did you check a TTFP or something?

@oscardssmith
Copy link
Member Author

I haven't yet, but plan to.

@Keno
Copy link
Member

Keno commented Nov 16, 2022

The core issue here is that unoptimizing error paths interacts badly with effects inference, which can cause more latency problems than it solves. We should re-evaluate the trade-off.

@brenhinkeller brenhinkeller added compiler:effects effect analysis compiler:inference Type inference labels Nov 16, 2022
@DilumAluthge DilumAluthge force-pushed the try-optimizeing-throw-blocks branch from cb89830 to 3b851ff Compare November 17, 2022 13:58
@KristofferC KristofferC changed the title try optimizing throw blocks Enable inference on throw blocks Nov 17, 2022
@aviatesk
Copy link
Member

@oscardssmith Could you check the numbers reported in #35982 on this PR with rebasing the latest master?

@Keno
Copy link
Member

Keno commented Mar 17, 2023

Just saw another case where this issue is seriously pessimizing effects. Can we do the benchmarking and see where we're at?

Keno added a commit that referenced this pull request Mar 17, 2023
My primary motivation here was to get the Xoshiro constructor to
be removed if the RNG is unused (I have a struct that always has
an RNG in it, which may or may not be used). I first tried to
do that in a more fine-grained way, but #47595 currently makes
that infeasible. Nevertheless, I figured it was worth leaving
those improvements in so we can switch over once #47595 is
resolved. In the meantime, annotate the top-level Xoshiro
constructor as `:removable`.
@oscardssmith oscardssmith force-pushed the try-optimizeing-throw-blocks branch from 3b851ff to 7970bc5 Compare March 28, 2023 17:52
@oscardssmith
Copy link
Member Author

@nanosoldier runbenchmarks("inference")

@nanosoldier
Copy link
Collaborator

Your benchmark job has completed - successfully executed benchmarks. A full report can be found here.

@vtjnash
Copy link
Member

vtjnash commented Mar 28, 2023

@nanosoldier runbenchmarks("inference", vs=":master")

@oscardssmith
Copy link
Member Author

why is vs=":master" necessary?

@KristofferC
Copy link
Member

Otherwise it doesn't run a comparison. It just gives you absolute values.

@nanosoldier
Copy link
Collaborator

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here.

@staticfloat
Copy link
Member

I think we should get some larger benchmarks that include some runtime performance as well. Let's get the compile-time benchmarks of large packages such as Plots and OmniPackage on this branch.

Let's also get some runtime benchmarks from nanosoldier on the broadcast and random suites, since we're spending so much time on those inference paths, let's see if we're getting any better runtime for our trouble.

@Keno
Copy link
Member

Keno commented Mar 31, 2023

We should consider trying a version of it that only deoptimizes the throw blocks if and only if the effects already make it constprop ineligibile, but we should also evaluate the original motivating benchmarks from when this change was introduced. Inference mcirobenchmark time is sort of the wrong benchmark here, because we do expect it to do more work ahead of time, just potentially armotizing it later with better constprop.

@aviatesk
Copy link
Member

aviatesk commented Apr 3, 2023

Replaced by #49235.

@aviatesk aviatesk closed this Apr 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:effects effect analysis compiler:inference Type inference
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants