Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

some more wire formatting improvements #989

Merged
merged 1 commit into from
Dec 20, 2020

Conversation

bollhals
Copy link
Contributor

Proposed Changes

Benchmarks:

  • Added size benchmarks
  • Added DataTypeFieldSerialization for table / array serialization

Optimizations

  • Aligned some optimization from table to array
  • Rearranged (or factored out into slow method) switches for types for read/write/size
  • Use span element ref to reduce code size
  • Use Int instead of byte for bool conversions

Breaking changes

  • ReadArray now returns null instead of empty List => Can be excluded if not wanted for backport

Types of Changes

  • Bug fix (non-breaking change which fixes issue #NNNN)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause an observable behavior change in existing systems)
  • Documentation improvements (corrections, new content, etc)
  • Cosmetic change (whitespace, formatting, etc)

Checklist

  • I have read the CONTRIBUTING.md document
  • I have signed the CA (see https://cla.pivotal.io/sign/rabbitmq)
  • All tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in related repositories

@bollhals
Copy link
Contributor Author

Benchmarks:
Before

|                Method |      Mean |     Error |   StdDev | Code Size |  Gen 0 |  Gen 1 | Gen 2 | Allocated |
|---------------------- |----------:|----------:|---------:|----------:|-------:|-------:|------:|----------:|
|        TableReadEmpty |  10.61 ns |  0.647 ns | 0.035 ns |     634 B |      - |      - |     - |         - |
|    TableReadPopulated | 851.79 ns | 53.415 ns | 2.928 ns |     634 B | 0.2871 | 0.0010 |     - |    1352 B |
|       TableWriteEmpty |  12.84 ns |  0.230 ns | 0.013 ns |    1041 B |      - |      - |     - |         - |
|   TableWritePopulated | 462.53 ns | 17.546 ns | 0.962 ns |    1041 B | 0.0186 |      - |     - |      88 B |
|     TableGetSizeEmpty |  16.85 ns |  0.612 ns | 0.034 ns |     735 B |      - |      - |     - |         - |
| TableGetSizePopulated | 294.06 ns | 42.104 ns | 2.308 ns |     735 B | 0.0186 |      - |     - |      88 B |

After

|                Method |       Mean |      Error |    StdDev | Code Size |  Gen 0 |  Gen 1 | Gen 2 | Allocated |
|---------------------- |-----------:|-----------:|----------:|----------:|-------:|-------:|------:|----------:|
|        TableReadEmpty |  10.958 ns |  1.3222 ns | 0.0725 ns |     638 B |      - |      - |     - |         - |
|    TableReadPopulated | 824.643 ns | 30.5694 ns | 1.6756 ns |     638 B | 0.2871 | 0.0010 |     - |    1352 B |
|       TableWriteEmpty |  13.217 ns |  2.3332 ns | 0.1279 ns |    1041 B |      - |      - |     - |         - |
|   TableWritePopulated | 386.165 ns | 26.3096 ns | 1.4421 ns |    1041 B |      - |      - |     - |         - |
|     TableGetSizeEmpty |   9.523 ns |  0.9596 ns | 0.0526 ns |     760 B |      - |      - |     - |         - |
| TableGetSizePopulated | 263.462 ns | 32.3660 ns | 1.7741 ns |     760 B |      - |      - |     - |         - |

Before

|                Method |       Mean |      Error |    StdDev | Code Size |  Gen 0 | Gen 1 | Gen 2 | Allocated |
|---------------------- |-----------:|-----------:|----------:|----------:|-------:|------:|------:|----------:|
|        ArrayReadEmpty |  14.865 ns |  4.1263 ns | 0.2262 ns |     408 B | 0.0068 |     - |     - |      32 B |
|    ArrayReadPopulated | 106.755 ns | 13.5321 ns | 0.7417 ns |     408 B | 0.0441 |     - |     - |     208 B |
|       ArrayWriteEmpty |   5.705 ns |  0.5799 ns | 0.0318 ns |     413 B |      - |     - |     - |         - |
|   ArrayWritePopulated |  87.764 ns |  6.6155 ns | 0.3626 ns |     413 B |      - |     - |     - |         - |
|     ArrayGetSizeEmpty |   2.981 ns |  0.4167 ns | 0.0228 ns |     147 B |      - |     - |     - |         - |
| ArrayGetSizePopulated |  44.364 ns |  1.9508 ns | 0.1069 ns |     147 B |      - |     - |     - |         - |

After

|                Method |      Mean |      Error |    StdDev | Code Size |  Gen 0 | Gen 1 | Gen 2 | Allocated |
|---------------------- |----------:|-----------:|----------:|----------:|-------:|------:|------:|----------:|
|        ArrayReadEmpty |  9.664 ns |  0.2994 ns | 0.0164 ns |     432 B |      - |     - |     - |         - |
|    ArrayReadPopulated | 96.834 ns | 10.2590 ns | 0.5623 ns |     432 B | 0.0441 |     - |     - |     208 B |
|       ArrayWriteEmpty |  5.188 ns |  4.4185 ns | 0.2422 ns |     438 B |      - |     - |     - |         - |
|   ArrayWritePopulated | 75.458 ns |  6.1223 ns | 0.3356 ns |     438 B |      - |     - |     - |         - |
|     ArrayGetSizeEmpty |  2.700 ns |  0.2232 ns | 0.0122 ns |     270 B |      - |     - |     - |         - |
| ArrayGetSizePopulated | 39.297 ns |  0.3700 ns | 0.0203 ns |     270 B |      - |     - |     - |         - |

Before

|                  Method |      Mean |     Error |    StdDev | Code Size |  Gen 0 | Gen 1 | Gen 2 | Allocated |
|------------------------ |----------:|----------:|----------:|----------:|-------:|------:|------:|----------:|
|                NullRead | 17.124 ns | 0.6011 ns | 0.0329 ns |    1799 B |      - |     - |     - |         - |
|                 IntRead | 21.348 ns | 1.2244 ns | 0.0671 ns |    1799 B | 0.0051 |     - |     - |      24 B |
|              StringRead | 36.421 ns | 5.8990 ns | 0.3233 ns |    1799 B | 0.0272 |     - |     - |     128 B |
|               ArrayRead | 19.518 ns | 0.6792 ns | 0.0372 ns |    1799 B |      - |     - |     - |         - |
|                DictRead | 20.240 ns | 0.9466 ns | 0.0519 ns |    1802 B |      - |     - |     - |         - |
|    BinaryTableValueRead | 24.666 ns | 0.7664 ns | 0.0420 ns |    1802 B | 0.0051 |     - |     - |      24 B |
|               NullWrite | 11.257 ns | 0.6672 ns | 0.0366 ns |    2581 B |      - |     - |     - |         - |
|                IntWrite | 14.347 ns | 1.3889 ns | 0.0761 ns |    2588 B |      - |     - |     - |         - |
|             StringWrite | 31.472 ns | 3.0262 ns | 0.1659 ns |    2588 B |      - |     - |     - |         - |
|              ArrayWrite | 19.562 ns | 1.8733 ns | 0.1027 ns |    2588 B |      - |     - |     - |         - |
|               DictWrite | 21.458 ns | 0.8154 ns | 0.0447 ns |    2588 B |      - |     - |     - |         - |
|   BinaryTableValueWrite | 25.888 ns | 0.2101 ns | 0.0115 ns |    2588 B |      - |     - |     - |         - |
|             NullGetSize |  1.116 ns | 0.0255 ns | 0.0014 ns |     826 B |      - |     - |     - |         - |
|              IntGetSize |  3.003 ns | 0.3161 ns | 0.0173 ns |     828 B |      - |     - |     - |         - |
|           StringGetSize | 18.425 ns | 1.2664 ns | 0.0694 ns |     828 B |      - |     - |     - |         - |
|            ArrayGetSize |  8.221 ns | 1.2211 ns | 0.0669 ns |     828 B |      - |     - |     - |         - |
|             DictGetSize | 41.566 ns | 5.4613 ns | 0.2994 ns |     828 B | 0.0119 |     - |     - |      56 B |
| BinaryTableValueGetSize | 10.078 ns | 0.6026 ns | 0.0330 ns |     828 B |      - |     - |     - |         - |

After

|                  Method |       Mean |     Error |    StdDev |  Gen 0 | Gen 1 | Gen 2 | Allocated | Code Size |
|------------------------ |-----------:|----------:|----------:|-------:|------:|------:|----------:|----------:|
|                NullRead |  9.8133 ns | 0.0767 ns | 0.0042 ns |      - |     - |     - |         - |     556 B |
|                 IntRead | 13.3957 ns | 2.2286 ns | 0.1222 ns | 0.0051 |     - |     - |      24 B |     556 B |
|              StringRead | 28.5507 ns | 3.7903 ns | 0.2078 ns | 0.0272 |     - |     - |     128 B |     556 B |
|               ArrayRead | 12.8032 ns | 0.3511 ns | 0.0192 ns |      - |     - |     - |         - |     556 B |
|                DictRead | 22.3597 ns | 0.3973 ns | 0.0218 ns |      - |     - |     - |         - |     559 B |
|    BinaryTableValueRead | 27.8326 ns | 3.2129 ns | 0.1761 ns | 0.0051 |     - |     - |      24 B |     559 B |
|               NullWrite |  4.3774 ns | 0.3998 ns | 0.0219 ns |      - |     - |     - |         - |     841 B |
|                IntWrite |  6.5297 ns | 0.1169 ns | 0.0064 ns |      - |     - |     - |         - |     848 B |
|             StringWrite | 21.8839 ns | 1.1791 ns | 0.0646 ns |      - |     - |     - |         - |     848 B |
|              ArrayWrite | 11.7807 ns | 0.3741 ns | 0.0205 ns |      - |     - |     - |         - |     848 B |
|               DictWrite | 22.8961 ns | 0.7784 ns | 0.0427 ns |      - |     - |     - |         - |     848 B |
|   BinaryTableValueWrite | 21.6578 ns | 0.5540 ns | 0.0304 ns |      - |     - |     - |         - |     848 B |
|             NullGetSize |  0.9719 ns | 0.1905 ns | 0.0104 ns |      - |     - |     - |         - |     721 B |
|              IntGetSize |  2.1791 ns | 0.1463 ns | 0.0080 ns |      - |     - |     - |         - |     723 B |
|           StringGetSize | 14.3706 ns | 0.2807 ns | 0.0154 ns |      - |     - |     - |         - |     723 B |
|            ArrayGetSize |  5.7586 ns | 0.6935 ns | 0.0380 ns |      - |     - |     - |         - |     723 B |
|             DictGetSize | 15.9500 ns | 1.0203 ns | 0.0559 ns |      - |     - |     - |         - |     723 B |
| BinaryTableValueGetSize | 11.9623 ns | 0.6234 ns | 0.0342 ns |      - |     - |     - |         - |     723 B |

@michaelklishin michaelklishin merged commit 6fb8b43 into rabbitmq:master Dec 20, 2020
@michaelklishin
Copy link
Member

Thank you! Squeezing even minor gains in these areas benefits 100% of the users 👍

@stebet
Copy link
Contributor

stebet commented Dec 20, 2020

Awesome. Lines well up with a few changes I have almost ready ;)

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.

3 participants