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

Bad performance in some Android devices #281

Closed
Sloy opened this issue Oct 31, 2018 · 6 comments

Comments

Projects
None yet
4 participants
@Sloy
Copy link

commented Oct 31, 2018

Describe the bug
After some testing with a big application we've detected some performance issues.
I've written a test project to compare the performance of multiple DI frameworks. Here's an example with one of the top 3 devices owned by our users:

=========|=====================
Device:  | Huawei hwALE-H v6.0
---------|--------------------
Test:    | Koin + Kotlin
Min-Max: | 234,91-272,23 ms
Average: | 241,21 ms
---------|--------------------
Test:    | Koin + Java
Min-Max: | 374,05-382,03 ms
Average: | 376,66 ms
---------|--------------------
Test:    | Kodein + Kotlin
Min-Max: | 7,48-15,48 ms
Average: | 7,63 ms
---------|--------------------
Test:    | Kodein + Java
Min-Max: | 7,95-10,76 ms
Average: | 8,08 ms
=========|=====================

(I excluded Dagger because it's obviously more performant)

To Reproduce
Here's the test project with more results in the readme: https://github.com/Sloy/android-dependency-injection-performance

Expected behavior
We would expect a similar result to Kodein, below 10ms in a not-so-good device.

Koin project used and used version:
koin-android:1.0.1

@Sloy

This comment has been minimized.

Copy link
Author

commented Oct 31, 2018

The biggest performance issue we found is described by #246

We ran the tests with the code from PR #258 and got better results:

Device:  | Huawei hwALE-H v6.0
---------|--------------------
Test:    | Koin + Kotlin
Max:     | 59,33 ms
Min:     | 33,93 ms
Average: | 35,35 ms
---------|--------------------
Test:    | Koin + Java
Max:     | 186,08 ms
Min:     | 165,36 ms
Average: | 170,31 ms

It's a big improvement, but can probably get better. Haven't found any other good spot for optimization yet.

@kuFEAR

This comment has been minimized.

Copy link

commented Nov 4, 2018

You can also test with nullable logger, because by default in 1.0.1 it build visual graph and print them.
#256 but i don't think that it so significant here, but anyway.

@arnaudgiuliani

This comment has been minimized.

Copy link
Member

commented Nov 5, 2018

Logging as nullable is not relevant from my last test, because we have already pre-formated the messages.

Performance improvement for 1.0.x is constrained to the actual design. I'm investigating a rewritten Koin core features, that would allow far better performances in loading & getting dependencies.

Also over complex feature like visibility checking/modules are clearlt impacting performances, whereas the value of such features (inner modules & visibility rules) is not good enough.

@CristianGM

This comment has been minimized.

Copy link

commented Nov 6, 2018

@arnaudgiuliani while you think on how to rewrite it you could at least merge the PR with the small performance improvement.
Anyway this issue is making Koin not usable for big apps, I hope you'll fix it soon. You can ask for contributors if you know what should be fixed or how.

@arnaudgiuliani

This comment has been minimized.

Copy link
Member

commented Nov 7, 2018

After good investigating ... @kuFEAR is right. Logs are also killing it :/

Wait for the 1.1.0 release then 👍

@arnaudgiuliani

This comment has been minimized.

Copy link
Member

commented Dec 2, 2018

Check the following 2.0.0 release for next performances announces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.