-
Notifications
You must be signed in to change notification settings - Fork 832
Type relations cache: optimize key generation #19120
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
Conversation
❗ Release notes required
|
Co-authored-by: Tomas Grosup <tomasgrosup@microsoft.com>
Co-authored-by: Tomas Grosup <tomasgrosup@microsoft.com>
|
I tested this by building the problematic branch of FSharpPlus: and verified it now manages to finish after a good coffee break. The code in this PR is 100% Gemini 3 via Copilot with only textual prompts. |
|
This needs a double check that other scenarios are not degraded now. |
|
Very informal speed test, because it takes ages: |
|
Compiling just FSharpPlus project without tests, caching starts to pay off: |
|
The timings are really great, the escape hatch via the cooldown is a nice amortization trick to find a balance between benefiting the cache vs. not being significantly slower than before. 👍 |
Does it finish building the .Tests project successfully, or does it fail somewhere along the way? |
|
I had to remove the cooldown (but the times measured are without it), it was very bad on other scenarios (OpenTK), but the optimizations copilot did are still very worthwhile. I did some measurements, and it turns out at best around 50% of emitted type structures are weakly cached. In case of FSharpPlus it amounts to many millions of calls, so optimizing this can really pay off.
It fails, but it fails consistently, same errors on main as this PR. |

Description
The expensive part is generation of structural keys out of TTypes. This was optimized before by memoizing the structures of solved rigid TTypes. We can't do that if the TType is unsolved or there is a chance it will mutate. Unfortunately to find out if a type is rigid we need to traverse it's structure anyway.
TypeTokenmore GC friendly.Improves #19116
Checklist