Status: New
Labels: Type-Defect Priority-Medium

New issue 464 by Inefficient Java handling of repeated list of primitive types

What steps will reproduce the problem?
1. Any handling of Protobuf message with a large set of repeated primitive fields ([packed=true] or not).
For instance:

messages Foo {
  repeated float data = 10; // optionally [packed=true]

2. Create handler that deals with large numbers of Foos with large data.
3. Use a profiler to monitor the large number of autoboxed types that slam the GC.

What is the expected output? What do you see instead?
The output is as expected, except the Java garbage collector is slammed because of having to manage a large number autoboxed primitive wrappers because of the use of a java.util.List Collection as the code-generated field type.

What version of the product are you using? On what operating system?
2.4.0a, 2.4.1, but confirmed that inefficiencty still exists in 2.5.0. Linux/RedHat, Java 1.6.X.

Please provide any additional information below.
I have attached a (bzipped) patch file that has a solution that uses a backend primitive_type[] that grows linearly as needed (much like a deque). It avoids having to generate autoboxed wrappers for repeated primitive types thus alleviating tons of work by the GC. Also, exposed a new interface that breaks immutability at the expense of performance by allowing the array[] type to be returned so that a client can make use of functions such as System.copy. If preserving immutability is absolutely mandatory then it may be necessary to provide a copy function (which takes an array_type[] reference as its argument) or incur an additional array clone/copy before returning the data (probably not the preferred approach).

Enquired about this on the Google Groups protobuf forum months ago but only got a single response that someone would be interested in the fix. Link to that conversation is here:

Attachments:  2.8 KB

You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:

You received this message because you are subscribed to the Google Groups "Protocol 
Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
To post to this group, send email to
Visit this group at
For more options, visit

Reply via email to