Commit 85507b9
Improve performace of repeated packed fixedSize fields (#19667)
## Changes
Improve performance of packed RepeatedField that has fixed size, by coping `LEN` bytes from serialzied buffer to RepeatedField array (like c memcpy).
## Relevant Information
As the docs [here](https://protobuf.dev/programming-guides/encoding/#cheat-sheet) notes, fixed size value is `memcpy of the equivalent C types (u?int64_t, double)`
You can see benchmark code and results [here](https://github.com/YarinOmesi/protobuf/blob/feature-with-benchmark/csharp/src/Benchmark)
## Summarized result:
| Method | Job | Size | Mean | Ratio | Allocated |
|----------------------|------------------------------|--------|-------------:|---------:|----------:|
| Parse_RepeatedFloats | 3.29.0 | 100000 | 416,582.7 ns | baseline | 400297 B |
| Parse_RepeatedFloats | improved-fixed-size-repeated | 100000 | 134,671.7 ns | -68% | 400776 B |
| Write_RepeatedFloats | 3.29.0 | 100000 | 340.549 us | baseline | 391.57 KB |
| Write_RepeatedFloats | improved-fixed-size-repeated | 100000 | 106.577 us | -69% | 391.5 KB |
---
I am pretty new to this repo to tell me what to you think about this.
Closes #19667
COPYBARA_INTEGRATE_REVIEW=#19667 from YarinOmesi:improve-performance-repeated-packed-fixed-field de11524
PiperOrigin-RevId: 7293801141 parent b666009 commit 85507b9
File tree
2 files changed
+76
-11
lines changed- csharp/src/Google.Protobuf
- Collections
2 files changed
+76
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| 17 | + | |
16 | 18 | | |
17 | 19 | | |
18 | 20 | | |
| |||
116 | 118 | | |
117 | 119 | | |
118 | 120 | | |
119 | | - | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
120 | 131 | | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
125 | 139 | | |
126 | 140 | | |
127 | 141 | | |
| |||
241 | 255 | | |
242 | 256 | | |
243 | 257 | | |
244 | | - | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
245 | 261 | | |
246 | | - | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
247 | 273 | | |
248 | 274 | | |
249 | 275 | | |
| |||
679 | 705 | | |
680 | 706 | | |
681 | 707 | | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
682 | 726 | | |
683 | 727 | | |
684 | 728 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
48 | | - | |
| 49 | + | |
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
| |||
382 | 383 | | |
383 | 384 | | |
384 | 385 | | |
385 | | - | |
| 386 | + | |
386 | 387 | | |
387 | 388 | | |
388 | 389 | | |
| |||
737 | 738 | | |
738 | 739 | | |
739 | 740 | | |
740 | | - | |
| 741 | + | |
741 | 742 | | |
742 | 743 | | |
743 | 744 | | |
| |||
751 | 752 | | |
752 | 753 | | |
753 | 754 | | |
754 | | - | |
| 755 | + | |
755 | 756 | | |
756 | 757 | | |
757 | 758 | | |
| |||
810 | 811 | | |
811 | 812 | | |
812 | 813 | | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
813 | 834 | | |
814 | 835 | | |
0 commit comments