Different performance results: Buffered Streams vs. Byte Streams

181 views
Skip to first unread message

Tai

unread,
Aug 27, 2009, 10:56:55 AM8/27/09
to Protocol Buffers
Hi,

I did some similar performance tests based on that:
http://thrift-protobuf-compare.googlecode.com/svn

My tests runs under Java and uses Protocol Buffers 2.2.0.

Basically I am comparing Java Serialization vs. Protocol buffers with
byte size, serialization and deserialization and my results are
similar to the performance results as stated here:
http://www.eishay.com/2009/03/more-on-benchmarking-java-serialization.html

For serialization I use ByteArrayOutputStream (data stream in
ObjectOutputStream) and for deserialization its counterpart:
ByteArrayInputStream (data stream in ObjectInputStream).

But doing the performance test under RMI the performance results are
totally different. Here Protocol Buffers is slower(!) than Java
Serialization.

The only difference I can see is that it uses for serialization a
BufferedOutputStream (in ConnectionOutputStream) and a DataInputStream
(in ConnectionInputStream).

Does anybody know why that is so?

Tai

Kenton Varda

unread,
Aug 27, 2009, 10:05:16 PM8/27/09
to Tai, Protocol Buffers
Did you try what I suggested before -- serializing to a byte array instead, and then writing that to the stream all at once?

It's possible that ObjectOutputStream itself is just really slow, but that when using native Java serialization it uses special, highly-optimized code paths.

Tai

unread,
Aug 27, 2009, 10:43:41 PM8/27/09
to Protocol Buffers
Yes. I first write the length of the byte array and then write the
byte array all at once.

I don't really understand why the results are completely different
when using RMI. So you assume Java is doing some optimization?

On Aug 28, 4:05 am, Kenton Varda <ken...@google.com> wrote:
> Did you try what I suggested before -- serializing to a byte array instead,
> and then writing that to the stream all at once?
> It's possible that ObjectOutputStream itself is just really slow, but that
> when using native Java serialization it uses special, highly-optimized code
> paths.
>
> On Thu, Aug 27, 2009 at 7:56 AM, Tai <maitai.tru...@gmail.com> wrote:
>
> > Hi,
>
> > I did some similar performance tests based on that:
> >http://thrift-protobuf-compare.googlecode.com/svn
>
> > My tests runs under Java and uses Protocol Buffers 2.2.0.
>
> > Basically I am comparing Java Serialization vs. Protocol buffers with
> > byte size, serialization and deserialization and my results are
> > similar to the performance results as stated here:
> >http://www.eishay.com/2009/03/more-on-benchmarking-java-serialization...

Kenton Varda

unread,
Aug 27, 2009, 10:54:10 PM8/27/09
to Tai, Protocol Buffers
I really don't know either.
Reply all
Reply to author
Forward
0 new messages