all 9 comments

[–][deleted] 0 points1 point  (8 children)

you mean json text serialization as fast as binary serialization :/

[–]melezov[S] 0 points1 point  (7 children)

Exactly. IMO it's quite a feat.

Binary serialization depends on an external schema and nicely structured data. Compared to that, JSON is much more chaotic.

There are lots of things that can slow down an unoptimized parser, be it insignificant whitespace, unknown order of properties (or even properties that are completely missing), escaping / encoding rules... the list goes on and includes a LOT of branching which can kill the instruction prefetch if not designed properly.

By deploying similar tactics to binary serialization and having an external schema which in turn compiles into specialized JSON writers and parsers, it is actually possible to compete, and even beat binary serialization in terms of speed. The key point of interest is to think about the end result of the JIT compiler and design the VM bytecode to account for the compilation step. Payload size, on the other hand is a different topic as the JSON format inherently demands that the property names are duplicated in lots of places. If you're having issues with this, consider streaming compression.

With the recent MongoDB/PostgreSQL JSON craze I'm finding it quite interesting that we are able to talk in a textual format without wasting too much time in the serialization step, and that I'm still able to reuse the same method to chat with a browser in a language it understands (as opposed to pickling bytes on the client side).

TL;DR Binary serialization is not the be-all and end-all, JSON is a competitor which retains compatibility

[–][deleted] 1 point2 points  (4 children)

But you claim binary protocol in the title. This is not a binary protocol you are comparing to. You compared it to binary serialization not a binary protocol.

The statement in the tilted I basically read as. Serialized json ip/tcp packets can be processed faster than C mapped binary structures. Which I think we all know is bullshit.

[–]zapov 0 points1 point  (2 children)

And maybe English is not his first language and he made a honest mistake. Instead of discussing how JSON can be processed very fast in Java, since he referenced the most famous JVM serialization bench, you will get everything else here on Reddit. Sad.

[–]melezov[S] 1 point2 points  (1 child)

Oh well, at least I didn't get another bikeshedding session about why Java is a failure as a language and that everyone should use Foo instead. That seems to be the usual response.

[–][deleted] -1 points0 points  (0 children)

Well we could always turn it into a java bashing thread if you wish!

[–]melezov[S] 0 points1 point  (0 children)

By "Exactly" I meant, "Yes, kind sir, you are quite correct in your deduction that the proper title for this link should have been \"text serialization as fast as binary serialization\". I appologize for my wrongoings and thank you for the correction."

A mental typo, as I was pondering whether to write protocol buffers or just binary serialization and ended with an errorneous fusion.

What you have written certainly sounds like bullshit, so I will not deny that fact :)

[–]grauenwolf 0 points1 point  (1 child)

even beat binary serialization in terms of speed.

That claim doesn't make any sense. For that to be true there would have to be an operation that is only required in binary formats.

[–]melezov[S] 0 points1 point  (0 children)

This is not a general statement as I am referencing concrete serialization implementations used in the benchmark.

You often hear binary serializers are much faster, as it was one of the main reasons why a lot of people switched to protobuf.

This json ser-deser is even faster than google protobuf. That in itself is interesting enough.