Uploaded image for project: 'Qpid Proton'
  1. Qpid Proton
  2. PROTON-1911

improve performance of String encoding




      Testing has highlighted that the encoding of Strings within messages isn't very efficient, due to the manner in which the output is written to the destination buffer. By expanding WritableBuffer to allow writing a String directly, and improving the String encoding implementation therein we can improve performance of String encoding. Leveraging PROTON-1913 we can also provide the previous impl as a default fallback to avoid breaking compatibility with existing WritableBuffer implementations that lack one.

      Original description:

      While digging into performance issues in the Eclipse Hono project I noticed a high consumption of CPU time when encoding AMQP messages using proton-j.

      I made a small reproducer and threw the same profiler at it, here are the results:

      As you can see in the attach screenshot (the first is the initial run with the current code) most of the time is consumed in EncoderImpl#writeRaw(String). This due to the fact that is call "put" for every byte it want to encode.

      The following screenshots are from a patched version which uses a small thread local buffer to locally encode the raw data and then flush it to the buffer in bigger chunks.

      Screenshot 3 and 4 show the improve performance, but also show that the memory consumption stays low.



        1. qpid_encode_1.png
          308 kB
          Jens Reimann
        2. qpid_encode_2.png
          322 kB
          Jens Reimann
        3. qpid_encode_3.png
          96 kB
          Jens Reimann
        4. qpid_encode_4.png
          195 kB
          Jens Reimann
        5. strings_encode_after.json
          2 kB
          Jens Reimann
        6. strings_encode_before.json
          2 kB
          Jens Reimann

          Issue Links



              • Assignee:
                ctron Jens Reimann
              • Votes:
                0 Vote for this issue
                5 Start watching this issue


                • Created: