-
Notifications
You must be signed in to change notification settings - Fork 507
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
[net6] xamarin_get_frame_length
performance regression
#14812
Comments
The issue's description is now up to date. |
xamarin_get_frame_length
performance regression
It might be the project options (or a different default value in dotnet vs legacy) but |
That's correct, we've changed the default so that exception marshalling is now on by default. Adding this to the csproj should get the old behavior back: <MtouchExtraArgs>--marshal-objectivec-exceptions:disable</MtouchExtraArgs> |
Thanks @rolfbjarne, @spouliot! Would you have some documentation about this change (or the feature itself) aside from #4940 and why you chose to use this mode? It's drastically changing the performance characteristics, but I wonder about the use cases, particularly if it can be enabled per method. Thanks! |
@jeromelaban exception marshaling is documented here: https://docs.microsoft.com/en-us/xamarin/ios/platform/exception-marshaling Making it enabled by default is something we plan on putting in the release notes (it's listed here: #10574) That said, it should be easy enough to fix that enhancement, since we'd only have to add a way to override the default logic. |
Thanks for the details! We'll likely use the original behavior for now even if the exception marshalling is incorrect. It's been working this way for many years and we've coped with it all this time, so we can continue doing so for a while :) |
…s or not. Fixes xamarin#4940. * This is a potential mitigation for slower transition to native code when exception marshalling is enabled (xamarin#14812). * A minor modification was required in the linker, to make sure any modified assemblies are saved. Fixes xamarin#4940.
I've fixed #14961, so it will be possible at some point to improve speed at the cost of app size (not for the first stable release, but for the next Xcode release we'll support, that be either Xcode 13.4 or Xcode 14.0). We might still want to look into if there are other performance improvements that can be done, so I'm keeping this open for now, but postponing until .NET 7. |
…s or not. Fixes xamarin#4940. (xamarin#14961) * This is a potential mitigation for slower transition to native code when exception marshalling is enabled (xamarin#14812). * A minor modification was required in the linker, to make sure any modified assemblies are saved. Fixes xamarin#4940.
I just did a very simple perf test on Mac Catalyst / ARM64: var watch = Stopwatch.StartNew ();
for (var i = 0; i < counter; i++) {
var x = view.Superview;
}
watch.Stop (); The results are for 20.000.000 iterations:
So I think the P/Invoke wrappers is the way to go here, without having to disable exception marshalling (it's even faster!): <PropertyGroup>
<MtouchExtraArgs>--require-pinvoke-wrappers:true</MtouchExtraArgs>
</PropertyGroup> |
Description
When invoking a
UIView
property (and likely anything else), there's a new native method being invokedxamarin_get_frame_length
which incurs a very high cost when invoking methods.This causes a very large performance regression (25:1 in some of our test cases) when comparing with legacy Xamarin.
The instruments traces below are from a physical device running arm64.
Steps to Reproduce
Create an application which invokes
UIView.get_SuperView
, invoke it in a loop.Expected Behavior
Here's the Legacy Xamarin result:
![image](https://user-images.githubusercontent.com/5839577/164790954-2be37cb6-994a-4744-be20-79967c5b2c5d.png)
Actual Behavior
Here's the .NET 6.0 RC1 result:
![image](https://user-images.githubusercontent.com/5839577/164791033-b8a19964-f2e5-4404-b20c-c311df157b9f.png)
Environment
.NET 6 RC1 (https://aka.ms/dotnet/maui/rc.1.json)
Build Logs
Available on demand.
Example Project (If Possible)
None, see repro steps above.
The text was updated successfully, but these errors were encountered: