bluelinelabs / LoganSquare

Screaming fast JSON parsing and serialization library for Android.
Apache License 2.0
3.21k stars 306 forks source link

Not so Fast with the Nexus 6P #159

Open LuigiPapino opened 8 years ago

LuigiPapino commented 8 years ago

I did some tests and found that on recent phones, like the Nexus 6P, LoganSquare doesn't result so fast in comparison with GSON and specially Jackson. Anyone else with this problem, or a device related issue?

Nexus 6P API 23

screenshot_20160430-221545 screenshot_20160430-221604

Samsung S5 API 21

screenshot_2016-04-30-22-43-12 screenshot_2016-04-30-22-43-03

alfdev commented 8 years ago

I confirm what LuigiPapino says, the issue seems present since android Lollipop.

Zhuinden commented 8 years ago

I think the issue isn't that LoganSquare is slow, but that Android has maybe increased reflection performance. I can't know for sure, though!

trevjonez commented 8 years ago

Also keep in mind the implementation of String and the underlying char[] was optimized in api 23 which could further reduce differences.

chenfei0928 commented 8 years ago

Why JSON processing use Jsckson. Since it has been for the Android platform, JsonWriter has better performance?

Zhuinden commented 8 years ago

@chenfei0928 because it uses jackson core streaming api

Macarse commented 8 years ago

it would be also nice to test with Jackson-jr (https://github.com/FasterXML/jackson-jr)

cowtowncoder commented 8 years ago

I also suggest that it is not slowing down of this library as much as likely speed up of some aspects of Android's SDK. Reflection improvements, as mentioned, would be a huge deal -- Android reflection performance has been really, REALLY bad, and lead to unfortunately high startup times for Jackson (even where Jackson's newer versions try to reduce amount of work done upfront).

Macarse commented 8 years ago

AndroidEngTeam replied this about reflection in M and N:

We’ve optimized code paths and code generation related to reflection through M and N. There have been numerous improvements (all of which you can find in AOSP). For example, in N we’ve hand-optimized some of the annotation code.

https://www.reddit.com/r/androiddev/comments/4tm8i6/were_on_the_android_engineering_team_and_built/d5in5rb

cowtowncoder commented 8 years ago

Very cool. This should help a lot with libraries that rely on reflection. I wonder if there could also be similar improvements to annotation access, which is something that has been slow as well, and possibly due to similar reasons (access to annotation information uses reflection(-like) functionality heavily).

EricKuck commented 8 years ago

Compile-time annotations don't use any reflection and can't really be optimized. They just end up as code in the app.

cowtowncoder commented 8 years ago

@EricKuck I understand, but I was referring to runtime annotations (which LS probably doesn't use, but others like Jackson and GSON do).