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

Afterburner (or Blackbird) with jackson-jr? #47

Open
Macarse opened this issue Jul 19, 2016 · 17 comments
Open

Afterburner (or Blackbird) with jackson-jr? #47

Macarse opened this issue Jul 19, 2016 · 17 comments

Comments

@Macarse
Copy link

Macarse commented Jul 19, 2016

As far as I understand afterburner can't be used with jackson-jr.

Is there any plan to "port" afterburner?

@cowtowncoder
Copy link
Member

@Macarse I have toyed with the idea as I don't think that is a bad idea at all. I think that should be an optional add-on, similar to how it works with regular Jackson; partly because there is still some additional risk of failures (since it's more elaborate setup with bytecode generation etc), and partly because it just won't work on Android.

I have not worked on anything like this, but I think idea itself is valid and I would love to help if anyone wants to prototype the idea.

@Macarse
Copy link
Author

Macarse commented Jul 19, 2016

@cowtowncoder afterburner + databind doesn't work on Android?

@cowtowncoder
Copy link
Member

Correct: Android bytecode is not Java bytecode but its own thing, and may or may not be dynamically loadable. If it is, then different support library (Afterburner uses asm) could be used to generate Dalvik bytecode for android java vm.

Some of techniques that Afterburner uses would actually work (specifically, use of JsonParser.nextFieldName()), but majority of speedup is from bytecode generation to avoid reflection calls.

@Macarse
Copy link
Author

Macarse commented Jul 19, 2016

@cowtowncoder I am interested in Android.
I was checking another library called LoganSquare: https://github.com/bluelinelabs/LoganSquare
There is an issue open mentioning that LoganSquare is not AS fast as it was before:
bluelinelabs/LoganSquare#159

Inside their repo they have a comparison of a couple of libraries but jackson-jr is not there. So I wanted to give it a try. I have tried replacing Jackson with Jackson-Jr in my personal branch:
https://github.com/Macarse/LoganSquare/tree/macarse/jacksonJr but it just doesn't work :(

Is there a way to see logs?

@cowtowncoder
Copy link
Member

cowtowncoder commented Jul 19, 2016

@Macarse logs of... ? Neither Jackson nor jackson-jr logs anything

FWIW LoganSquare does use streaming parer/generator from jackson-core, so the suggestion by someone that it is much more likely that new version helps with regular Jackson databind to get closer, than that LS is slowed down. Android reflection performance, specifically, was abysmally bad before, so if that is sped up, difference would be big.

Still would be interesting to see jackson-jr; on JavaSE jr has performance similar to regular jackson.
And with version 2.8 can use fields, not just getter/setter methods.

@Macarse
Copy link
Author

Macarse commented Jul 19, 2016

@cowtowncoder oh interesting. How do you usually figure out what's wrong?

The code is serializing with:

String ret = JSON.std.asString(response);

Logs show that the String output is:{} and I can't find what's wrong :(

@cowtowncoder
Copy link
Member

@Macarse what is the class like? It would first sound like there were no public getters available on that object -- jackson-jr versions before 2.8.0 required getters. It is also not an error if no properties are found (unlike default settings with Jackson).

@Macarse
Copy link
Author

Macarse commented Jul 19, 2016

@cowtowncoder wait, what?

I am using jackson-jr in my work project and I am using it without getters and setters. Just public fields.

@Macarse
Copy link
Author

Macarse commented Jul 19, 2016

@cowtowncoder ok, I am clueless. Adding getters and setters fixed the LoganSquare Demo. I will update my code.

How come my model works without getters and setters?

@Macarse
Copy link
Author

Macarse commented Jul 20, 2016

btw, this is the result of running my branch in a nexus 6p with developer preview 4.

screenshot_20160719-165146

screenshot_20160719-165212

@cowtowncoder
Copy link
Member

Cool. So, on fields -- version 2.8.0 DOES support use of simple public fields. Older versions (up 2.7) do NOT. So it depends on version. Support for fields was added since Android developers mentioned that there are reasons for wanting to avoid use of fields.

Interesting numbers; clearly Moshi has been geared at Android use as its numbers are better than GSON here, which is different from J2SE where GSON seems to be faster.

@Macarse
Copy link
Author

Macarse commented Jul 20, 2016

I found my issue, after cleaning the build my code stop working. Apparently I started using 2.8 and changed it to 2.7.x but the dependency was not updated.

@cowtowncoder do you maintain a changelog? I can't find any doc which says 2.8 supports fields and 2.7 does not. I would also like to know if 2.8.1 is prod ready.

@cowtowncoder
Copy link
Member

Yes, changelog is under release-notes/VERSION, and entry for field addition is #26.
In addition, Jackson release notes:

https://github.com/FasterXML/jackson/wiki/Jackson-Release-2.8

list this change (although list of all changes is sometimes incomplete; modules keep actual changes in release-notes/VERSION and those should be complete change lists).

2.8.1 is now released.

@Macarse
Copy link
Author

Macarse commented Jul 21, 2016

@cowtowncoder thanks. since I am only going to use USE_FIELDS, should I turn off other features? for example USE_IS_GETTERS.

@cowtowncoder
Copy link
Member

@Macarse yes, you may want to do that; if it's left on, getter/setter is used instead of field if one exists, otherwise field is used. So if you never plan on using getters, turn them off; ditto for setters.

@re-thc
Copy link

re-thc commented May 30, 2018

What would be required to add Afterburner style support? Can this still be evaluated?

@cowtowncoder
Copy link
Member

@hc-codersatlas If anyone wants to implement it, I'd be happy to help. I do not have any extra time to work on this personally. But then again, mr-bean came as external contribution, and then served as basis of Afterburner.

But basically jackson-jr does not have any extension points to support this yet. Adding extension points might not be superbly difficult, and it might even make sense to add support for ability to map abstract types to concrete more generally (since the two parts are related in Jackson).

@cowtowncoder cowtowncoder changed the title Afterburner with jackson-jr? Afterburner (or Blackbird) with jackson-jr? Jan 10, 2022
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