You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "A B (Updated) (JIRA)" <ji...@apache.org> on 2011/10/17 19:48:10 UTC
[jira] [Updated] (AVRO-934) Avro PHP has a performance issue - it
appears to operate in O(N^2) time when decoding messages
[ https://issues.apache.org/jira/browse/AVRO-934?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
A B updated AVRO-934:
---------------------
Release Note: Fix for performance issue in Avro PHP.
Status: Patch Available (was: Open)
--- avro/io.php.orig 2011-10-17 12:39:47.437561900 -0500
+++ avro/io.php 2011-10-17 12:41:47.414485600 -0500
@@ -201,7 +201,9 @@
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];
if (count($read) < $len)
$this->current_index = $this->length();
else
> Avro PHP has a performance issue - it appears to operate in O(N^2) time when decoding messages
> ----------------------------------------------------------------------------------------------
>
> Key: AVRO-934
> URL: https://issues.apache.org/jira/browse/AVRO-934
> Project: Avro
> Issue Type: Improvement
> Components: php
> Affects Versions: 1.5.4
> Environment: PHP 5.3.8, Windows or OSX
> Reporter: A B
> Labels: avro, php
> Fix For: 1.5.4
>
>
> 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];
> ...
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira