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

Prototype jsoniter decoding #37

Open
valdo404 opened this issue Apr 25, 2019 · 12 comments
Open

Prototype jsoniter decoding #37

valdo404 opened this issue Apr 25, 2019 · 12 comments

Comments

@valdo404
Copy link
Contributor

valdo404 commented Apr 25, 2019

Instead of relying on circe try jsoniter for fun and profit
https://plokhotnyuk.github.io/jsoniter-scala/

@plokhotnyuk
Copy link

plokhotnyuk commented Jul 19, 2019

Here is derivation of codec that parses and serializes a bid request from OpenRTB 2.5.

Here is an example, provided by @atais, for a custom codec which extracts the message part that can be optionally encoded as a JSON string.

Please also check results of OpenRTBReading and OpenRTBWriting benchmarks here

@valdo404
Copy link
Contributor Author

Hey @plokhotnyuk it is interesting. As you may know we are also managing protobuf and openrtb extensions, so we may need to adapt your examples a little bit.
Do you want to provide a pr ?

@plokhotnyuk
Copy link

@valdo404 Please try and leave your feedback here. I can help with review, profiling and tuning.

@atais
Copy link

atais commented Jul 20, 2019

@valdo404 we have implemented full open rtb support, meaning encoding and decoding, with jsoniter.

From my experience/point of view you can't just generate the whole model based on case classes, but it depends on the approach :)

Anyway, jsoniter is a lot faster than circe.

I did not know of this project existence so let me check if we could benefit from each other's work :)

@valdo404
Copy link
Contributor Author

Thanks atais. the interesting thing here is that we provide compatibility with protobuf and ssps as well (like bidswitch).
For this we created an extension system, which also compatible with protobuf extensions.
For all those reasons (plus other ones) we cannot just generate derivations. serde needs to be tweaked.

@atais
Copy link

atais commented Jul 25, 2019

@valdo404 just fyi we did not realize there is a google protobuf project available 😞 and we simply recreated the whole OpenRTB model from the IAB specs.

So, god damn, our parsers are for sure not compatible with that model.

We are not using protobuf extensions either, so our way is completely different.

Still, I am curious how jsoniter performs against jackson - available here:
https://github.com/google/openrtb/tree/master/openrtb-core/src/main/java/com/google/openrtb/json

We will have a look into google model, which could give us more flexibility and reduce our codebase, but I need some time. Tbh it is not a top priority. I could help you with the parsers as well if you start writing them since we have spent some pleasant time with jsoniter ;)

@plokhotnyuk
Copy link

plokhotnyuk commented Jul 25, 2019

@atais I can bet 1 PLN that jsoniter-scala will outperform protobuf parsers for Java/Scala on bid request messages with the same payload. Here is a more than 1yo benchmark with results while for the different domain, but jsoniter-scala evolved a lot since...

@valdo404
Copy link
Contributor Author

Guys it is hard to beat scalapb project (especially because protobuf is very compact and requires less memory allocs)
But if by chance you can beat scalapb project let me know !

@valdo404
Copy link
Contributor Author

@atais scala openrtb is based on google openrtb project since it is relying on same .proto files.
We have 100% compatibility with them.

@atais
Copy link

atais commented Jul 29, 2019

@valdo404 just quick note on circe vs jsoniter decoding performance

We have both circe and jsoniter serde and this is the benchmark:

::Benchmark decoding.circe::
cores: 4
name: Java HotSpot(TM) 64-Bit Server VM
osArch: amd64
osName: Linux
vendor: Oracle Corporation
version: 25.201-b09
Parameters(times -> 10): 5.111939
Parameters(times -> 40): 19.39121
Parameters(times -> 70): 33.482897
Parameters(times -> 100): 47.864702

::Benchmark decoding.jsoniter::
cores: 4
name: Java HotSpot(TM) 64-Bit Server VM
osArch: amd64
osName: Linux
vendor: Oracle Corporation
version: 25.201-b09
Parameters(times -> 10): 1.688709
Parameters(times -> 40): 6.283416
Parameters(times -> 70): 10.923638
Parameters(times -> 100): 15.671711

so its ~3x difference, which for us was a huge benefit.

@plokhotnyuk
Copy link

plokhotnyuk commented Jul 31, 2019

My figures show 3.5x - 4x speed up over circe for a 1.5K sample of the most common input depending on version of JDK/GraalVM:

image

@plokhotnyuk
Copy link

Currently GraalVM is preferable for parsing of OpenRTB with jsoniter-scala or borer:
image

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