-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Description
Description
Reviewing a customer issue, we noticed usage of RegexOptions.Compiled impacts startup quite a bit:
This was coming from the AppCenter SDK in the customer's app:
This shows up as a regression from Xamarin.Android -> .NET 6, because RegexOptions.Compiled was not implemented at all in mono/mono.
The question here, is how do we get the previous behavior from mono/mono? Is there a way to toggle RuntimeFeature.IsDynamicCodeCompiled?
runtime/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Regex.cs
Line 105 in 807d091
| if (RuntimeFeature.IsDynamicCodeCompiled && (options & RegexOptions.Compiled) != 0) |
If there is a way to toggle RuntimeFeature.IsDynamicCodeCompiled, should we consider turning on this flag by default on Android? I've found System.Reflection.Emit to be very impactful to startup.
Reproduction Steps
dotnet new android- Open
MainActivity.csand put_ = new Regex(@"([^;=]+)=([^;]+)(?:;\s*)?", RegexOptions.Compiled);in theOnCreate()method. - Build/run with
dotnet build -c Release -t:Run
Expected behavior
RegexOptions.Compiled doesn't have a significant impact to Android startup. (Or we have a feature flag to turn it off)
Actual behavior
RegexOptions.Compiled has a significant impact to Android startup.
Regression?
From a customer's perspective they might say this is startup performance regression from Xamarin.Android to .NET 6.
Known Workarounds
Don't use RegexOptions.Compiled, use Normal.
Configuration
I tested this with the .NET 6.0.400-preview.22301.10 SDK, and the SR 1 version of .NET MAUI.
Other information
dotnet trace output: regexoptions.compiled.zip
Metadata
Metadata
Assignees
Type
Projects
Status
