Replace Mono.Cecil
usage with modified S.R.MetadataLoadContext
#1254
Labels
proposal
Issue raised for discussion, we do not even know if the change would be desirable yet
Replacing our usage of Cecil with System.Reflection.MetadataLoadContext is an interesting idea that should in theory result in faster build times for tasks that need to scan assemblies.
For example, looking for all top-level classes that inherit
Java.Lang.Object
inMono.Android.dll
:However, while MLC performs great resolving assemblies and iterating types, its performance tanks once you start digging deeper, like calling
GetNestedTypes ()
orGetMethods ()
on it. If we extend the previous test case to also check nested types, MLC is already unusable:Interestingly, this performance hit seems to be related to trying to shoehorn the results into a
System.Reflection
compatible API. If we bypass that and instead add a way to call the otherwiseinternal
EcmaDefinitionType.GetNestedTypesCore (NameFilter?)
method directly, performance is back to excellent:If we create an MLC version of
JavaCallableWrappers
'sCecilImporter
class, we can see it performs worse, as it scans nested types, methods, constructors, etc.Once again, as we create "backdoors" to
internal
enumeration methods for these objects, we start to see performance wins over Cecil:MLC performance has been reported at dotnet/runtime#30886, but it does not seem like MLC is very actively under development anymore.
We could probably get some decent build performance wins if we created a fork of MLC that used the default assembly/module/type logic but had custom nested type/methods/constructors logic.
The text was updated successfully, but these errors were encountered: