-
Notifications
You must be signed in to change notification settings - Fork 830
Add GetCachedProjectOptions #12848
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 GetCachedProjectOptions #12848
Conversation
src/fsharp/service/service.fs
Outdated
if incrementalBuildersCache.ContainsSimilarKey (AnyCallerThread, options) then | ||
parseCacheLock.AcquireLock(fun ltok -> | ||
for sourceFile in options.SourceFiles do | ||
checkFileInProjectCache.RemoveAnySimilar(ltok, (sourceFile, 0L, options)) |
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.
Hm, it seems this will also erase cached results in "similar" projects, e.g. there could be cached results for a file in another target framework in the same project. This API shouldn't touch other "similar" projects and only remove cache for the "same" project options, though this shouldn't likely be a real problem in practice. @DedSec256 could you take a look, please?
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.
getOrCreateBuilder
function does similar things and uses RemoveAnySimilar
too https://github.com/dotnet/fsharp/blob/main/src/fsharp/service/service.fs#L419
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.
That's interesting. We could probably change it there too then, but it also shows it's probably not that bad to do it like that this time, since this approach is already used in other places and we haven't noticed it before.
Could you explain more why please? We actually want to move in the other direction where the existence of these caches is relied on less, rather than more, and any caching happens outside. For example the Visual F# tools FSharp.Editor keeps its own table of options for documents/projects. So why not have a table on the outside? Rather than relying on the keys of the incremental builders lookup?
OK, interesting - perhaps these should be separate fixes please? |
Thanks, it's our mid-term plan indeed, and I'm working on other things to make it feasible on our side. For the short-term, however, having such an API would the best way to fix several issues we're having by improving the invalidation for the scripts in projects. Getting cached entries from FCS is preferred, since we only want to invalidate what's actually in the builder cache and we should not request new script options for each script, since invalidations are expected to be fast and it may be very expensive to resolve referenced assemblies and packages. |
8b57dbc
to
d945d9c
Compare
Given that anything we add to FCS has to stay, I think I'd prefer you move to your mid-term plan rather than adding to the FCS API? Or if really necessary use private reflection or some other hack? So I'd be inclined to say we don't take this... thanks |
We need to be able to quickly get project/script options from the FCS cache.
This PR adds
GetCachedProjectOptions(projectOrScriptFileName, isScript)
method.