Uploaded image for project: 'ProtoStream'
  1. ProtoStream
  2. IPROTO-217

Reuse buffer when writing a nested message

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Won't Do
    • Major
    • None
    • 4.4.1.Final
    • None
    • False
    • False

    Description

      When writing a wrapped nested message, WrappedMessage.writeMessage() allocates a new ByteArrayOutputStreamEx to store the output of the nested message (starting with byte[32] and growing as needed), but also a OutputStreamEncoder with an internal byte[4096] fixed buffer.

      GeneratedMarshallerBase#writeNestedMessage() allocates a similar byte[4096] buffer every time it writes a non-wrapped nested message.

      It should be easy to reuse the fixed buffer from the parent OutputStreamEncoder in both situations and avoid an allocation.

      Avoiding the allocation of the ByteArrayOutputStreamEx is much harder, but it should be possible to modify ByteArrayOutputStreamEx so that it doesn't allocate anything until the first write operation, thus avoiding the byte[32] allocation in the (common, I assume) case where the output is larger than 32 bytes.

      Attachments

        Issue Links

          Activity

            People

              dberinde@redhat.com Dan Berindei (Inactive)
              dberinde@redhat.com Dan Berindei (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: