RameshRaj / thrift-protobuf-compare

Automatically exported from code.google.com/p/thrift-protobuf-compare
0 stars 0 forks source link

javaExt benchmark way too slow #16

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi, 

I just stumbled upon this project. I was wondering why the manual
externalization ("java (externalizable)") is so inferior in the benchmark.
I did some own benchmarks with protobuf and Java externalization before I
decided to implement my own framework, and the numbers were pretty different.

So I dived into the code just to find out that it is far from efficient.
Please find a patch which remedies the deficiencies. javaExt needs only
8.0s total on my machine while it needed 30.0s before. In comparison:
protobuf needs 9.3s.

While JavaExt is now one of the fastest externalization methods in the
benchmark, it is far from the best. No forward and backward compatibility,
no cross language support, error-prone to implement, ...

The patch might need some polish, since I don't always check for null, and
the source-formatting might need a cleanup. But you get the idea.

Bye,
   Michael

Original issue reported on code.google.com by michael....@gmail.com on 6 Jan 2010 at 7:13

Attachments:

GoogleCodeExporter commented 8 years ago
Interesting, what did the trick?
Was it the ExternalizationHelper.writeString instead of out.writeObject ?
Where can I find the source for ExternalizationHelper ?

Thanks a lot for the patch.
Eishay

Original comment by eis...@gmail.com on 6 Jan 2010 at 7:21

GoogleCodeExporter commented 8 years ago
Oops, apparently I failed to create a proper patch file. Please find
ExternalizationHelper attached.

There are two "tricks":
- use writeUTF(.) instead of writeObject(.)
- use Externalizable.writeExternal(out) instead of out.writeObject(ex)

Both are essential, as ObjectOutputStream does some expensive, unneccessary 
stuff. At
least unneccessary in most cases.

Original comment by michael....@gmail.com on 6 Jan 2010 at 7:29

Attachments:

GoogleCodeExporter commented 8 years ago
Patch applied.

Original comment by michael....@gmail.com on 6 Jan 2010 at 8:50