Avro
  1. Avro
  2. AVRO-934

Avro PHP has a performance issue - it appears to operate in O(N^2) time when decoding messages

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.5.4
    • Fix Version/s: 1.6.0
    • Component/s: php
    • Labels:
    • Environment:

      PHP 5.3.8, Windows or OSX

    • Release Note:
      Fix for performance issue in Avro PHP.

      Description

      While decoding simple requests, observed that the time to decode was growing much faster than expected. A 25k file would take 3 seconds to decode while a 570k file was taking approximately 45 minutes. The Ruby implementation does not exhibit a similar issue; above 570k file takes about 3 seconds to decode. Profiled the code and found that the problem lies in AvroStringIO::read($len) - repeated calls to array_slice seem to cause the issue. Replaced the call to array_slice with the following and now the 570k file is processed in about 5 seconds. I will submit the patch shortly as well but here is the new code:

      class AvroStringIO extends AvroIO
      {
      ...
      public function read($len)
      {
      $this->check_closed();
      //$read = array_slice($this->buffer, $this->current_index, $len);
      $read=array();
      for($i=$this->current_index; $i<($this->current_index+$len); $i++)
      $read []=$this->buffer[$i];
      ...

        Activity

        Doug Cutting made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Doug Cutting made changes -
        Status Patch Available [ 10002 ] Resolved [ 5 ]
        Assignee A B [ abawany ]
        Fix Version/s 1.6.0 [ 12316198 ]
        Fix Version/s 1.5.4 [ 12317878 ]
        Resolution Fixed [ 1 ]
        A B made changes -
        Attachment 1.patch [ 12499418 ]
        A B made changes -
        Field Original Value New Value
        Status Open [ 1 ] Patch Available [ 10002 ]
        Release Note Fix for performance issue in Avro PHP.
        A B created issue -

          People

          • Assignee:
            A B
            Reporter:
            A B
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development