Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit62098ef

Browse files
vasily-kirichenkoKevinRansom
authored andcommitted
Use stale type check results more aggressively in completion (#5131)
* use stale type check results matched only by file name and project in completion* decrease waiting for fresh check results time in completion from 2 s to 200 ms* decrease checkFileInProjectCacheSize to 10* fixed: type check runs twice in ParseDocument helper* revert fresh check results timeout to 2s for now* Add option in settings and respect the option
1 parent1f0afc8 commit62098ef

21 files changed

+148
-37
lines changed

‎src/fsharp/service/service.fs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ module EnvMisc =
5959
letmaxTypeCheckErrorsOutOfProjectContext= GetEnvInteger"FCS_MaxErrorsOutOfProjectContext"3
6060
letbraceMatchCacheSize= GetEnvInteger"FCS_BraceMatchCacheSize"5
6161
letparseFileCacheSize= GetEnvInteger"FCS_ParseFileCacheSize"2
62-
letcheckFileInProjectCacheSize= GetEnvInteger"FCS_CheckFileInProjectCacheSize"5
62+
letcheckFileInProjectCacheSize= GetEnvInteger"FCS_CheckFileInProjectCacheSize"10
6363

6464
letprojectCacheSizeDefault= GetEnvInteger"FCS_ProjectCacheSizeDefault"3
6565
letframeworkTcImportsCacheStrongSize= GetEnvInteger"FCS_frameworkTcImportsCacheStrongSizeDefault"8
@@ -2764,7 +2764,7 @@ type BackgroundCompiler(legacyReferenceResolver, projectCacheSize, keepAssemblyC
27642764
parseCacheLock.AcquireLock(fun ltok->
27652765
match checkFileInProjectCache.TryGet(ltok,(filename,sourceText,options))with
27662766
| Some(a,b,c,_)-> Some(a,b,c)
2767-
| None->None)
2767+
| None->parseCacheLock.AcquireLock(fun ltok-> checkFileInProjectCachePossiblyStale.TryGet(ltok,(filename,options))))
27682768
| None-> parseCacheLock.AcquireLock(fun ltok-> checkFileInProjectCachePossiblyStale.TryGet(ltok,(filename,options)))
27692769

27702770
/// Parse and typecheck the whole project (the implementation, called recursively as project graph is evaluated)

‎vsintegration/src/FSharp.Editor/LanguageService/FSharpCheckerExtensions.fs‎

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -24,37 +24,38 @@ type FSharpChecker with
2424
checker.ParseDocument(document, parsingOptions, sourceText=sourceText.ToString(), userOpName=userOpName)
2525

2626
memberchecker.ParseAndCheckDocument(filePath:string,textVersionHash:int,sourceText:string,options:FSharpProjectOptions,allowStaleResults:bool,userOpName:string)=
27-
letparseAndCheckFile=
28-
async{
29-
let!parseResults,checkFileAnswer= checker.ParseAndCheckFileInProject(filePath, textVersionHash, sourceText, options, userOpName=userOpName)
30-
return
31-
match checkFileAnswerwith
32-
| FSharpCheckFileAnswer.Aborted->
33-
None
34-
| FSharpCheckFileAnswer.Succeeded(checkFileResults)->
35-
Some(parseResults, checkFileResults)
36-
}
27+
async{
28+
letparseAndCheckFile=
29+
async{
30+
let!parseResults,checkFileAnswer= checker.ParseAndCheckFileInProject(filePath, textVersionHash, sourceText, options, userOpName=userOpName)
31+
return
32+
match checkFileAnswerwith
33+
| FSharpCheckFileAnswer.Aborted->
34+
None
35+
| FSharpCheckFileAnswer.Succeeded(checkFileResults)->
36+
Some(parseResults, checkFileResults)
37+
}
3738

38-
lettryGetFreshResultsWithTimeout():Async<CheckResults>=
39-
async{
40-
try
41-
let!worker= Async.StartChild(parseAndCheckFile,2000)
42-
let!result= worker
43-
return Ready result
44-
with:? TimeoutException->
45-
return StillRunning parseAndCheckFile
46-
}
39+
let!worker= Async.StartChild(parseAndCheckFile, millisecondsTimeout=Settings.LanguageServicePerformance.TimeUntilStaleCompletion)
40+
41+
lettryGetFreshResultsWithTimeout():Async<CheckResults>=
42+
async{
43+
try
44+
let!result= worker
45+
return Ready result
46+
with:? TimeoutException->
47+
return StillRunning worker
48+
}
4749

48-
letbindParsedInput(results:(FSharpParseFileResults* FSharpCheckFileResults)option)=
49-
match resultswith
50-
| Some(parseResults, checkResults)->
51-
match parseResults.ParseTreewith
52-
| Some parsedInput-> Some(parseResults, parsedInput, checkResults)
50+
letbindParsedInput(results:(FSharpParseFileResults* FSharpCheckFileResults)option)=
51+
match resultswith
52+
| Some(parseResults, checkResults)->
53+
match parseResults.ParseTreewith
54+
| Some parsedInput-> Some(parseResults, parsedInput, checkResults)
55+
| None-> None
5356
| None-> None
54-
| None-> None
5557

56-
if allowStaleResultsthen
57-
async{
58+
if allowStaleResultsthen
5859
let!freshResults= tryGetFreshResultsWithTimeout()
5960

6061
let!results=
@@ -69,8 +70,10 @@ type FSharpChecker with
6970
return! worker
7071
}
7172
return bindParsedInput results
72-
}
73-
else parseAndCheckFile|> Async.map bindParsedInput
73+
else
74+
let!res= worker
75+
return bindParsedInput res
76+
}
7477

7578

7679
memberchecker.ParseAndCheckDocument(document:Document,options:FSharpProjectOptions,allowStaleResults:bool,userOpName:string,?sourceText:SourceText)=

‎vsintegration/src/FSharp.Editor/Options/EditorOptions.fs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ type CodeFixesOptions =
4343
[<CLIMutable>]
4444
typeLanguageServicePerformanceOptions=
4545
{ EnableInMemoryCrossProjectReferences:bool
46+
TimeUntilStaleCompletion:int
4647
ProjectCheckCacheSize:int}
4748

4849
[<CLIMutable>]
@@ -73,6 +74,7 @@ type internal Settings [<ImportingConstructor>](store: SettingsStore) =
7374

7475
store.RegisterDefault
7576
{ EnableInMemoryCrossProjectReferences=true
77+
TimeUntilStaleCompletion=2000// In ms, so this is 2 seconds
7678
ProjectCheckCacheSize=200}
7779

7880
store.RegisterDefault

‎vsintegration/src/FSharp.UIResources/FSharp.UIResources.csproj‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@
4141
<CompileUpdate="**\*.xaml.cs"SubType="Designer"DependentUpon="%(Filename)" />
4242
<CompileUpdate="$(IntermediateOutputPath)**\*.g.cs"Visible="false" />
4343
</ItemGroup>
44+
<ItemGroup>
45+
<EmbeddedResourceUpdate="Strings.resx">
46+
<Generator></Generator>
47+
</EmbeddedResource>
48+
</ItemGroup>
4449

4550
<PropertyGroup>
4651
<VSMSBuildBinDir>$(VS150COMNTOOLS)\..\..\MSBuild\$(VisualStudioVersion)\Bin</VSMSBuildBinDir>

‎vsintegration/src/FSharp.UIResources/LanguageServicePerformanceOptionControl.xaml‎

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,38 @@
1717
<Grid>
1818
<ScrollViewerVerticalScrollBarVisibility="Auto">
1919
<StackPanel>
20-
<GroupBoxHeader="{x:Static local:Strings.Language_Service_Performance}">
20+
<GroupBoxHeader="{x:Static local:Strings.Enable_in_memory_cross_project_references}">
2121
<StackPanel>
22-
<CheckBoxx:Name="enableInMemoryCrossProjectReferences"IsChecked="{Binding EnableInMemoryCrossProjectReferences}"
23-
Content="{x:Static local:Strings.Enable_in_memory_cross_project_references}"/>
22+
<CheckBoxx:Name="enableInMemoryCrossProjectReferences"
23+
IsChecked="{Binding EnableInMemoryCrossProjectReferences}"
24+
Content="{x:Static local:Strings.Enable_in_memory_cross_project_references}"/>
2425
<Grid>
2526
<Grid.ColumnDefinitions>
26-
<ColumnDefinitionWidth="Auto"/>
27+
<ColumnDefinitionWidth="300"/>
28+
<ColumnDefinitionWidth="70" />
29+
</Grid.ColumnDefinitions>
30+
<Label Grid.Column="0"x:Name="timeUntilStaleIntelliSenseLabel"Content="{x:Static local:Strings.Time_until_stale_completion}"/>
31+
<TextBox Grid.Column="1"
32+
HorizontalContentAlignment="Right"
33+
VerticalContentAlignment="Center">
34+
<TextBox.Text>
35+
<BindingUpdateSourceTrigger="PropertyChanged"Path="TimeUntilStaleCompletion">
36+
<Binding.ValidationRules>
37+
<local:IntegerRangeValidationRuleMin="0"Max="10000"/><!-- If people truly want more than 10 seconds before stale results come in, they can open an issue on VisualFSharp.-->
38+
</Binding.ValidationRules>
39+
</Binding>
40+
</TextBox.Text>
41+
</TextBox>
42+
</Grid>
43+
<Grid>
44+
<Grid.ColumnDefinitions>
45+
<ColumnDefinitionWidth="300"/>
2746
<ColumnDefinitionWidth="70" />
2847
</Grid.ColumnDefinitions>
2948
<Label Grid.Column="0"x:Name="projectCheckCacheSizeLabel"Content="{x:Static local:Strings.Project_check_cache_size}"/>
3049
<TextBox Grid.Column="1"
31-
HorizontalContentAlignment="Right"
32-
VerticalContentAlignment="Center">
50+
HorizontalContentAlignment="Right"
51+
VerticalContentAlignment="Center">
3352
<TextBox.Text>
3453
<BindingUpdateSourceTrigger="PropertyChanged"Path="ProjectCheckCacheSize">
3554
<Binding.ValidationRules>

‎vsintegration/src/FSharp.UIResources/Strings.Designer.cs‎

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎vsintegration/src/FSharp.UIResources/Strings.resx‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,4 +180,7 @@
180180
<dataname="Show_Outlining"xml:space="preserve">
181181
<value>Show outlining and collapsable nodes for F# code</value>
182182
</data>
183+
<dataname="Time_until_stale_completion"xml:space="preserve">
184+
<value>Time until stale results for completion (in milliseconds)</value>
185+
</data>
183186
</root>

‎vsintegration/src/FSharp.UIResources/xlf/Strings.cs.xlf‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@
107107
<targetstate="translated">Zobrazí osnovu a sbalitelné uzly kódu F#.</target>
108108
<note />
109109
</trans-unit>
110+
<trans-unitid="Time_until_stale_completion">
111+
<source>Time until stale results for completion (in milliseconds)</source>
112+
<targetstate="new">Time until stale results for completion (in milliseconds)</target>
113+
<note />
114+
</trans-unit>
110115
</body>
111116
</file>
112117
</xliff>

‎vsintegration/src/FSharp.UIResources/xlf/Strings.de.xlf‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@
107107
<targetstate="translated">Gliederung und ausblendbare Knoten für F#-Code anzeigen</target>
108108
<note />
109109
</trans-unit>
110+
<trans-unitid="Time_until_stale_completion">
111+
<source>Time until stale results for completion (in milliseconds)</source>
112+
<targetstate="new">Time until stale results for completion (in milliseconds)</target>
113+
<note />
114+
</trans-unit>
110115
</body>
111116
</file>
112117
</xliff>

‎vsintegration/src/FSharp.UIResources/xlf/Strings.en.xlf‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@
107107
<targetstate="new">Show outlining and collapsable nodes for F# code</target>
108108
<note />
109109
</trans-unit>
110+
<trans-unitid="Time_until_stale_completion">
111+
<source>Time until stale results for completion (in milliseconds)</source>
112+
<targetstate="new">Time until stale results for completion (in milliseconds)</target>
113+
<note />
114+
</trans-unit>
110115
</body>
111116
</file>
112117
</xliff>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp