Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Performance] Allow manual initialization of expensive operations to potentially decrease startup time #5248

Closed
wants to merge 2 commits into from

Conversation

kingces95
Copy link
Contributor

@kingces95 kingces95 commented Feb 14, 2019

To generate this profile you need to build a private nuget package with this branch and then build https://github.com/kingces95/droidperf.
profile

Goal is to reduce startup time by making renderer registration explicit and allowing for feature opt out and to build in a profiler to allow adding regression tests.
NO BREAKING CHANGES -- All features are opt in: A new Init call + profiler logic lives behind a define.

To generate the nuget:

set NUGET_DIR=x:\nuget\4.4.1
.create-nuget.bat rdroid
X:\git\forms.nuspec\Xamarin.Forms.9.9.46.nupkg

To build the droidperf:

  • Install VS Ent -- only that supports AOT
  • Config = Release
  • Build/Deploy XFFastUp.Android

Profiler API:
The profiler API is built in but hidden behind a PROFILE define. The define is set in this branch to ease development. Will remove before accepting PR. To inject sampling points simply put:

Profile.Push("Timing Partition A")
... // logic to time
Profile.PopPush("Next Partition")
... // more logic to time
Profile.Pop()
To report on the samples use the droidperf app linked above.

Explicit Registration:
This is an example of using explicit renderer registration and optional opt-out of features.

var activation = new ActivationOptions()
{
	Activity = this,
	Bundle = savedInstanceState,
	ResourceAssembly = Assembly.GetExecutingAssembly(),
	Handlers = Exports.Handlers,
	Flags = ActivationFlags.NoCss
};
Forms.Init(activation);
//Forms.Init(this, savedInstanceState, Assembly.GetExecutingAssembly());

@kingces95 kingces95 added the DO-NOT-MERGE-!!! 🛑 This is in progress and needs to be updated before it can be merged. label Feb 14, 2019
@mattleibow
Copy link
Contributor

Nice!

@samhouts samhouts requested review from PureWeen and hartez March 4, 2019 22:21
@samhouts samhouts assigned hartez and PureWeen and unassigned hartez and PureWeen Mar 4, 2019
@samhouts samhouts removed the DO-NOT-MERGE-!!! 🛑 This is in progress and needs to be updated before it can be merged. label Mar 4, 2019
@KSemenenko
Copy link
Contributor

any updates?

@samhouts samhouts added the DO-NOT-MERGE-!!! 🛑 This is in progress and needs to be updated before it can be merged. label Mar 22, 2019
Copy link
Contributor

@hartez hartez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just a couple of questions and a typo.

@kingces95
Copy link
Contributor Author

Got the go ahead to check this in behind a PROFILE define. So I'll address the concerns, double check ensure everything is behind the PROFILE define, then get a final review, and merge it in... that's my plan.

@kingces95
Copy link
Contributor Author

kingces95 commented Apr 2, 2019

Eh, changed my plan. I'm not gonna hide behind a PROFILE.

Instead, I'll add Start. Without calling Start all the public entry points are noops and are small enough so they should be in-lined so that their cost will minimal and allow us to simply ship the profiler disabled in the product.

@kingces95
Copy link
Contributor Author

Build

rmarinho added a commit that referenced this pull request Apr 4, 2019
* man init

* man init w/o profile

* Update Xamarin.Forms.Platform.Android/Forms.cs

Co-Authored-By: rmarinho <me@ruimarinho.net>
kingces95 added a commit that referenced this pull request Apr 4, 2019
@kingces95 kingces95 reopened this Apr 4, 2019
@kingces95 kingces95 removed the DO-NOT-MERGE-!!! 🛑 This is in progress and needs to be updated before it can be merged. label Apr 4, 2019
@samhouts samhouts requested a review from hartez April 5, 2019 23:19
Copy link
Member

@samhouts samhouts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm re-running the Fast Renderers tests. The other failing tests are not related to this PR.

@kingces95 kingces95 force-pushed the droid-perf branch 2 times, most recently from 184078f to bee5958 Compare April 13, 2019 01:54
@samhouts samhouts removed the request for review from PureWeen April 16, 2019 17:37
codemillmatt pushed a commit to codemillmatt/Xamarin.Forms that referenced this pull request Apr 19, 2019
* man init

* man init w/o profile

* Update Xamarin.Forms.Platform.Android/Forms.cs

Co-Authored-By: rmarinho <me@ruimarinho.net>
codemillmatt pushed a commit to codemillmatt/Xamarin.Forms that referenced this pull request Apr 19, 2019
@samhouts samhouts changed the title Profiler; Explicit Init [Performance] Allow manual initialization of expensive operations to potentially increase startup time Apr 23, 2019
Copy link
Contributor

@hartez hartez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question about commented code.

@@ -127,7 +128,11 @@ protected void LoadApplication(Application application)

application.PropertyChanged += AppOnPropertyChanged;

//Profile.FramePartition(nameof(SetMainPage));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are all these Profile calls commented out?

@kingces95 kingces95 changed the title [Performance] Allow manual initialization of expensive operations to potentially increase startup time [Performance] Allow manual initialization of expensive operations to potentially decrease startup time May 9, 2019
@kingces95 kingces95 closed this May 9, 2019
@kingces95 kingces95 deleted the droid-perf branch May 9, 2019 21:10
AxelUser pushed a commit to AxelUser/Xamarin.Forms that referenced this pull request Jun 15, 2019
* man init

* man init w/o profile

* Update Xamarin.Forms.Platform.Android/Forms.cs

Co-Authored-By: rmarinho <me@ruimarinho.net>
AxelUser pushed a commit to AxelUser/Xamarin.Forms that referenced this pull request Jun 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants