[ 
https://issues.apache.org/jira/browse/THRIFT-112?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Bryan Duxbury updated THRIFT-112:
---------------------------------

    Attachment: thrift-112.patch

Here's a patch of the implementation for the ruby libraries only (lib/rb).

> Initialize method is unnecessarily slow for structs with many optional fields
> -----------------------------------------------------------------------------
>
>                 Key: THRIFT-112
>                 URL: https://issues.apache.org/jira/browse/THRIFT-112
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Library (Ruby)
>            Reporter: Bryan Duxbury
>            Priority: Minor
>         Attachments: thrift-112.patch
>
>
> We have Thrift structs that are composed of mostly optional fields, and only 
> one is occupied. (The struct is used like a C union.) In Ruby, this leads to 
> an inordinate amount of time being spent creating instances. We've tracked 
> this down to the initialize method, which iterates over all fields, setting 
> defaults or taking constructor args as needed. A fairly effective fix for us 
> was to only iterate the union of fields that have default values or are being 
> set via the constructor. In the worst case, either when all fields have 
> default values or when the user is setting all fields' values via the 
> constructor, it is no more costly than the existing implementation.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to