-
Notifications
You must be signed in to change notification settings - Fork 566
Startup performance improvements (less reflection) #4302
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| ### App startup performance | ||
|
|
||
| * [GitHub PR 4302](https://github.com/xamarin/xamarin-android/pull/4302): | ||
| Avoid unneeded calls to `GetCustomAttribute()` during app startup for the | ||
| common case where an app has no types decorated with the | ||
| `[JniAddNativeMethodRegistration]` attribute. Additionally, instead of | ||
| using a managed method to propagate uncaught exceptions from Java, use a | ||
| Java method that calls into the unmanaged Xamarin.Android runtime. These | ||
| changes reduced the time to display the first screen of a small test | ||
| Xamarin.Forms app from about 730 milliseconds to about 700 milliseconds for | ||
| a Release configuration build on a Google Pixel 3 XL device. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 0 additions & 69 deletions
69
src/Mono.Android/Android.Runtime/UncaughtExceptionHandler.cs
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it would make more sense to just leave this entirely in Java & C...?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should absolutely move all this stuff into
XamarinUncaughtExceptionHandler.Here's my conceptual problem:
Thread.getDefaultUncaughtExceptionHandler()forms a "linked list", and it is the responsibility of allThread.UncaughtExceptionHandlerimplementations to propagate the exception to their "parent" handler withinThread.UncaughtExceptionHandler.uncaughtException().The problem here is twofold:
UncaughtExceptionHandlerinstantiation is "responsible" for callingThread.DefaultUncaughtExceptionHandlerand obtaining the "parent" handler, andUncaughtExceptionHandleris only instantiated when there's an unhandled exception, so it's not "clean" as of process startup, andXamarinUncaughtExceptionHandler,UncaughtExceptionHandler,JNIEnv.PropagateUncaughtException(),UncaughtExceptionHandler.UncaughtException()).It does not give me a good feeling.
Instead, let's "move" the "default uncaught exception handler linked list management" of
UncaughtExceptionHandlerintoXamarinUncaughtExceptionHandler, and then moveUncaughtExceptionHandler.UncaughtException()intoJNIEnv.PropagateUncaughtException().This should kill two places to try to keep track of things, simplifying logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, changes applied. Working on this I wanted to make the minimum amount of changes to minimize potential of breaking something that's been in place for years, but I agree with your assessment 100%