Uploaded image for project: 'Apache Avro'
  1. Apache Avro
  2. AVRO-2281

Performance improvement in ruby binary decoder and encoder

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 1.9.0
    • 1.9.0
    • ruby
    • None

    Description

      The ruby binary decoder has some inefficient memory usage patterns. The decoding process relies on `unpack` quite heavily, but it allocates an array that is not used as we just access the first element of the result. In ruby 2.4 we can use the optimized version of this, `unpack1` which avoids allocating the unused array. In `byte!`, we can go one step further and just use the `readbyte` method provided by the IO module - this improves the performance of `byte!` by about 50%. Additionally, there are a few strings in the encoder and decoder that should be frozen to reduce unnecessary string allocations.

       

      With these changes, I've seen about a 20% performance improvement when decoding.

      Attachments

        Issue Links

          Activity

            People

              dkulp Daniel Kulp
              kphelps Kyle Phelps
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: