Skip to content

Improve performance of CBOR serialization and deserialization, and fix negative timestamps - #10681

Draft
ashovlin wants to merge 2 commits into
v2from
shovlia/cbor-perf
Draft

ashovlin wants to merge 2 commits into
v2from
shovlia/cbor-perf

Conversation

@ashovlin

Copy link
Copy Markdown
Member

Issue #, if available: N/A

Description of changes:

  1. Implements some performance optimizations for the CBOR serializer and deserializer. Most of this was hoisting constants that were defined in each method up to the class level. It also reworks _serialize_data_item with if/elif instead of building the method name dynamically and simplified some hot paths.
  2. While here, found a bug in serializing pre-epoch timestamps.

I still need to run the internal benchmarks on the standard instances, but results locally:

================================================================================
  rpcv2Cbor_GetItemOutputBinary_L
================================================================================
  metric           before        after         diff   % change
  ----------------------------------------------------------
  mean             305627       255278       -50349     -16.5%
  p50              299666       253667       -45999     -15.4%
  p90              322416       259792       -62624     -19.4%
  p95              331208       264833       -66375     -20.0%
  p99              350250       279125       -71125     -20.3%
  std_dev           12964         6285        -6679     -51.5%

================================================================================
  rpcv2Cbor_GetItemOutputBinary_M
================================================================================
  metric           before        after         diff   % change
  ----------------------------------------------------------
  mean              49255        41777        -7478     -15.2%
  p50               47958        41250        -6708     -14.0%
  p90               53125        42166       -10959     -20.6%
  p95               56875        45583       -11292     -19.9%
  p99               62542        51333       -11209     -17.9%
  std_dev            5600         2384        -3216     -57.4%

================================================================================
  rpcv2Cbor_GetItemOutputBinary_S
================================================================================
  metric           before        after         diff   % change
  ----------------------------------------------------------
  mean              15613        13953        -1660     -10.6%
  p50               15292        13666        -1626     -10.6%
  p90               15875        14250        -1625     -10.2%
  p95               16833        15333        -1500      -8.9%
  p99               19917        18208        -1709      -8.6%
  std_dev            3057         1871        -1186     -38.8%

================================================================================
  rpcv2Cbor_GetItemOutput_Baseline
================================================================================
  metric           before        after         diff   % change
  ----------------------------------------------------------
  mean               2618         2660          +42      +1.6%
  p50                2459         2583         +124      +5.0%
  p90                2667         2667            0      +0.0%
  p95                3167         2750         -417     -13.2%
  p99                3625         3458         -167      -4.6%
  std_dev            1515         1278         -237     -15.6%

================================================================================
  rpcv2Cbor_GetItemOutput_L
================================================================================
  metric           before        after         diff   % change
  ----------------------------------------------------------
  mean             310398       266950       -43448     -14.0%
  p50              306292       255458       -50834     -16.6%
  p90              324583       264334       -60249     -18.6%
  p95              337042       273291       -63751     -18.9%
  p99              353542       674042      +320500     +90.7%
  std_dev           11485        81964       +70479    +613.7%

================================================================================
  rpcv2Cbor_GetItemOutput_M
================================================================================
  metric           before        after         diff   % change
  ----------------------------------------------------------
  mean              49209        42415        -6794     -13.8%
  p50               48541        41667        -6874     -14.2%
  p90               50625        43834        -6791     -13.4%
  p95               54083        47041        -7042     -13.0%
  p99               58792        52959        -5833      -9.9%
  std_dev            2891         4506        +1615     +55.9%

================================================================================
  rpcv2Cbor_GetItemOutput_S
================================================================================
  metric           before        after         diff   % change
  ----------------------------------------------------------
  mean              16124        16186          +62      +0.4%
  p50               15792        14792        -1000      -6.3%
  p90               16500        20042        +3542     +21.5%
  p95               18250        20709        +2459     +13.5%
  p99               20709        22833        +2124     +10.3%
  std_dev            1559         4182        +2623    +168.2%

================================================================================
  rpcv2Cbor_PutItemRequest_Baseline
================================================================================
  metric           before        after         diff   % change
  ----------------------------------------------------------
  mean               6137         3537        -2600     -42.4%
  p50                4083         3250         -833     -20.4%
  p90                5375         3583        -1792     -33.3%
  p95               12167         4208        -7959     -65.4%
  p99               51792         4500       -47292     -91.3%
  std_dev           14235         4241        -9994     -70.2%

================================================================================
  rpcv2Cbor_PutItemRequest_BinaryData_L
================================================================================
  metric           before        after         diff   % change
  ----------------------------------------------------------
  mean              58037        50209        -7828     -13.5%
  p50               55834        48875        -6959     -12.5%
  p90               63583        53959        -9624     -15.1%
  p95               67125        56583       -10542     -15.7%
  p99               90542        62000       -28542     -31.5%
  std_dev            9128         4413        -4715     -51.7%

================================================================================
  rpcv2Cbor_PutItemRequest_BinaryData_M
================================================================================
  metric           before        after         diff   % change
  ----------------------------------------------------------
  mean              20601        16817        -3784     -18.4%
  p50               19750        16375        -3375     -17.1%
  p90               23833        17292        -6541     -27.4%
  p95               25000        19209        -5791     -23.2%
  p99               26209        21583        -4626     -17.7%
  std_dev            3888         3132         -756     -19.4%

================================================================================
  rpcv2Cbor_PutItemRequest_BinaryData_S
================================================================================
  metric           before        after         diff   % change
  ----------------------------------------------------------
  mean               5306         4325         -981     -18.5%
  p50                5166         4250         -916     -17.7%
  p90                5875         4334        -1541     -26.2%
  p95                6625         4375        -2250     -34.0%
  p99                6875         5500        -1375     -20.0%
  std_dev            1130         1101          -29      -2.6%

================================================================================
  rpcv2Cbor_PutItemRequest_MixedItem_L
================================================================================
  metric           before        after         diff   % change
  ----------------------------------------------------------
  mean             276349       217368       -58981     -21.3%
  p50              272875       213958       -58917     -21.6%
  p90              285708       228375       -57333     -20.1%
  p95              294291       235000       -59291     -20.1%
  p99              315792       246625       -69167     -21.9%
  std_dev           11152         9199        -1953     -17.5%

================================================================================
  rpcv2Cbor_PutItemRequest_MixedItem_M
================================================================================
  metric           before        after         diff   % change
  ----------------------------------------------------------
  mean              92333        75228       -17105     -18.5%
  p50               91375        72875       -18500     -20.2%
  p90               94583        81458       -13125     -13.9%
  p95               98333        84083       -14250     -14.5%
  p99              106250        93208       -13042     -12.3%
  std_dev            4642         6282        +1640     +35.3%

================================================================================
  rpcv2Cbor_PutItemRequest_MixedItem_S
================================================================================
  metric           before        after         diff   % change
  ----------------------------------------------------------
  mean              18225        14989        -3236     -17.8%
  p50               17750        14375        -3375     -19.0%
  p90               18708        16750        -1958     -10.5%
  p95               19625        18000        -1625      -8.3%
  p99               23625        19083        -4542     -19.2%
  std_dev            3626         3684          +58      +1.6%

================================================================================
  rpcv2Cbor_PutItemRequest_Nested_L
================================================================================
  metric           before        after         diff   % change
  ----------------------------------------------------------
  mean              47264        47034         -230      -0.5%
  p50               45917        39333        -6584     -14.3%
  p90               50458        59834        +9376     +18.6%
  p95               53750        92458       +38708     +72.0%
  p99               61083       134750       +73667    +120.6%
  std_dev            9601        28468       +18867    +196.5%

================================================================================
  rpcv2Cbor_PutItemRequest_Nested_M
================================================================================
  metric           before        after         diff   % change
  ----------------------------------------------------------
  mean              12218         9980        -2238     -18.3%
  p50               11625         9500        -2125     -18.3%
  p90               13250        11291        -1959     -14.8%
  p95               14875        12041        -2834     -19.1%
  p99               16208        12625        -3583     -22.1%
  std_dev            3916         3498         -418     -10.7%

================================================================================
  rpcv2Cbor_PutItemRequest_ShallowMap_L
================================================================================
  metric           before        after         diff   % change
  ----------------------------------------------------------
  mean             342857       254479       -88378     -25.8%
  p50              336708       251500       -85208     -25.3%
  p90              372459       263167      -109292     -29.3%
  p95              380083       269959      -110124     -29.0%
  p99              455292       284500      -170792     -37.5%
  std_dev           34236         8205       -26031     -76.0%

================================================================================
  rpcv2Cbor_PutItemRequest_ShallowMap_M
================================================================================
  metric           before        after         diff   % change
  ----------------------------------------------------------
  mean             113269        80618       -32651     -28.8%
  p50              109250        79833       -29417     -26.9%
  p90              114083        82833       -31250     -27.4%
  p95              123542        86333       -37209     -30.1%
  p99              202750        93583      -109167     -53.8%
  std_dev           30515         2821       -27694     -90.8%

================================================================================
  rpcv2Cbor_PutItemRequest_ShallowMap_S
================================================================================
  metric           before        after         diff   % change
  ----------------------------------------------------------
  mean              22764        13172        -9592     -42.1%
  p50               17250        13041        -4209     -24.4%
  p90               22541        13292        -9249     -41.0%
  p95               44417        13625       -30792     -69.3%
  p99              156708        16750      -139958     -89.3%
  std_dev           31672         1034       -30638     -96.7%

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@ashovlin

Copy link
Copy Markdown
Member Author

#10644 is adding the timestamp fix and will likely merge first

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant