Re: Java deserialization - any best practices for performances?

2009-07-24 Thread Kenton Varda
On Thu, Jul 23, 2009 at 7:15 PM, alopecoid alopec...@gmail.com wrote: Hmm... that strikes me as strange. I understand that the Message objects are immutable, but the Builders are as well? I thought that they would work more along the lines of String and StringBuilder, where String is

Re: Java deserialization - any best practices for performances?

2009-07-24 Thread Christopher Smith
The best way to think of it is: Builder : Java Message :: C++ Message : const C++ Message As far as performance goes, it is a common mistake to confuse C/C++ heap memory allocation costs to Java heap allocation. In the common case, allocations in Java are just a few instructions... comperable

Re: Java deserialization - any best practices for performances?

2009-07-23 Thread alopecoid
Hi, I haven't actually used the Java protobuf API, but it seems to me from the quick occasional glance that this isn't entirely true. I mean, specifically in response to the code snippet posted in the original message, I would possibly: 1. Reuse the Builder object by calling its clear() method.

Re: Java deserialization - any best practices for performances?

2009-07-23 Thread Kenton Varda
On Thu, Jul 23, 2009 at 12:32 AM, alopecoid alopec...@gmail.com wrote: Hi, I haven't actually used the Java protobuf API, but it seems to me from the quick occasional glance that this isn't entirely true. I mean, specifically in response to the code snippet posted in the original message,

Re: Java deserialization - any best practices for performances?

2009-07-23 Thread alopecoid
Hi Kenton, Thanks for your reply. You can't continue to use a Builder after calling build(). Even if we made it so you could, it would be building an entirely new object, not reusing the old one. We can't make it reuse the old one because that would break the immutability guarantee of

Re: Java deserialization - any best practices for performances?

2009-07-18 Thread Kenton Varda
On Fri, Jul 17, 2009 at 8:13 PM, Alex Black a...@alexblack.ca wrote: When I write out messages using C++ I'm careful to clear messages and re-use them, is there something equivalent on the java side when reading those same messages in? No. Sorry. This just doesn't fit at all with the Java

Java deserialization - any best practices for performances?

2009-07-17 Thread Alex Black
When I write out messages using C++ I'm careful to clear messages and re-use them, is there something equivalent on the java side when reading those same messages in? My code looks like: CodedInputStream stream = CodedInputStream.newInstance(inputStream); while ( !stream.isAtEnd() ) {