Skip to content
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

[RFC] Android RPC service performance issues #1433

Closed
alex-weaver opened this issue Jul 14, 2018 · 4 comments
Closed

[RFC] Android RPC service performance issues #1433

alex-weaver opened this issue Jul 14, 2018 · 4 comments

Comments

@alex-weaver
Copy link
Contributor

Using a service process for RPC in Android is causing significant performance regressions (approximately by a factor of 3 on my test device).

@merrymercy identified the watchdog process commit as the cause in #1426
The service/watchdog process was added in #1387

I've confirmed that on my device performance returns to its previous level if I roll back MainActivity.java to before the service/watchdog was introduced.

It is unclear precisely why this is occurring, but I've done some debugging on this and found the following:

  • The issue persists if the RPCProcessor is launched in a service but the watchdog is removed. This demonstrates the performance issue is not due to the interaction with the watchdog, but simply due to running in the service process.
  • Adding a timer in C++ around GraphRuntime::Run confirms that almost all of the processing time is taken by this function, and not by java code.
  • I have tried setting the service as a foreground service (how to do this correctly is somewhat poorly documented), since by default service processes in Android are given lower priority than app processes[1]. This did not make any difference :(

Any ideas as to why this might be occurring would be appreciated

[1] https://medium.com/google-developers/who-lives-and-who-dies-process-priorities-on-android-cb151f39044f

@tqchen
@eqy

@eqy
Copy link
Contributor

eqy commented Jul 14, 2018 via email

@alex-weaver
Copy link
Contributor Author

alex-weaver commented Jul 14, 2018

That sounds great :)

Bringing the RPCProcessor back into the activity will definitely resolve the issue, I've just been digging into this because it's somehow unsatisfying without knowing why it was broken in the first place!

EDIT: PS if you find yourself needing foreground services, this may be helpful (especially around the changes in Android O):
https://proandroiddev.com/deep-dive-into-android-services-4830b8c9a09

@tqchen
Copy link
Member

tqchen commented Jul 19, 2018

#1457

@tqchen
Copy link
Member

tqchen commented Jul 20, 2018

close this for now as @merrymercy confirmed that the performance regression is fixed by #1457 @alex-weaver it would be great if you can also verify independently

@tqchen tqchen closed this as completed Jul 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants