-
Notifications
You must be signed in to change notification settings - Fork 55
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
Investigate adding automatic bind in default dispatchers. #36
Comments
So continuing from conversation in #48 I think we can also consider Bytecode Manipulation like in Retrolambda or Realm. Pro
Cons
Usage in other project
The other thing that need to consider is, if we use this, we need define our own rule when the binding will happen (Currently it's always in onCreate). |
Interesting, idea. This makes me think of a 3rd idea. With v2 we may have an annotation like Pros
Cons
Open question
|
Ultimately, I am wondering what is the real cost to bind all the time ... Maybe we take example on RxJava - since they have a focus on performances - https://github.com/ReactiveX/RxJava/blob/1.x/src/perf/java/rx/SubscribingPerf.java http://openjdk.java.net/projects/code-tools/jmh/ . |
Makes sense
I don't know about microbenchmark, I just read this answer on stack overflow. Can you elaborate a bit ? |
To put it simple, microbenchmark is benchmarking a little piece of code (Performance depends on how those few lines are compiled). Because microbenchmark is like a magnifying glass, even if we can find a problem with it, it doesn't mean that problem is the main cause of performance problem of our app/library. On why I think microbenchmark can be used in our case because you asked about the performance of the binding, rather than the whole program. In this case, using profiler would be overkill in my opinion. For examples, I think the RxJava links that you shared before is a collection of microbenchmark. And by the way, I think this question and the most voted answer is really good reference for microbenchmark |
I had another look at it, and I am under the impression we are overthinking it. For context :
So far, we have bindings to both Does it mean that it only penalizes Now, I believe it is actually more harmful to have an inconsistent API (autobinding for Activity and Fragment class but not the other dispatchers) than the performance cost actually is. TBH, I think this issue was created in the early days and we never took the time to look back at it. Thoughts ? |
Agreed
Agreed, like I wrote above currently there are no official rule for when to do LightCycles.bind(). I have two idea : First
Pros
Cons
Second
Pros
Cons
In my opinion, we can also think LightCycleActivity and LightCycleFragment as different thing from the dispatchers and think it like this LightCycleActivity & LightCycleFragment
Dispatcher
With this argument, if we want to avoid breaking changes, we can stick with the first idea. What do you think about this? |
I think option 1 is better for the users for the lib and if we have perf issues we will address them later. I am confident. About your last point, I think we ca refer to #48, unless you think it does not capture your thoughts :
|
OK then! I'll create a pull request to make the Readme clearer and let's discuss about it there! |
No problem! Can you review this PR #82 ? |
OK! Will review it! |
Dispatchers rely on equals to deduce the list of attached light cycles. Lifted light cycles must implement it. Related to #36
Bind the fragment only on the first onAttach call. Related to #36
* Lifted LightCycles of the same class are equals. * Fix fragment dispatchers bound multiple times. Related to #36
This could be done like we do w/ base activities and fragments.
On the example we would go from binding:
to binding:
The text was updated successfully, but these errors were encountered: