-
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
Add a version of TryGetRecentCheckResultsForFile with project snapshot #16720
Add a version of TryGetRecentCheckResultsForFile with project snapshot #16720
Conversation
…t takes a snapshot instead of project options
|
…c return but let's see if this is acceptable
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.
I think for this method we should try to use the cache we already have with the results instead of creating a new one.
Maybe we can extend the version of the ParseAndCheckFileInProject
to include file hash and add a method to retrieve a value based on key
and version -> bool
predicate.
That way we would have the same behavior, if I understand it correctly, where we care about the file's contents + ProjectCore
matching, but other files' contents could be different.
…ForFile - extend version of ParseAndCheckFileInProject cache with the check sum of the source code - add test
Hey @0101 ,
I extended the version of the Did I understand you correctly that we should add a new method to the |
Hey @dawedawe
I have not necessarily thought it all through... But we shouldn't need LruCache.GetAll: 'TKey -> ('TVersion * 'TValue) list And make it return the strongly held value (if present) first, so that in case there are multiple items matching we'll pick that one (which would be most recent). Don't know if we can give any meaningful ordering besides that. If we really wanted we could maybe add a timestamp or a counter to Possibly we can then implement the existing |
Co-authored-by: Petr Pokorny <petr@innit.cz>
Looking at the original docstring: fsharp/src/Compiler/Service/service.fsi Lines 382 to 392 in 9d36d64
It says the sourceText is optional, and if not given we should return any result for that filename. Although fsharp/src/Compiler/Service/BackgroundCompiler.fs Lines 1148 to 1161 in 9d36d64
Not sure what we should do for the new API. Probably we don't have to worry about this behavior since no one can be relying on it now when it doesn't work... We could make it work with an extra parameter (optional version of the file), but also I'm not sure how useful are old diagnostics when the source has changed. |
I also think we don't have to worry but from a conversation last week, I know that editor developers were confused about the behaviour regarding returning always None when no sourceText was given. |
…tring" as the second part of lastFileKey.Version
- let tests run for background compiler, too
Co-authored-by: Petr Pokorny <petr@innit.cz>
tests/FSharp.Compiler.ComponentTests/FSharpChecker/TransparentCompiler.fs
Outdated
Show resolved
Hide resolved
tests/FSharp.Compiler.ComponentTests/FSharpChecker/TransparentCompiler.fs
Outdated
Show resolved
Hide resolved
…Compiler.fs Co-authored-by: Petr Pokorny <petr@innit.cz>
…Compiler.fs Co-authored-by: Petr Pokorny <petr@innit.cz>
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.
Looks good! Sorry it was so difficult 😅 I'd be happy for any suggestions on how to make working with the code easier. Probably some things should be renamed but I don't know to what... Maybe some more documentation?
Ah, don't take me as a benchmark, I was pretty dump this week. Thanks again for all the hand-holding here! I can't wait to have all this in the IDEs. |
/azp run |
Azure Pipelines successfully started running 2 pipeline(s). |
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.
Good stuff. Thanks for your enduring help with TC :)
Mmh, no idea why the one test failed in the last run. I can't reproduce that locally 🤷 |
This reverts commit c72df2b.
Yeah sorry we have a lot flaky tests recently. |
But that was a test added by this PR 😂. We might have to revisit it so we don't increase the flakiness. The tests in the CI sometimes behave quite unpredictably compared to local runs (when working with Tasks/async stuff), so these failures are not reproducible. I think it's when the CI machine is overloaded or something and tasks that are started don't actually start running for a long time. So some barriers are needed before we assert something. But also maybe this test has been fully replaced by the new workflow tests and can just be removed? |
Yep, let's remove it. |
dotnet#16720) * First stab at adding a version of TryGetRecentCheckResultsForFile that takes a snapshot instead of project options * use version type without defaultof<_> = null * take sourcetext out of project snapshot, kind of forces us to an async return but let's see if this is acceptable * format * - reuse ParseAndCheckFileInProject cache for TryGetRecentCheckResultsForFile - extend version of ParseAndCheckFileInProject cache with the check sum of the source code - add test * format * cleanup * use a new LruCache member GetAll to get rid of the dummy version * cleanup * Update src/Compiler/Service/TransparentCompiler.fs Co-authored-by: Petr Pokorny <petr@innit.cz> * unify key creation * just use ProjectSnapShot.FileKey * to have it on record, push a version with "f.Version |> Md5Hasher.toString" as the second part of lastFileKey.Version * use FileKeyWithExtraFileSnapshotVersion for the ParseAndCheckFileInProject cache * replace FileSnapShot after edit in Test * add CustomOperation tryGetRecentCheckResults for tests * - Make API non-async and don't return hash - let tests run for background compiler, too * better fix for commandLineOptions order * Update src/Compiler/Service/FSharpProjectSnapshot.fs Co-authored-by: Petr Pokorny <petr@innit.cz> * Update tests/FSharp.Compiler.ComponentTests/FSharpChecker/TransparentCompiler.fs Co-authored-by: Petr Pokorny <petr@innit.cz> * Update tests/FSharp.Compiler.ComponentTests/FSharpChecker/TransparentCompiler.fs Co-authored-by: Petr Pokorny <petr@innit.cz> * fix version predicate * let LruCache.GetAll(key: 'TKey) return a seq instead of a list * compare signatures in CustomOperation tryGetRecentCheckResults to tighten the tests --------- Co-authored-by: Petr Pokorny <petr@innit.cz>
Description
As the title says, this adds a version of TryGetRecentCheckResultsForFile that works with a project snapshot.
Checklist
Test cases added
Performance benchmarks added in case of performance changes
Release notes entry updated: