[ 
https://issues.apache.org/jira/browse/AVRO-2281?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16711848#comment-16711848
 ] 

ASF GitHub Bot commented on AVRO-2281:
--------------------------------------

kphelps opened a new pull request #401: [AVRO-2281] Optimize ruby binary 
encoder/decoder
URL: https://github.com/apache/avro/pull/401
 
 
   This makes some performance improvements around unpacking strings and 
freezing some strings that cause a lot of unnecessary allocations in some 
cases. We can also take advantage of `unpack1` when running in a version of 
ruby that supports it.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> Performance improvement in ruby binary decoder and encoder
> ----------------------------------------------------------
>
>                 Key: AVRO-2281
>                 URL: https://issues.apache.org/jira/browse/AVRO-2281
>             Project: Apache Avro
>          Issue Type: Improvement
>          Components: ruby
>    Affects Versions: 1.9.0
>            Reporter: Kyle Phelps
>            Priority: Minor
>
> 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.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to