Skip to content
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

Update Roslyn to 4.4.0 1.22369.1 #2420

Merged
merged 14 commits into from
Jul 25, 2022
Merged

Conversation

JoeRobich
Copy link
Member

@JoeRobich JoeRobich commented Jul 19, 2022

The changes are mostly around how Global Options in Roslyn is changing. We need to provide fallbacks which derive from OmniSharpOptions for LineFormatting options that are normally found in the .editorconfig.

@JoeRobich JoeRobich changed the title Update roslyn 4.4.0 1.22369.1 Update Roslyn to 4.4.0 1.22369.1 Jul 19, 2022
Copy link
Contributor

@333fred 333fred left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small suggestion, otherwise LGTM

@filipw
Copy link
Member

filipw commented Jul 20, 2022

Not sure what is going on here, or whether there is some regression in Roslyn, but we have a bunch of System.OutOfMemoryException

@JoeRobich
Copy link
Member Author

Thanks for helping fix up the scripting test @filipw! Going to keep working on it.

@333fred
Copy link
Contributor

333fred commented Jul 21, 2022

@JoeRobich selectively running tests, it appears that import completion is taking significant amounts of memory. By far the worst offender is ImportCompletionResolvesOnSubsequentQueries, though all show more memory usage than I would expect. It's particularly bad when they're the first tests that run, and looking at heap dumps there are huge numbers of PENamedTypeSymbols in memory. Additionally, when I insert Task.Delays between each theory leg, it becomes very obvious that something is holding onto memory, between theory runs, as memory increases by about the same amount each leg without going back down.

@333fred
Copy link
Contributor

333fred commented Jul 21, 2022

Looking at VMMAP of the process after it's run all 4 of the ImportCompletionResolvesOnSubsequentQueries tests, I see the following:
image
Most of the memory being used in these tests is not in the native heap. I'm not sure what to make of this, as I have no idea what could be causing such massive native allocations in our framework.

@@ -55,7 +55,7 @@ internal static partial class CompletionListBuilder
completionTasksAndProviderNamesBuilder.Add(((Task<CompletionChange>?)completionService.GetChangeAsync(document, completion), providerName));
}
}
var completionTasksAndProviderNames = completionTasksAndProviderNamesBuilder.MoveToImmutable();
var completionTasksAndProviderNames = completionTasksAndProviderNamesBuilder.ToImmutable();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@filipw why did you revert this? Just to see if it would fix the OOM issue?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it failed many tests with System.InvalidOperationException : MoveToImmutable can only be performed when Count equals Capacity.

@filipw
Copy link
Member

filipw commented Jul 21, 2022

Additionally, when I insert Task.Delays between each theory leg, it becomes very obvious that something is holding onto memory, between theory runs, as memory increases by about the same amount each leg without going back down.

One thing is we inject SharedOmniSharpHostFixture which is a shared test host - it does not get recreated between the tests, only is attempted to be cleared and reused. Could be that.

@333fred
Copy link
Contributor

333fred commented Jul 21, 2022

One thing is we inject SharedOmniSharpHostFixture which is a shared test host - it does not get recreated between the tests, only is attempted to be cleared and reused. Could be that.

The import completion tests are not using the shared fixture (my latest commit adds a new fixture to share hosts between them).

@JoeRobich
Copy link
Member Author

JoeRobich commented Jul 22, 2022

So, I made the assumption that the stack trace that is failing is also the stack that is allocating. I choose to look at the TestHelper GetReferences and by caching the MetaData References memory stay much, much lower.

                             [xUnit.net 00:03:06.06]       System.OutOfMemoryException : Insufficient memory to continue the execution of the program.
2022-07-21T06:44:52.1290096Z [xUnit.net 00:03:06.07]       Stack Trace:
2022-07-21T06:44:52.1291826Z [xUnit.net 00:03:06.07]            at System.Runtime.InteropServices.Marshal.AllocHGlobal(IntPtr cb)
2022-07-21T06:44:52.1292828Z [xUnit.net 00:03:06.07]            at System.Reflection.Internal.StreamMemoryBlockProvider.ReadMemoryBlockNoLock(Stream stream, Int64 start, Int32 size)
2022-07-21T06:44:52.1293843Z [xUnit.net 00:03:06.07]            at System.Reflection.PortableExecutable.PEReader..ctor(Stream peStream, PEStreamOptions options, Int32 size)
2022-07-21T06:44:52.1294777Z [xUnit.net 00:03:06.07]            at Microsoft.CodeAnalysis.ModuleMetadata.CreateFromStream(Stream peStream, PEStreamOptions options)
2022-07-21T06:44:52.1313146Z [xUnit.net 00:03:06.07]         D:\a\omnisharp-roslyn\omnisharp-roslyn\tests\TestUtility\TestHelpers.cs(121,0): at TestUtility.TestHelpers.<>c.<GetReferences>b__3_2(String l) <-- This might be problematic
2022-07-21T06:44:52.1313810Z [xUnit.net 00:03:06.07]            at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext()
2022-07-21T06:44:52.1314299Z [xUnit.net 00:03:06.07]            at System.Linq.Enumerable.UnionIterator`1.MoveNext()
2022-07-21T06:44:52.1314808Z [xUnit.net 00:03:06.07]            at System.Collections.Generic.LargeArrayBuilder`1.AddRange(IEnumerable`1 items)
2022-07-21T06:44:52.1319398Z [xUnit.net 00:03:06.07]            at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable`1 source)
2022-07-21T06:44:52.1320135Z [xUnit.net 00:03:06.07]            at System.Collections.Immutable.ImmutableArray.CreateRange[T](IEnumerable`1 items)
2022-07-21T06:44:52.1320745Z [xUnit.net 00:03:06.07]            at Roslyn.Utilities.EnumerableExtensions.ToBoxedImmutableArray[T](IEnumerable`1 items)
2022-07-21T06:44:52.1322078Z [xUnit.net 00:03:06.07]            at Microsoft.CodeAnalysis.ProjectInfo.Create(ProjectId id, VersionStamp version, String name, String assemblyName, String language, String filePath, String outputFilePath, CompilationOptions compilationOptions, ParseOptions parseOptions, IEnumerable`1 documents, IEnumerable`1 projectReferences, IEnumerable`1 metadataReferences, IEnumerable`1 analyzerReferences, IEnumerable`1 additionalDocuments, Boolean isSubmission, Type hostObjectType, String outputRefFilePath)

@JoeRobich
Copy link
Member Author

Now to work out why the global line formatting options aren't applying to Cake services..

2022-07-22T01:09:43.1369369Z [xUnit.net 00:00:23.05]     OmniSharp.Cake.Tests.CodeActionsV2Facts.Can_extract_method [FAIL]
2022-07-22T01:09:43.1802021Z [xUnit.net 00:00:23.05]       Assert.Equal() Failure
2022-07-22T01:09:43.1805254Z [xUnit.net 00:00:23.05]       Expected: LinePositionSpanTextChange { StartLine=4, StartColumn=8, EndLine=4, EndColumn=8, NewText=NewMethod();\n    }\n\n    private static void NewMethod()\n    {\n         }
2022-07-22T01:09:43.2251706Z [xUnit.net 00:00:23.05]       Actual:   LinePositionSpanTextChange { StartLine=4, StartColumn=8, EndLine=6, EndColumn=0, NewText=NewMethod();\n    }\r\n\r\n    private static void NewMethod()\r\n    {\r\n        Console.Write("should be using System;");\r\n    }\r\n }

@JoeRobich JoeRobich merged commit 5c6c460 into master Jul 25, 2022
@JoeRobich JoeRobich deleted the update-roslyn-4.4.0-1.22369.1 branch July 25, 2022 21:07
@filipw
Copy link
Member

filipw commented Jul 26, 2022

😅👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants