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

Linker performance issue with GetCustomDebugInformation #1409

Closed
jeromelaban opened this issue Aug 4, 2020 · 5 comments
Closed

Linker performance issue with GetCustomDebugInformation #1409

jeromelaban opened this issue Aug 4, 2020 · 5 comments
Labels

Comments

@jeromelaban
Copy link

When linking a set of assemblies which contain Microsoft.SourceLink.GitHub with EmbedUntrackedSources enabled, the processing time will increase significantly.

Lots of the processing time is spent in GetCustomDebugInformation : https://github.com/jbevain/cecil/blob/5e37f44535e0753ff3e4dbdef4ef148ca8bb09e0/Mono.Cecil/AssemblyReader.cs#L3241

Here's a stack trace leading to this:

 	mscorlib.dll!System.IO.Stream.InternalCopyTo(System.IO.Stream destination, int bufferSize)	Unknown
>	Mono.Cecil.dll!Mono.Cecil.MetadataReader.GetCustomDebugInformation(Mono.Cecil.Cil.ICustomDebugInformationProvider provider) Line 3242	C#
 	Mono.Cecil.dll!Mono.Cecil.MetadataReader.GetDocument(uint rid) Line 2881	C#
 	Mono.Cecil.dll!Mono.Cecil.MetadataReader.ReadSequencePoints(Mono.Cecil.MethodDefinition method) Line 2870	C#
 	Mono.Cecil.dll!Mono.Cecil.Cil.PortablePdbReader.Read(Mono.Cecil.MethodDefinition method) Line 118	C#
 	Mono.Cecil.dll!Mono.Cecil.Cil.CodeReader.ReadMethodBody() Line 109	C#
 	Mono.Cecil.dll!Mono.Cecil.Cil.CodeReader.ReadMethodBody(Mono.Cecil.MethodDefinition method) Line 61	C#
 	Mono.Cecil.dll!Mono.Cecil.MethodDefinition.get_Body.AnonymousMethod__41_0(Mono.Cecil.MethodDefinition method, Mono.Cecil.MetadataReader reader) Line 154	C#
 	Mono.Cecil.dll!Mono.Cecil.ModuleDefinition.Read<System.__Canon, System.__Canon>(ref System.__Canon variable, System.__Canon item, System.Func<System.__Canon, Mono.Cecil.MetadataReader, System.__Canon> read) Line 989	C#
 	Mono.Cecil.dll!Mono.Cecil.MethodDefinition.Body.get() Line 156	C#
 	monolinker.exe!Mono.Linker.Steps.RemoveUnreachableBlocksStep.RewriteBody(Mono.Cecil.MethodDefinition method) Line 129	C#
 	monolinker.exe!Mono.Linker.Steps.RemoveUnreachableBlocksStep.RewriteBodies(Mono.Collections.Generic.Collection<Mono.Cecil.TypeDefinition> types) Line 119	C#
 	monolinker.exe!Mono.Linker.Steps.RemoveUnreachableBlocksStep.Process() Line 45	C#
 	monolinker.exe!Mono.Linker.Steps.BaseStep.Process(Mono.Linker.LinkContext context) Line 60	C#
 	monolinker.exe!Mono.Linker.Pipeline.ProcessStep(Mono.Linker.LinkContext context, Mono.Linker.Steps.IStep step) Line 134	C#
 	monolinker.exe!Mono.Linker.Pipeline.Process(Mono.Linker.LinkContext context) Line 127	C#
 	monolinker.exe!Mono.Linker.Driver.Run(Mono.Linker.ILogger customLogger) Line 609	C#
 	monolinker.exe!Mono.Linker.Driver.Execute(string[] args, Mono.Linker.ILogger customLogger) Line 67	C#
 	monolinker.exe!Mono.Linker.Driver.Main(string[] args) Line 51	C#
@marek-safar
Copy link
Contributor

marek-safar commented Aug 5, 2020

Will keep this open as tracking issue for Cecil issue

@jeromelaban
Copy link
Author

jeromelaban commented Oct 3, 2020

This issue is getting problematic when using C# 9.0 source generators, as their symbols and source is getting embedded in the pdbs, making the linker step significantly longer.

(/cc @jaredpar who may be interested as this relates to source generation)

@jaredpar
Copy link
Member

jaredpar commented Oct 5, 2020

Source generators should observably be no different than just embedding sources during build as it's just embedding a subset of files.

@jeromelaban
Copy link
Author

The origin of the files will not impact, indeed. I'm mentioning this issue as there may be more scenarios coming in the future involving source generation than ones with source link.

@jeromelaban
Copy link
Author

Fixed in jbevain/cecil#684

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

No branches or pull requests

3 participants