Skip to content
This repository was archived by the owner on Sep 25, 2026. It is now read-only.
This repository was archived by the owner on Sep 25, 2026. It is now read-only.

Linker performance issue with GetCustomDebugInformation #1409

Closed

Description

@jeromelaban

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#

Activity

  1. marek-safar commented on Aug 5, 2020

    @marek-safar
    Contributor

    Will keep this open as tracking issue for Cecil issue

  2. jeromelaban commented on Oct 3, 2020

    @jeromelaban
    Author

    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)

  3. jaredpar commented on Oct 5, 2020

    @jaredpar
    Member

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

  4. jeromelaban commented on Oct 5, 2020

    @jeromelaban
    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.

  5. jeromelaban commented on Sep 7, 2022

    @jeromelaban
    Author
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions