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

Java: Improve BinaryEncoder Performance

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Blocker
    • Resolution: Fixed
    • None
    • 1.5.0
    • java
    • None
    • Incompatible change
    • Hide
      The Encoder API has several resulting changes:
          * Construction and configuration is handled by EncoderFactory. All
            Constructors are hidden, and Encoder.init(OutputStream) is removed.
          * Some Encoders previously did not buffer output. Users must call
            Encoder.flush() to ensure output is written unless the EncoderFactory
            method used to construct an instance explicitly states that the Encoder
            does not buffer output.
      Show
      The Encoder API has several resulting changes:     * Construction and configuration is handled by EncoderFactory. All       Constructors are hidden, and Encoder.init(OutputStream) is removed.     * Some Encoders previously did not buffer output. Users must call       Encoder.flush() to ensure output is written unless the EncoderFactory       method used to construct an instance explicitly states that the Encoder       does not buffer output.

    Description

      BinaryEncoder has not had a performance improvement pass like BinaryDecoder did. It still mostly writes directly to the underlying OutputStream which is not optimal for performance. I like to use a rule that if you are writing to an OutputStream or reading from an InputStream in chunks smaller than 128 bytes, you have a performance problem.

      Measurements indicate that optimizing BinaryEncoder yields a 2.5x to 6x performance improvement. The process is significantly simpler than BinaryDecoder because 'pushing' is easier than 'pulling' – and also because we do not need a 'direct' variant because BinaryEncoder already buffers sometimes.

      Attachments

        1. AVRO-753.v1.patch
          14 kB
          Scott Carey
        2. AVRO-753.v2.patch
          125 kB
          Scott Carey
        3. AVRO-753.v3.patch
          129 kB
          Scott Carey
        4. AVRO-753.v4.patch
          132 kB
          Scott Carey

        Issue Links

          Activity

            People

              scott_carey Scott Carey
              scott_carey Scott Carey
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: