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

Measuring runtime performance #105

Closed
AttwellBrian opened this issue Oct 8, 2017 · 3 comments
Closed

Measuring runtime performance #105

AttwellBrian opened this issue Oct 8, 2017 · 3 comments

Comments

@AttwellBrian
Copy link

AttwellBrian commented Oct 8, 2017

If I add .to(new ObservableScoper<RequestLocation>(lifecycle)) to an observable it makes it noticeably slower. Not super slow: just 0.13ms on a pixel (I put this in a loop with 500 iterations and measured the increase in duration). But slower than using a simple composite disposable pattern.

Some thoughts from a chat with Zac below

The exec path under the hood when you do this (this point when you call to()):

  • create new Scoper
  • scoper implements subscribeproxy

(this point on happens when you call subscribe())

  • calling subscribe creates an autodisposing observable, which is just a normal observable that has a custom observer in subscribeActual
  • the custom observer implements AutoDisposingObserver, creates an extra subscription on the lifecycle
  • all pub sub from there

potential areas of wins:

  • don't use consumers for lifecycle subscription to avoid unnecessary rxjava LambdaObserver creation
  • Maybe LifecycleScopeProvider could be lazier, but I doubt it. It already defer()'s to subscribe()-time, but if you want boundary checks there then you have to do it synchronously
@ZacSweers
Copy link
Collaborator

Do you have more concrete numbers on those different parts? It is going to be slower than not using autodispose for obvious reasons, but it’s hard to see where any issue is without more details

@ZacSweers ZacSweers changed the title Autodispose is a bit slow Measuring runtime performance Oct 8, 2017
@AttwellBrian
Copy link
Author

When tried it in the Rider app, it appeared to take 0.5% of main thread time. I only measured two iterations of the following test: app start + trip start.

Wasn't big enough of an issue to dig into more. But did want to write this up in case there was any obvious wins you could think of.

@ZacSweers
Copy link
Collaborator

Going to close this as inactionable for now, happy to revisit if anyone sees anything concerning!

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

2 participants