You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Kevin Clark (JIRA)" <ji...@apache.org> on 2008/08/26 03:27:44 UTC

[jira] Issue Comment Edited: (THRIFT-112) Initialize method is unnecessarily slow for structs with many optional fields

    [ https://issues.apache.org/jira/browse/THRIFT-112?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12625578#action_12625578 ] 

kclark edited comment on THRIFT-112 at 8/25/08 6:26 PM:
-------------------------------------------------------------

For reference, here's the protocol benchmarks (test/rb/benchmarks) pre and post application. Looks like a big speedup. Good work.

{noformat}# Pre 112
 
ruby write large (1MB) structure once 3.050000 0.050000 3.100000 ( 3.161090)
ruby read large (1MB) structure once 24.460000 0.650000 25.110000 ( 26.228877)
c write large (1MB) structure once 0.180000 0.010000 0.190000 ( 0.203352)
c read large (1MB) structure once 9.200000 0.460000 9.660000 ( 9.905314)
ruby write 10_000 small structures 2.380000 0.030000 2.410000 ( 2.468453)
ruby read 10_000 small structures 9.490000 0.290000 9.780000 ( 10.323756)
c write 10_000 small structures 0.130000 0.020000 0.150000 ( 0.153872)
c read 10_000 small structures 6.360000 0.250000 6.610000 ( 6.774520)
 
 
# Post 112
ruby write large (1MB) structure once 2.990000 0.030000 3.020000 ( 3.073227)
ruby read large (1MB) structure once 5.530000 0.070000 5.600000 ( 5.729319)
c write large (1MB) structure once 0.230000 0.010000 0.240000 ( 0.235470)
c read large (1MB) structure once 0.220000 0.000000 0.220000 ( 0.235971)
ruby write 10_000 small structures 1.780000 0.030000 1.810000 ( 1.839737)
ruby read 10_000 small structures 2.710000 0.030000 2.740000 ( 2.822826)
c write 10_000 small structures 0.100000 0.020000 0.120000 ( 0.122327)
c read 10_000 small structures 0.250000 0.000000 0.250000 ( 0.259422)
{noformat}

      was (Author: kclark):
    For reference, here's the protocol benchmarks (test/rb/benchmarks) pre and post application:

# Pre 112
 
ruby write large (1MB) structure once 3.050000 0.050000 3.100000 ( 3.161090)
ruby read large (1MB) structure once 24.460000 0.650000 25.110000 ( 26.228877)
c write large (1MB) structure once 0.180000 0.010000 0.190000 ( 0.203352)
c read large (1MB) structure once 9.200000 0.460000 9.660000 ( 9.905314)
ruby write 10_000 small structures 2.380000 0.030000 2.410000 ( 2.468453)
ruby read 10_000 small structures 9.490000 0.290000 9.780000 ( 10.323756)
c write 10_000 small structures 0.130000 0.020000 0.150000 ( 0.153872)
c read 10_000 small structures 6.360000 0.250000 6.610000 ( 6.774520)
 
 
# Post 112
ruby write large (1MB) structure once 2.990000 0.030000 3.020000 ( 3.073227)
ruby read large (1MB) structure once 5.530000 0.070000 5.600000 ( 5.729319)
c write large (1MB) structure once 0.230000 0.010000 0.240000 ( 0.235470)
c read large (1MB) structure once 0.220000 0.000000 0.220000 ( 0.235971)
ruby write 10_000 small structures 1.780000 0.030000 1.810000 ( 1.839737)
ruby read 10_000 small structures 2.710000 0.030000 2.740000 ( 2.822826)
c write 10_000 small structures 0.100000 0.020000 0.120000 ( 0.122327)
c read 10_000 small structures 0.250000 0.000000 0.250000 ( 0.259422)
  
> 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
>            Assignee: 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.