-
Notifications
You must be signed in to change notification settings - Fork 803
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
Implicit yield performance fix #17096
Conversation
…is avoids exponential blowup when checking nested builders with implicit yields
❗ Release notes required
|
Yeah, CE checking is pretty hard and complex currently. This looks like a low hanging fruit. If it doesn't break anything else, it's an easy merge. We need to go through thorough review though. |
…ed expressions * added TType return to TryTcStmt
…ng duplicated ranges of implicitly yielded expressions
Co-authored-by: Vlad Zarytovskii <vzaritovsky@hotmail.com>
Some error messages in |
It is related to the changes, seems to be related to type inference (obj vs int), maybe ordering. I've hit the same (or similar) issue when was implementing caching for custom operations type checking in CEs. |
Good to know, should I try to fix it or just leave it that way? |
It is a change of behavior induced by the change - it does need fixing IMO. |
So the only difference I found is that
now reads:
The |
I agree, it is not a regression. You can change the baseline in the .bsl file to reflect that.
True, that is the only place of impact. |
Hey, I realized that my type-unification didn't have the proper range (i used range0 for testing and forgot about it). I now fixed the range and the regression seems to have disappeared. The only sensible conclusion for me is that the error gets formatted differently when inside the range of some CE. Nonetheless the regression is gone and the rest of the failing checks seem to be unrelated to my change. Cheers |
One failing check is formatting, you can either format locally on your machine (it should be described in Regarding other failures, it's currently some fluke it seems. |
/run fantomas |
Okay I'll try to do that locally 😉 |
Co-authored-by: krauthaufen <6370801+krauthaufen@users.noreply.github.com>
/azp run |
Azure Pipelines successfully started running 2 pipeline(s). |
CI classic 😉 |
Nice 🥳🥳🥳 How do you release these things? We currently work around the problem by explicitly yielding everything but a rough estimate of how long we need to keep this up would be nice. Thanks to everyone involved! |
The monthly SDK releases are typically only security fixes or big regressions. This kind of fix I'd expect to ship in one of the quarterly SDK releases, so I'd expect something like 8.0.400 in the August time frame. Ionide builds on the libraries that this repo produces, which are released on the same cadence as the SDK - monthly security/bugfixes, quarterly feature drops. |
Okay, thanks. Just out of curiosity: does visual studio use the fscs from the relevant sdk or does it have its own copy of things? |
VS has its own copy in-proc for intellisense, diagnostics etc. So change would come with next VS Preview. |
Finally got the fix in VS and Rider, intellisense delay for my projects dropped from "too long to wait" to half a second! 🎉🎉🎉 |
Description
Hey, we're heavily using implicit yields in CE builders for our UI library and have incredibly slow autocomplete & compile times for relatively simple files.
After some investigation we found that the runtime scales exponentially with the nesting depth of such CE builders, like:
A quick repro can be found here: https://gist.github.com/krauthaufen/a23a622beac99a89f5ce9d992266ab91
There you see compile-times around 10s for a 50-line file and whenever you change anything all completions & type-hovers will take a comparable amount of time.
So I did some digging in the compiler-source and found the exponential blow-up which i circumvented by simply caching already type-checked expressions.
This solves our issue and compile-time for the file is down to approx. 0.5s.
In order to test this properly i checked your benchmarks and found no difference in runtimes, which showed that all the CE-benchmarks do not clear the
FsChecker
caches and therefore all tests basically just returned cached results. This of course is not a realistic benchmark for the type-checker.Therefore I adjusted the benchmarks in this PR to run with and without cleared caches. The results show the expected exponential behaviour with the current head and a drastically improved behaviour with my caching fix.
Here are the most important benchmarks compared with cleared FsChecker-Caches (full report below)
With TC-Caching (this PR)
Without TC-Caching (current main branch)
I really hope you can merge this, since our UI library heavily relies on implicit yields and we currently code without autocomplete and have 10m compile times for average projects.
Sadly the benchmarks with the current main branch took ages with the cleared
FsChecker
caches, so i currently only have partial results as seen below, but I think the above tables should be enough to see that11s
vs73ms
for a very simple file is drastic.Let me know if you have any further questions/requirements I need to fix for this to be accepted.
Cheers
Full Benchmark Results for this PR (with cleared FsChecker-Caches)
Partial Benchmark Results for main branch (with cleared FsChecker-Caches)