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

Performance idea: ILReader / type system #1203

Open
dgrunwald opened this issue Jul 14, 2018 · 0 comments
Open

Performance idea: ILReader / type system #1203

dgrunwald opened this issue Jul 14, 2018 · 0 comments

Comments

@dgrunwald
Copy link
Member

ILReader is still somewhat expensive when resolving method references.

  1. TypeProvider.GetTypeFromReference() still constructs a GetClassTypeReference and IModuleReference. These are unnecessary allocations and should be refactored away. Moreover, assemblies tend to have only few module references, so it's highly useful to cache the result of resolving them within the MetadataAssembly.

  2. We currently fully resolve the signature of a memberref into type objects; then use them only for comparing the type objects against the available methods. It's possible to directly compare the signature bytes instead (SignatureBlobComparer). This might speed things up (though it might also cause us to resolve types slightly more often).

Also, SignatureBlobComparer.TypeHandleEquals needs adjustment. The current implementation is both inefficient (allocates strings, splits of backticks for generics), and ignores the assembly identity.

  1. We might consider reintroducing caches for resolving typerefs and/or memberrefs (we had those in ILSpy 3.x). But let's first try to optimize the other ways; a fast robust IEntity<->memberref comparison will also help analyzer performance.
dgrunwald added a commit that referenced this issue Aug 6, 2020
…type system.

We now avoid the old `IModuleReference` interface which required allocating for every type being resolved.
Instead `MetadataModule.ResolveModule` now combines decoding+resolving assembly references into a single step.
This allows the type system to maintain a cache indexed by row number.

This also changes the behavior of resolving references within a compilation: We now prefer an exact match (name + version + publickeytoken) first; and fall back to a name-only match only if no exact match exists.
This somewhat improves the decompilation of assemblies created by using ilmerge to combine assemblies with different target frameworks.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant