-
Notifications
You must be signed in to change notification settings - Fork 795
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
Experiment: replace cancellable
with async
#18239
base: main
Are you sure you want to change the base?
Conversation
❗ Release notes requiredCaution No release notes found for the changed paths (see table below). Please make sure to add an entry with an informative description of the change as well as link to this pull request, issue and language suggestion if applicable. Release notes for this repository are based on Keep A Changelog format. The following format is recommended for this repository:
If you believe that release notes are not necessary for this PR, please add NO_RELEASE_NOTES label to the pull request. You can open this PR in browser to add release notes: open in github.dev
|
In a couple of places, because of cancellable, we had to use stackguard. Since async handles tail recursion rather well, we might want to rethink it. |
Also, we need to review places we used cancellable (and now async), if there are any routines which are fully sync, and now will have quite a bit of overhead of creating async. |
So this surprisingly passed :) and it seems the test run wasn't noticeably slower. Allocations is probably another story.
Yes, those I just removed for now.
Looks like the performance critical place where |
FCSSourceFiles benchmark this PR:
vs main:
|
Just removing stack guards might be dangerous, as it can result in SOs on desktop still. |
I mean all the recursive calls are now async |
It should, yes. We just want to be sure that every path will result in proper recursion |
ic.MatchBraces(fileName, SourceText.ofString source, parsingOptions, userOpName) | ||
|> Cancellable.UsingToken |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks too easy to miss in future updates/additions to the service layer.
Is there something we can do to prevent such mistakes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enforce it with types, which means use a specialized CE internally again :)
ValueOrCancelled.Cancelled x | ||
| ValueOrCancelled.Value(firstDef, env, envAtEnd) -> | ||
TcModuleOrNamespaceElementsNonMutRec cenv parent typeNames endm ((firstDef :: defsSoFar), env, envAtEnd) otherDefs ct | ||
return! TcModuleOrNamespaceElementsNonMutRec cenv parent typeNames endm ((firstDef :: defsSoFar), env, envAtEnd) otherDefs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does look a lot better now!
c030a95
to
1227542
Compare
As usual I'm dogfooding this by running a vsix and it seems fine. But I'm kind of worried about performance. In the benchmark the speed is similar and about 3% more allocation but what about really large codebases of the kind that required the stack guard there? Will it slow down to a crawl? Eat up all of the RAM? |
There are tests which include very large files (I think part of Fsharp.Suite), and some auto-generated massive tests. |
Also should keep in mind that allocations grow when you just work with your codebase, as changes trigger typechecks. My usual "benchmark" is to change something in FCS while working on vsix, multiple times. |
After some testing, this feels definitely slower / laggier in VS especially with many documents open. |
I wonder if we could make
|
As first approximation we could just add overloads to |
#18238 (comment)