Speedup and cleanup vom decoder.
This brings the vom Decoder implementation into a reasonable
state, performance-wise. The main changes are to:
1) Bytes handling is improved, both for []byte lists and [n]byte
arrays, and regardless of named / unnamed / generated / reflect
variants. Note that the implementation chooses to not re-use
existing byte slices when decoding, which costs ~10% in our
benchmarks, but is safer for developers.
2) Scalar collections now have special Decoder ReadValue* and
NextEntryValue* methods. This simplifies the generated code, and
also lets us implement some important optimizations, which speed
up array, list, set and map.
Other than similar changes on the Encoder, the largest remaining
item for vom speedup / cleanup is to re-implement the vdl type
registration mechanism, which will let us use David Crawshaw's
cool ideas for smaller binary sizes, and also for a faster /
simpler implementation.
There are lots of files here. The important ones to look at are
the non *.vdl.go files under:
v.io/v23/vdl
v.io/v23/vom
v.io/v23/verror
v.io/x/ref/lib/vdl/codegen/golang
Here are the decoding benchmarks. I'm not worrying too much
about the ones that got worse, since the absolute magnitude is
relatively small.
benchmark old ns/op new ns/op delta
Vom___Decode_____XNumber 1477 1318 -10.77%
Vom___DecodeMany_XNumber 536 459 -14.37%
Vom___Decode_____VNumber 1045 898 -14.07%
Vom___DecodeMany_VNumber 260 256 -1.54%
Vom___Decode_____XStringSmall 1627 1437 -11.68%
Vom___DecodeMany_XStringSmall 681 617 -9.40%
Vom___Decode_____VStringSmall 1207 1012 -16.16%
Vom___DecodeMany_VStringSmall 405 343 -15.31%
Vom___Decode_____XStringLarge 33714 33658 -0.17%
Vom___DecodeMany_XStringLarge 33325 32451 -2.62%
Vom___Decode_____VStringLarge 33284 32038 -3.74%
Vom___DecodeMany_VStringLarge 31765 31426 -1.07%
Vom___Decode_____VEnum 1123 910 -18.97%
Vom___DecodeMany_VEnum 298 271 -9.06%
Vom___Decode_____XByteListSmall 1950 1592 -18.36%
Vom___DecodeMany_XByteListSmall 931 802 -13.86%
Vom___Decode_____VByteListSmall 1225 1052 -14.12%
Vom___DecodeMany_VByteListSmall 426 386 -9.39%
Vom___Decode_____XByteListLarge 20721 19814 -4.38%
Vom___DecodeMany_XByteListLarge 19334 18850 -2.50%
Vom___Decode_____VByteListLarge 19364 18905 -2.37%
Vom___DecodeMany_VByteListLarge 17947 17987 +0.22%
Vom___Decode_____XByteArray 1758 1568 -10.81%
Vom___DecodeMany_XByteArray 768 733 -4.56%
Vom___Decode_____VByteArray 1125 945 -16.00%
Vom___DecodeMany_VByteArray 358 332 -7.26%
Vom___Decode_____XArray 2553 1840 -27.93%
Vom___DecodeMany_XArray 1234 733 -40.60%
Vom___Decode_____VArray 1515 1199 -20.86%
Vom___DecodeMany_VArray 502 409 -18.53%
Vom___Decode_____XListSmall 3719 2178 -41.44%
Vom___DecodeMany_XListSmall 2344 1088 -53.58%
Vom___Decode_____VListSmall 1608 1255 -21.95%
Vom___DecodeMany_VListSmall 589 465 -21.05%
Vom___Decode_____XListLarge 28288185 3706132 -86.90%
Vom___DecodeMany_XListLarge 28454774 3718255 -86.93%
Vom___Decode_____VListLarge 5264233 2425440 -53.93%
Vom___DecodeMany_VListLarge 6324235 2424557 -61.66%
Vom___Decode_____XListAnySmall 5459 4371 -19.93%
Vom___DecodeMany_XListAnySmall 3895 2918 -25.08%
Vom___Decode_____VListAnySmall 2898 2666 -8.01%
Vom___DecodeMany_VListAnySmall 1701 1507 -11.41%
Vom___Decode_____XListAnyLarge 56238352 38693410 -31.20%
Vom___DecodeMany_XListAnyLarge 56389732 37919725 -32.75%
Vom___Decode_____VListAnyLarge 27310371 25149237 -7.91%
Vom___DecodeMany_VListAnyLarge 26423353 24243553 -8.25%
Vom___Decode_____VSet 2291 1970 -14.01%
Vom___DecodeMany_VSet 1227 1088 -11.33%
Vom___Decode_____XMap 5278 4169 -21.01%
Vom___DecodeMany_XMap 4734 3048 -35.61%
Vom___Decode_____VMap 2699 2144 -20.56%
Vom___DecodeMany_VMap 1527 1209 -20.83%
Vom___Decode_____XSmallStruct 3860 3506 -9.17%
Vom___DecodeMany_XSmallStruct 2451 2353 -4.00%
Vom___Decode_____VSmallStruct 1878 1627 -13.37%
Vom___DecodeMany_VSmallStruct 823 674 -18.10%
Vom___Decode_____XLargeStruct 33192 30363 -8.52%
Vom___DecodeMany_XLargeStruct 31344 28640 -8.63%
Vom___Decode_____VLargeStruct 8687 7311 -15.84%
Vom___DecodeMany_VLargeStruct 7038 6028 -14.35%
Vom___Decode_____XLargeStructZero 2121 2069 -2.45%
Vom___DecodeMany_XLargeStructZero 758 726 -4.22%
Vom___Decode_____VLargeStructZero 1319 1338 +1.44%
Vom___DecodeMany_VLargeStructZero 293 298 +1.71%
Vom___Decode_____VSmallUnion 2706 2516 -7.02%
Vom___DecodeMany_VSmallUnion 1237 1241 +0.32%
Vom___Decode_____Time 3078 2812 -8.64%
Vom___DecodeMany_Time 1800 1672 -7.11%
Vom___Decode_____Blessings 57178 56034 -2.00%
Vom___DecodeMany_Blessings 54852 53810 -1.90%
Vom___Decode_____RPCRequestZero 1765 1767 +0.11%
Vom___DecodeMany_RPCRequestZero 309 327 +5.83%
Vom___Decode_____RPCRequestFull 58691 57640 -1.79%
Vom___DecodeMany_RPCRequestFull 55820 54865 -1.71%
Vom___Decode_____RPCResponseZero 1804 1803 -0.06%
Vom___DecodeMany_RPCResponseZero 338 333 -1.48%
Vom___Decode_____RPCResponseFull 43685 42907 -1.78%
Vom___DecodeMany_RPCResponseFull 39505 39474 -0.08%
MultiPart: 2/5
Change-Id: Ide16501727c14ab89f1e79c595a1d2596480a8e1
1 file changed