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

Improvements in command handling #5 #631

Open
wants to merge 173 commits into
base: main
Choose a base branch
from

Conversation

TalZaccai
Copy link
Contributor

@TalZaccai TalZaccai commented Sep 3, 2024

  • Introducing RawStringInput struct to simplify main store command processing
    • BasicCommands
    • ArrayCommands
    • MainStoreOps
    • AdvancedOps
    • BitmapCommands
    • BitmapOps
    • HyperLogLogCommands
    • HyperLogLogOps
    • KeyAdminCommands
    • CustomRawStringFunctions
  • Supporting RawStringInput serialization/deserialization for AOF recovery
  • Relaying parse state to custom commands / transactions
  • Fixing bug in PFCOUNT logic

Benchmarking results:
GeoHashBenchmarks

main:

Method Mean Error StdDev Gen0 Allocated
GeoToLongValue 5.130 ns 0.2571 ns 0.7294 ns - -
GetCoordinatesFromLong 4.704 ns 0.1240 ns 0.1523 ns - -
GetGeoHashCode 16.508 ns 0.2788 ns 0.2471 ns 0.0001 48 B

#631:

Method Mean Error StdDev Gen0 Allocated
GeoToLongValue 4.769 ns 0.1289 ns 0.1433 ns - -
GetCoordinatesFromLong 5.490 ns 0.1025 ns 0.1332 ns - -
GetGeoHashCode 17.832 ns 0.3667 ns 0.3430 ns 0.0001 48 B

RecoveryBenchmark

main:

Method MemorySize LogDir Mean Error StdDev P90 P95
Recover 100m -f 113.8 us 2.96 us 8.26 us 122.6 us 125.9 us
Recover 100m * NA NA NA NA NA

#631:

Method MemorySize LogDir Mean Error StdDev P90 P95
Recover 100m -f 130.8 us 6.16 us 17.88 us 156.6 us 163.5 us
Recover 100m * NA NA NA NA NA

SpanVsPointer

main:

Method Mean Error StdDev Ratio RatioSD
Pointer 418.9 ns 8.32 ns 16.02 ns 1.00 0.05
Span 1,265.5 ns 15.45 ns 12.06 ns 3.03 0.12
SpanToPointer 376.2 ns 6.88 ns 13.43 ns 0.90 0.05

#631:

Method Mean Error StdDev Ratio RatioSD
Pointer 414.7 ns 4.39 ns 3.89 ns 1.00 0.01
Span 1,281.5 ns 21.47 ns 20.08 ns 3.09 0.05
SpanToPointer 383.5 ns 7.54 ns 9.54 ns 0.92 0.02

RespClusterBench

main:

Method Mean Error StdDev Allocated
Get 15.25 us 0.202 us 0.169 us -
Set 15.67 us 0.289 us 0.270 us -
MGet 12.20 us 0.191 us 0.179 us -
MSet 12.78 us 0.247 us 0.231 us -

#631:

Method Mean Error StdDev Allocated
Get 15.22 us 0.231 us 0.193 us -
Set 16.52 us 0.304 us 0.285 us -
MGet 12.39 us 0.185 us 0.155 us -
MSet 13.33 us 0.264 us 0.220 us -

RespClusterMigrateBench

main:

Method Mean Error StdDev Allocated
Get 27.80 us 0.554 us 0.862 us -
Set 29.20 us 0.583 us 0.835 us -
MGet 24.40 us 0.210 us 0.175 us -
MSet 25.58 us 0.290 us 0.257 us -

#631:

Method Mean Error StdDev Allocated
Get 28.77 us 0.536 us 0.501 us -
Set 30.74 us 0.610 us 1.019 us -
MGet 24.99 us 0.363 us 0.339 us -
MSet 26.06 us 0.386 us 0.429 us -

RespAofStress

main:

Method Mean Error StdDev Allocated
Set 16.42 us 0.296 us 0.541 us -
Increment 21.66 us 0.414 us 0.367 us -
LPushPop 109.45 us 1.413 us 1.253 us 32768 B

#631:

Method Mean Error StdDev Allocated
Set 18.60 us 0.280 us 0.262 us -
Increment 26.02 us 0.444 us 0.394 us -
LPushPop 110.39 us 1.577 us 1.475 us 18432 B

RespDoubleWriteBenchmarks

main:

Method value Mean Error StdDev Gen0 Allocated
WriteDoubleAsBulkString -1.79(...)E+308 [24] 137.55 ns 2.615 ns 2.446 ns - -
WriteDoubleAsBulkStringByTranscoding -1.79(...)E+308 [24] 165.03 ns 1.976 ns 1.848 ns - 72 B
WriteDoubleAsBulkString -1 53.90 ns 1.049 ns 1.166 ns - -
WriteDoubleAsBulkStringByTranscoding -1 60.66 ns 0.931 ns 0.825 ns - 32 B
WriteDoubleAsBulkString 0 31.91 ns 0.569 ns 0.532 ns - -
WriteDoubleAsBulkStringByTranscoding 0 36.52 ns 0.755 ns 0.589 ns 0.0001 24 B
WriteDoubleAsBulkString 1 50.86 ns 0.854 ns 0.713 ns - -
WriteDoubleAsBulkStringByTranscoding 1 56.81 ns 0.757 ns 0.708 ns - 24 B
WriteDoubleAsBulkString 3.141592653589793 107.41 ns 2.174 ns 1.928 ns - -
WriteDoubleAsBulkStringByTranscoding 3.141592653589793 124.18 ns 2.465 ns 3.374 ns - 56 B
WriteDoubleAsBulkString 1.797(...)E+308 [23] 136.16 ns 1.639 ns 1.368 ns - -
WriteDoubleAsBulkStringByTranscoding 1.797(...)E+308 [23] 165.22 ns 2.286 ns 2.027 ns - 72 B

#631:

Method value Mean Error StdDev Median Gen0 Allocated
WriteDoubleAsBulkString -1.79(...)E+308 [24] 139.44 ns 2.657 ns 2.843 ns 138.28 ns - -
WriteDoubleAsBulkStringByTranscoding -1.79(...)E+308 [24] 171.68 ns 2.864 ns 2.539 ns 172.33 ns - 72 B
WriteDoubleAsBulkString -1 62.40 ns 4.801 ns 13.540 ns 56.10 ns - -
WriteDoubleAsBulkStringByTranscoding -1 61.18 ns 1.122 ns 0.995 ns 61.32 ns - 32 B
WriteDoubleAsBulkString 0 32.79 ns 0.690 ns 1.440 ns 32.37 ns - -
WriteDoubleAsBulkStringByTranscoding 0 36.73 ns 0.715 ns 0.669 ns 36.61 ns 0.0001 24 B
WriteDoubleAsBulkString 1 53.57 ns 1.110 ns 2.924 ns 52.41 ns - -
WriteDoubleAsBulkStringByTranscoding 1 59.13 ns 0.999 ns 0.885 ns 59.05 ns - 24 B
WriteDoubleAsBulkString 3.141592653589793 106.73 ns 1.472 ns 2.616 ns 106.22 ns - -
WriteDoubleAsBulkStringByTranscoding 3.141592653589793 122.28 ns 2.443 ns 2.285 ns 121.71 ns - 56 B
WriteDoubleAsBulkString 1.797(...)E+308 [23] 135.87 ns 2.052 ns 1.920 ns 135.80 ns - -
WriteDoubleAsBulkStringByTranscoding 1.797(...)E+308 [23] 164.77 ns 2.929 ns 2.287 ns 164.62 ns - 72 B

RespIncrementStress

main:

Method input Mean Error StdDev
Increment ? 165.4 ns 3.37 ns 7.33 ns
Decrement ? 163.7 ns 2.54 ns 2.12 ns
IncrementBy Byte[30] 252.2 ns 4.35 ns 4.07 ns
DecrementBy Byte[30] 251.1 ns 3.81 ns 3.38 ns
IncrementBy Byte[31] 250.5 ns 3.09 ns 2.74 ns
DecrementBy Byte[31] 250.5 ns 4.74 ns 5.99 ns
IncrementBy Byte[40] 263.7 ns 3.97 ns 3.52 ns
DecrementBy Byte[40] 277.2 ns 3.21 ns 2.50 ns
IncrementBy Byte[41] 270.7 ns 5.03 ns 3.93 ns
DecrementBy Byte[41] 265.3 ns 3.25 ns 2.72 ns

#631:

Method input Mean Error StdDev
Increment ? 170.4 ns 3.02 ns 2.83 ns
Decrement ? 167.7 ns 3.32 ns 3.70 ns
IncrementBy Byte[30] 236.7 ns 1.74 ns 1.54 ns
DecrementBy Byte[30] 238.8 ns 4.54 ns 5.04 ns
IncrementBy Byte[31] 246.0 ns 4.19 ns 3.91 ns
DecrementBy Byte[31] 247.6 ns 3.48 ns 3.25 ns
IncrementBy Byte[40] 265.1 ns 5.32 ns 6.34 ns
DecrementBy Byte[40] 265.5 ns 4.51 ns 4.22 ns
IncrementBy Byte[41] 267.8 ns 5.37 ns 10.08 ns
DecrementBy Byte[41] 265.2 ns 3.62 ns 3.39 ns

RespIntegerReadBenchmarks

main:

Method testCase Mean Error StdDev Median
ReadLengthHeader $-1\r\n 1.841 ns 0.0698 ns 0.1659 ns 1.785 ns
ReadLengthHeader $-2147483648\r\n NA NA NA NA
ReadLengthHeader $0\r\n 3.387 ns 0.0916 ns 0.0812 ns 3.379 ns
ReadIntWithLengthHeader $1\r\n0\r\n 8.545 ns 0.0851 ns 0.0796 ns 8.553 ns
ReadLongWithLengthHeader $1\r\n0\r\n 7.808 ns 0.1803 ns 0.1686 ns 7.789 ns
ReadULongWithLengthHeader $1\r\n0\r\n 7.068 ns 0.2658 ns 0.7836 ns 6.770 ns
ReadIntWithLengthHeader $10\r\n2147483647\r\n 16.773 ns 0.6680 ns 1.9696 ns 16.179 ns
ReadULongWithLengthHeader $10\r\n2147483647\r\n 14.346 ns 0.2350 ns 0.1962 ns 14.362 ns
ReadIntWithLengthHeader $11\r\n-2147483648\r\n 15.144 ns 0.2487 ns 0.2326 ns 15.130 ns
ReadLongWithLengthHeader $19\r\n(...)807\r\n [26] 16.529 ns 0.3170 ns 0.2647 ns 16.472 ns
ReadIntWithLengthHeader $2\r\n-1\r\n 8.905 ns 0.1315 ns 0.1230 ns 8.895 ns
ReadLongWithLengthHeader $2\r\n-1\r\n 7.851 ns 0.0843 ns 0.0704 ns 7.870 ns
ReadLongWithLengthHeader $20\r\n(...)808\r\n [27] 17.665 ns 0.3845 ns 0.8911 ns 17.378 ns
ReadULongWithLengthHeader $20\r\n(...)615\r\n [27] 18.131 ns 0.3988 ns 0.5459 ns 17.965 ns
ReadLengthHeader $2147483647\r\n 9.914 ns 0.1323 ns 0.1238 ns 9.905 ns
ReadInt64 :-1\r\n 5.669 ns 0.0675 ns 0.0598 ns 5.655 ns
ReadInt64 :-922(...)808\r\n [23] 14.500 ns 0.3018 ns 0.2675 ns 14.498 ns
ReadInt64 :0\r\n 5.655 ns 0.0936 ns 0.0875 ns 5.678 ns
ReadInt64 :9223(...)807\r\n [22] 13.909 ns 0.1917 ns 0.1601 ns 13.939 ns

#631:

Method testCase Mean Error StdDev Median
ReadLengthHeader $-1\r\n 2.533 ns 0.0427 ns 0.0399 ns 2.552 ns
ReadLengthHeader $-2147483648\r\n NA NA NA NA
ReadLengthHeader $0\r\n 3.669 ns 0.0538 ns 0.0477 ns 3.684 ns
ReadIntWithLengthHeader $1\r\n0\r\n 10.209 ns 0.0889 ns 0.0743 ns 10.200 ns
ReadLongWithLengthHeader $1\r\n0\r\n 10.745 ns 0.2035 ns 0.1804 ns 10.710 ns
ReadULongWithLengthHeader $1\r\n0\r\n 6.992 ns 0.2793 ns 0.7406 ns 7.088 ns
ReadIntWithLengthHeader $10\r\n2147483647\r\n 17.260 ns 0.3736 ns 0.4302 ns 17.133 ns
ReadULongWithLengthHeader $10\r\n2147483647\r\n 14.407 ns 0.2202 ns 0.2059 ns 14.392 ns
ReadIntWithLengthHeader $11\r\n-2147483648\r\n 17.210 ns 0.3355 ns 0.2620 ns 17.155 ns
ReadLongWithLengthHeader $19\r\n(...)807\r\n [26] 18.053 ns 0.3771 ns 0.4768 ns 17.878 ns
ReadIntWithLengthHeader $2\r\n-1\r\n 10.353 ns 0.2326 ns 0.2176 ns 10.290 ns
ReadLongWithLengthHeader $2\r\n-1\r\n 10.855 ns 0.2465 ns 0.5146 ns 11.051 ns
ReadLongWithLengthHeader $20\r\n(...)808\r\n [27] 23.001 ns 0.4303 ns 0.4226 ns 22.807 ns
ReadULongWithLengthHeader $20\r\n(...)615\r\n [27] 20.590 ns 0.4421 ns 0.5263 ns 20.415 ns
ReadLengthHeader $2147483647\r\n 9.666 ns 0.2125 ns 0.3833 ns 9.578 ns
ReadInt64 :-1\r\n 6.840 ns 0.1202 ns 0.1124 ns 6.786 ns
ReadInt64 :-922(...)808\r\n [23] 16.144 ns 0.3325 ns 0.2947 ns 16.082 ns
ReadInt64 :0\r\n 6.623 ns 0.0630 ns 0.0526 ns 6.614 ns
ReadInt64 :9223(...)807\r\n [22] 16.168 ns 0.2093 ns 0.1958 ns 16.173 ns

RespIntegerWriteBenchmarks

main:

Method value Mean Error StdDev Median
WriteInt32_AllAsciiLengths ? 23,712.043 ns 471.6419 ns 484.3415 ns 23,501.273 ns
WriteInt64_AllAsciiLengths ? 82,229.185 ns 1,578.6950 ns 1,399.4720 ns 81,692.041 ns
WriteInt32BulkString_AllAsciiLengths ? 23,833.167 ns 324.6709 ns 303.6974 ns 23,907.724 ns
WriteInt32 -2147483648 5.960 ns 0.0683 ns 0.0605 ns 5.980 ns
WriteInt32 -1 5.410 ns 0.0963 ns 0.0854 ns 5.414 ns
WriteInt64 -9223372036854775808 4.833 ns 0.2519 ns 0.6980 ns 4.635 ns
WriteInt64 -1 6.660 ns 0.1676 ns 0.3534 ns 6.633 ns
WriteInt32AsBulkString -2147483648 11.819 ns 0.2405 ns 0.5762 ns 11.611 ns
WriteInt32AsBulkString -1 9.593 ns 0.2190 ns 0.2151 ns 9.539 ns
WriteInt32 0 4.488 ns 0.0802 ns 0.0711 ns 4.481 ns
WriteInt64 0 4.960 ns 0.0930 ns 0.0913 ns 4.920 ns
WriteInt32AsBulkString 0 8.083 ns 0.1835 ns 0.1716 ns 8.091 ns
WriteInt32 2147483647 12.187 ns 0.1426 ns 0.1264 ns 12.139 ns
WriteInt32AsBulkString 2147483647 17.858 ns 0.3889 ns 0.9828 ns 17.420 ns
WriteInt64 9223372036854775807 26.661 ns 0.5129 ns 1.0592 ns 26.429 ns

#631:

Method value Mean Error StdDev Median
WriteInt32_AllAsciiLengths ? 23,779.419 ns 350.1536 ns 327.5339 ns 23,762.656 ns
WriteInt64_AllAsciiLengths ? 81,888.036 ns 1,583.0011 ns 1,403.2892 ns 81,409.979 ns
WriteInt32BulkString_AllAsciiLengths ? 23,033.019 ns 449.9581 ns 398.8761 ns 22,914.883 ns
WriteInt32 -2147483648 5.867 ns 0.0887 ns 0.0830 ns 5.852 ns
WriteInt32 -1 5.481 ns 0.1368 ns 0.1778 ns 5.460 ns
WriteInt64 -9223372036854775808 4.226 ns 0.0516 ns 0.0457 ns 4.229 ns
WriteInt64 -1 6.120 ns 0.1539 ns 0.4239 ns 5.955 ns
WriteInt32AsBulkString -2147483648 12.104 ns 0.4777 ns 1.2996 ns 11.841 ns
WriteInt32AsBulkString -1 10.923 ns 0.1031 ns 0.0861 ns 10.934 ns
WriteInt32 0 4.484 ns 0.0912 ns 0.0808 ns 4.466 ns
WriteInt64 0 4.986 ns 0.0642 ns 0.0569 ns 4.970 ns
WriteInt32AsBulkString 0 8.087 ns 0.1526 ns 0.1428 ns 8.066 ns
WriteInt32 2147483647 11.923 ns 0.2288 ns 0.2029 ns 11.932 ns
WriteInt32AsBulkString 2147483647 17.313 ns 0.2455 ns 0.2297 ns 17.326 ns
WriteInt64 9223372036854775807 24.275 ns 0.5509 ns 1.0481 ns 23.914 ns

RespLuaRunnerStress

main:

Method Mean Error StdDev Median Gen0 Allocated
BasicLua1 93.90 ns 1.862 ns 1.742 ns 93.66 ns - 24 B
BasicLua2 157.37 ns 3.125 ns 5.135 ns 156.01 ns 0.0002 144 B
BasicLua3 396.77 ns 48.629 ns 143.383 ns 302.33 ns 0.0005 240 B
BasicLua4 1,524.64 ns 30.449 ns 57.932 ns 1,509.03 ns 0.0019 776 B

#631:

Method Mean Error StdDev Gen0 Allocated
BasicLua1 92.38 ns 1.762 ns 1.471 ns - 24 B
BasicLua2 150.43 ns 2.808 ns 2.192 ns 0.0002 144 B
BasicLua3 276.65 ns 5.470 ns 5.372 ns 0.0005 240 B
BasicLua4 1,438.84 ns 16.177 ns 13.508 ns 0.0019 776 B

RespLuaStress

main:

Method Mean Error StdDev Gen0 Allocated
BasicLua1 82.81 ns 1.452 ns 2.173 ns - 24 B
BasicLua2 141.43 ns 2.862 ns 2.677 ns 0.0002 144 B
BasicLua3 535.02 ns 7.188 ns 6.724 ns 0.0010 328 B
BasicLua4 1,192.51 ns 19.110 ns 17.875 ns 0.0019 832 B

#631:

Method Mean Error StdDev Gen0 Allocated
BasicLua1 78.00 ns 1.543 ns 1.368 ns - 24 B
BasicLua2 134.78 ns 1.721 ns 1.526 ns 0.0002 144 B
BasicLua3 523.07 ns 9.401 ns 8.794 ns 0.0010 328 B
BasicLua4 1,154.09 ns 18.219 ns 17.042 ns 0.0019 832 B

RespParseACLStress

main:

Method UseACLs Mean Error StdDev Allocated
InlinePing False 1.819 us 0.0171 us 0.0160 us -
Set False 12.013 us 0.1642 us 0.1456 us -
SetEx False 18.450 us 0.2746 us 0.2434 us -
Get False 8.216 us 0.1298 us 0.1862 us -
Increment False 17.524 us 0.1725 us 0.1529 us -
ZAddRem False 106.559 us 1.1891 us 1.1123 us 23552 B
LPushPop False 95.807 us 1.7211 us 1.3437 us 18432 B
SAddRem False 87.816 us 1.1058 us 0.9234 us 16384 B
HSetDel False 155.144 us 3.0969 us 7.0533 us 55297 B
MyDictSetGet False 167.714 us 1.5974 us 1.3339 us 30720 B
InlinePing True 1.843 us 0.0357 us 0.0317 us -
Set True 12.462 us 0.1590 us 0.1409 us -
SetEx True 3.421 us 0.0493 us 0.0461 us -
Get True 8.224 us 0.1495 us 0.2047 us -
Increment True 2.327 us 0.0435 us 0.0363 us -
ZAddRem True 13.967 us 0.2698 us 0.3211 us -
LPushPop True 14.190 us 0.1917 us 0.1793 us -
SAddRem True 13.941 us 0.2047 us 0.1915 us -
HSetDel True 13.632 us 0.2033 us 0.1901 us -
MyDictSetGet True 72.984 us 1.1760 us 0.9820 us -

#631:

Method UseACLs Mean Error StdDev Median Allocated
InlinePing False 1.946 us 0.0256 us 0.0227 us 1.946 us -
Set False 12.383 us 0.2333 us 0.1948 us 12.314 us -
SetEx False 17.314 us 0.1903 us 0.1687 us 17.319 us -
Get False 8.036 us 0.1577 us 0.1877 us 7.987 us -
Increment False 18.253 us 0.2480 us 0.2071 us 18.218 us -
ZAddRem False 106.227 us 1.8700 us 3.7345 us 104.976 us 23552 B
LPushPop False 91.848 us 0.8454 us 0.7060 us 91.585 us 18432 B
SAddRem False 87.864 us 1.6639 us 1.4750 us 87.259 us 16384 B
HSetDel False 149.704 us 8.7587 us 23.2270 us 154.094 us 55297 B
MyDictSetGet False 173.115 us 2.6690 us 2.3660 us 173.736 us 30720 B
InlinePing True 2.077 us 0.0415 us 0.0595 us 2.063 us -
Set True 12.381 us 0.2466 us 0.6231 us 12.164 us -
SetEx True 3.599 us 0.0702 us 0.1028 us 3.574 us -
Get True 8.256 us 0.1650 us 0.2418 us 8.181 us -
Increment True 2.398 us 0.0479 us 0.0470 us 2.385 us -
ZAddRem True 13.698 us 0.2524 us 0.2237 us 13.702 us -
LPushPop True 12.717 us 0.2397 us 0.6189 us 12.620 us -
SAddRem True 13.018 us 0.2142 us 0.1789 us 12.991 us -
HSetDel True 13.034 us 0.2597 us 0.2302 us 12.996 us -
MyDictSetGet True 72.379 us 1.2960 us 1.5428 us 71.757 us -

RespParseStress

main:

Method Mean Error StdDev Allocated
InlinePing 1.847 us 0.0347 us 0.0308 us -
Set 12.027 us 0.1440 us 0.1347 us -
SetEx 17.180 us 0.1956 us 0.1829 us -
Get 7.988 us 0.1135 us 0.1006 us -
Increment 18.402 us 0.3632 us 0.7084 us -
ZAddRem 105.054 us 1.2244 us 1.0854 us 23552 B
LPushPop 93.678 us 1.8514 us 3.9853 us 18432 B
SAddRem 87.940 us 1.7248 us 1.6134 us 16384 B
HSetDel 151.430 us 3.0211 us 5.8206 us 55297 B
MyDictSetGet 169.125 us 2.7683 us 2.5894 us 30720 B

#631:

Method Mean Error StdDev Allocated
InlinePing 1.925 us 0.0328 us 0.0322 us -
Set 12.311 us 0.2425 us 0.2269 us -
SetEx 17.571 us 0.3285 us 0.4272 us -
Get 8.199 us 0.1062 us 0.0886 us -
Increment 18.486 us 0.1738 us 0.1541 us -
ZAddRem 105.684 us 1.4259 us 1.2641 us 23552 B
LPushPop 91.931 us 0.9396 us 0.8329 us 18432 B
SAddRem 88.029 us 1.7527 us 2.8798 us 16384 B
HSetDel 153.453 us 3.4489 us 9.6140 us 55297 B
MyDictSetGet 180.070 us 2.7047 us 3.4206 us 30720 B

RespTsavoriteStress

main:

Method Mean Error StdDev
Get 11.59 us 0.162 us 0.152 us
Set 11.83 us 0.140 us 0.131 us
Incr 17.20 us 0.333 us 0.409 us

#631:

Method Mean Error StdDev
Get 12.42 us 0.216 us 0.181 us
Set 12.55 us 0.251 us 0.477 us
Incr 18.84 us 0.329 us 0.292 us

=> t.TotalSize;
public int GetUpsertValueLength(ref SpanByte t, ref RawStringInput input)
{
if (input.header.cmd != RespCommand.NONE)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can avoid this if and directly do the switch with SET, SETEX, default sections.

{
case RespCommand.SET:
case RespCommand.SETEX:
return input.arg1 > 0 && t.MetadataSize == 0 ? t.TotalSize + sizeof(long) : t.TotalSize;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reduce one if condition:

input.arg1 == 0 ? t.TotalSize : sizeof(int) + t.LengthWithoutMetadata + sizeof(long)

}
throw new GarnetException("Unsupported operation on input");
}
}

return sizeof(int) + input.Length - RespInputHeader.Size;
return sizeof(int) + input.parseState.GetArgSliceByRef(input.parseStateFirstArgIdx).ReadOnlySpan.Length +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to get the ReadOnlySpan first before finding the length? can try to avoid this.

{
Initialize(1);

buffer[0] = arg;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use bufferPtr, rename buffer to bufferRoot, add Slice for SPS.

@@ -46,8 +44,7 @@ public unsafe struct SessionParseState
/// <summary>
/// Initialize the parse state at the start of a session
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change public readonly Span<ArgSlice> Parameters to public ReadOnlySpan<ArgSlice> Parameters

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.

5 participants