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

VM: avoid checking reference when the stack is not full. #3107

Merged
merged 6 commits into from
Feb 7, 2024

Conversation

Jim8y
Copy link
Contributor

@Jim8y Jim8y commented Jan 23, 2024

Description

Since the reference check of neo vm consumes 17% of total execution time, we can avoid unnecessary reference check to optimize the performancce.

Fixes # (issue)

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Test Configuration:
Have updated the referencecount UT tests.

Now all tests passes

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@Jim8y
Copy link
Contributor Author

Jim8y commented Jan 23, 2024

@shargon this should have much better performance.

@Jim8y
Copy link
Contributor Author

Jim8y commented Jan 25, 2024

Benchmark result @shargon, before and after:

| Method        | Mean            | Error         | StdDev       |
|-------------- |----------------:|--------------:|-------------:|
| NeoIssue2528  | 2,112,928.48 us | 11,853.097 us | 9,897.873 us |
| NeoVMIssue418 |    67,766.64 us |    368.362 us |   307.599 us |
| NeoIssue2723  |        24.42 us |      0.432 us |     0.424 us |

| Method        | Mean         | Error      | StdDev    |
|-------------- |-------------:|-----------:|----------:|
| NeoIssue2528  | 21,474.12 us | 101.307 us | 84.596 us |
| NeoVMIssue418 |    826.69 us |   2.594 us |  2.299 us |
| NeoIssue2723  |     24.00 us |   0.150 us |  0.125 us |

@Jim8y
Copy link
Contributor Author

Jim8y commented Jan 25, 2024

Method Mean Error StdDev Gen0 Allocated
TestOthersDebugger NA NA NA NA NA
TestOthersStackItemLimits NA NA NA NA NA
TestOthersScriptLogic NA NA NA NA NA
TestOthersOtherCases NA NA NA NA NA
TestOthersInvocationLimits NA NA NA NA NA
TestOthersInit NA NA NA NA NA
TestOthersStackLimits NA NA NA NA NA
TestOpCodesArraysClearItems NA NA NA NA NA
TestOpCodesArraysPack 96,159.121 ns 160.7114 ns 134.2013 ns 0.3662 2880 B
TestOpCodesArraysNewArrayT 23.509 ns 0.0159 ns 0.0132 ns - -
TestOpCodesArraysPickItem 136,879.061 ns 231.1169 ns 216.1869 ns 0.4883 4160 B
TestOpCodesArraysPackStruct 96,072.181 ns 250.2072 ns 221.8022 ns 0.3662 2880 B
TestOpCodesArraysSetItem 96,630.636 ns 89.0291 ns 83.2779 ns 0.3662 2880 B
TestOpCodesArraysNewStruct0 3.195 ns 0.0020 ns 0.0017 ns - -
TestOpCodesArraysReverseItems 38,584.901 ns 54.2538 ns 48.0946 ns 0.1831 1152 B
TestOpCodesArraysNewMap 3.196 ns 0.0026 ns 0.0021 ns - -
TestOpCodesArraysHasKey 57,911.934 ns 104.0578 ns 92.2445 ns 0.2441 1856 B
TestOpCodesArraysNewArray 76,998.999 ns 137.5492 ns 121.9338 ns 0.3662 2304 B
TestOpCodesArraysKeys 19,298.016 ns 61.6505 ns 54.6515 ns 0.0916 680 B
TestOpCodesArraysAppend 38,508.735 ns 96.0288 ns 85.1270 ns 0.1831 1152 B
TestOpCodesArraysRemove 77,487.233 ns 118.9376 ns 105.4351 ns 0.3662 2432 B
TestOpCodesArraysPackMap 96,090.066 ns 264.3366 ns 220.7331 ns 0.3662 2880 B
TestOpCodesArraysValues 38,678.735 ns 89.8983 ns 79.6925 ns 0.1831 1256 B
TestOpCodesArraysNewArray0 2.937 ns 0.0017 ns 0.0015 ns - -
TestOpCodesArraysUnpack 38,800.123 ns 58.7801 ns 52.1070 ns 0.1831 1280 B
TestOpCodesArraysSize 38,599.630 ns 93.5074 ns 87.4669 ns 0.1831 1152 B
TestOpCodesArraysNewStruct 77,011.248 ns 190.6054 ns 168.9667 ns 0.3662 2304 B
TestOpCodesStackXDrop 38,153.117 ns 103.3951 ns 91.6571 ns 0.1831 1152 B
TestOpCodesStackReverseN 57,616.285 ns 115.1607 ns 102.0869 ns 0.2441 1728 B
TestOpCodesStackReverse4 18,996.855 ns 16.0876 ns 15.0483 ns 0.0916 576 B
TestOpCodesStackClear 5.321 ns 0.0045 ns 0.0037 ns - -
TestOpCodesStackReverse3 19,021.888 ns 45.2044 ns 37.7477 ns 0.0916 576 B
TestOpCodesStackRot 57,425.788 ns 170.5489 ns 151.1872 ns 0.2441 1728 B
TestOpCodesStackPick 76,658.765 ns 119.5652 ns 93.3486 ns 0.3662 2304 B
TestOpCodesStackNip 37,747.771 ns 171.9249 ns 143.5650 ns 0.1831 1152 B
TestOpCodesStackRoll 95,534.235 ns 143.0757 ns 133.8331 ns 0.3662 2880 B
TestOpCodesStackDepth 8.218 ns 0.0039 ns 0.0032 ns - -
TestOpCodesStackSwap 38,410.815 ns 130.6027 ns 109.0592 ns 0.1831 1152 B
TestOpCodesStackTuck 38,073.436 ns 88.2754 ns 73.7140 ns 0.1831 1264 B
TestOpCodesStackOver 37,956.650 ns 92.9477 ns 77.6155 ns 0.1831 1264 B
TestOpCodesStackDrop 19,173.877 ns 30.6989 ns 27.2138 ns 0.0916 576 B
TestOpCodesSlotStsFld6 38,386.010 ns 138.5389 ns 122.8111 ns 0.1831 1232 B
TestOpCodesSlotInitSlot 56,751.180 ns 369.8746 ns 327.8842 ns 0.1831 1411 B
TestOpCodesSlotLdLoc4 38,726.680 ns 100.2878 ns 83.7449 ns 0.1831 1232 B
TestOpCodesSlotLdArg 38,543.947 ns 111.0628 ns 98.4543 ns 0.1831 1232 B
TestOpCodesSlotStArg0 19,111.902 ns 27.1872 ns 24.1008 ns 0.0610 560 B
TestOpCodesSlotLdSFLD0 19,038.608 ns 30.0222 ns 25.0699 ns 0.0610 560 B
TestOpCodesSlotLdArg4 38,695.445 ns 38.9894 ns 32.5579 ns 0.1831 1232 B
TestOpCodesSlotLdArg5 38,470.214 ns 103.5018 ns 80.8074 ns 0.1831 1232 B
TestOpCodesSlotLdSFLD1 38,275.246 ns 80.5485 ns 71.4042 ns 0.1831 1232 B
TestOpCodesSlotLdLoc 38,228.195 ns 113.5758 ns 106.2389 ns 0.1831 1232 B
TestOpCodesSlotStArg1 38,537.004 ns 42.9775 ns 35.8882 ns 0.1831 1232 B
TestOpCodesSlotLdLoc5 38,225.942 ns 61.6624 ns 51.4909 ns 0.1831 1232 B
TestOpCodesSlotLdSFLD6 38,332.383 ns 130.2569 ns 115.4694 ns 0.1831 1232 B
TestOpCodesSlotLdArg2 38,390.612 ns 63.9874 ns 59.8539 ns 0.1831 1232 B
TestOpCodesSlotStsFld0 19,135.863 ns 38.9411 ns 36.4255 ns 0.0610 560 B
TestOpCodesSlotLdLoc2 38,588.118 ns 105.8119 ns 93.7995 ns 0.1831 1232 B
TestOpCodesSlotStArg6 38,483.324 ns 75.4034 ns 70.5324 ns 0.1831 1232 B
TestOpCodesSlotLdLoc3 38,092.052 ns 44.1167 ns 36.8394 ns 0.1831 1232 B
TestOpCodesSlotStsFld1 38,505.921 ns 66.9044 ns 52.2346 ns 0.1831 1232 B
TestOpCodesSlotInitSSlot 37,703.819 ns 74.2983 ns 65.8635 ns 0.1221 954 B
TestOpCodesSlotLdArg3 38,354.641 ns 85.5728 ns 75.8581 ns 0.1831 1232 B
TestOpCodesSlotLdSFLD 37,925.234 ns 61.4289 ns 51.2959 ns 0.1831 1232 B
TestOpCodesSlotLdArg0 19,028.919 ns 47.0856 ns 41.7401 ns 0.0610 560 B
TestOpCodesSlotLdSFLD4 38,371.176 ns 46.5118 ns 38.8395 ns 0.1831 1232 B
TestOpCodesSlotStArg4 38,498.513 ns 114.4164 ns 95.5429 ns 0.1831 1232 B
TestOpCodesSlotLdLoc0 19,132.484 ns 24.9633 ns 22.1293 ns 0.0610 560 B
TestOpCodesSlotStsFld2 38,458.223 ns 103.2609 ns 80.6193 ns 0.1831 1232 B
TestOpCodesSlotStsFld3 38,288.645 ns 91.6818 ns 71.5791 ns 0.1831 1232 B
TestOpCodesSlotLdLoc1 38,993.482 ns 164.1955 ns 137.1107 ns 0.1831 1232 B
TestOpCodesSlotStArg5 39,016.125 ns 107.7309 ns 95.5006 ns 0.1831 1232 B
TestOpCodesSlotLdSFLD5 38,816.884 ns 66.6087 ns 55.6213 ns 0.1831 1232 B
TestOpCodesSlotLdArg1 38,450.330 ns 65.4700 ns 54.6704 ns 0.1831 1232 B
TestOpCodesSlotStArg2 38,577.973 ns 205.1803 ns 160.1913 ns 0.1831 1232 B
TestOpCodesSlotLdLoc6 38,254.298 ns 75.7411 ns 63.2473 ns 0.1831 1232 B
TestOpCodesSlotStArg 38,463.103 ns 46.6591 ns 38.9624 ns 0.1831 1232 B
TestOpCodesSlotStsFld4 38,909.397 ns 84.5310 ns 65.9962 ns 0.1831 1232 B
TestOpCodesSlotLdArg6 38,916.096 ns 69.0665 ns 61.2256 ns 0.1831 1232 B
TestOpCodesSlotLdSFLD2 38,226.486 ns 82.5899 ns 73.2138 ns 0.1831 1232 B
TestOpCodesSlotLdSFLD3 38,778.380 ns 101.2407 ns 89.7472 ns 0.1831 1232 B
TestOpCodesSlotStLoc 38,315.617 ns 126.5788 ns 112.2088 ns 0.1831 1360 B
TestOpCodesSlotStsFld 38,490.572 ns 55.3521 ns 49.0682 ns 0.1831 1232 B
TestOpCodesSlotStsFld5 38,426.377 ns 71.2819 ns 59.5236 ns 0.1831 1232 B
TestOpCodesSlotStArg3 38,529.639 ns 55.6740 ns 52.0775 ns 0.1831 1232 B
TestOpCodesSpliceSubStr 173,790.812 ns 274.0109 ns 228.8115 ns 0.7324 5184 B
TestOpCodesSpliceCat 76,490.036 ns 115.9856 ns 96.8532 ns 0.3662 2304 B
TestOpCodesSpliceMemCpy 116,141.618 ns 999.2521 ns 834.4208 ns 0.4883 3456 B
TestOpCodesSpliceLeft 76,898.737 ns 237.8624 ns 198.6259 ns 0.3662 2304 B
TestOpCodesSpliceRight 77,154.808 ns 958.1023 ns 800.0588 ns 0.3662 2304 B
TestOpCodesSpliceNewBuffer 76,500.596 ns 226.2012 ns 188.8883 ns 0.3662 2304 B
TestOpCodesControlTryCatchFinally6 18,775.844 ns 355.0155 ns 277.1728 ns 0.0610 433 B
TestOpCodesControlJmpLeL 38,364.541 ns 76.6552 ns 67.9528 ns 0.1831 1152 B
TestOpCodesControlJmpEqL 38,228.306 ns 69.5693 ns 61.6714 ns 0.1831 1152 B
TestOpCodesControlJmpLe 38,160.088 ns 92.9401 ns 82.3890 ns 0.1831 1152 B
TestOpCodesControlJmpNe 38,149.201 ns 98.9009 ns 87.6730 ns 0.1831 1152 B
TestOpCodesControlTryCatchFinally7 18,662.044 ns 32.4359 ns 28.7536 ns 0.0610 433 B
TestOpCodesControlAssertMsg 19,610.452 ns 40.5285 ns 37.9104 ns 0.0916 576 B
TestOpCodesControlJmpGt 38,056.048 ns 109.9541 ns 97.4714 ns 0.1831 1152 B
TestOpCodesControlJmpL 38,330.389 ns 86.8597 ns 76.9989 ns 0.1831 1360 B
TestOpCodesControlJmpIfL 19,052.912 ns 30.9625 ns 27.4475 ns 0.0916 576 B
TestOpCodesControlTryFinally 18,531.563 ns 36.2155 ns 30.2416 ns 0.0305 344 B
TestOpCodesControlJmpNeL 38,121.276 ns 49.3823 ns 41.2364 ns 0.1831 1152 B
TestOpCodesControlJmpIfNot 19,072.218 ns 37.5661 ns 35.1393 ns 0.0916 576 B
TestOpCodesControlAbortMsg 19,681.030 ns 30.2501 ns 26.8160 ns 0.0916 576 B
TestOpCodesControlCall 39,666.888 ns 48.1725 ns 42.7036 ns 0.1831 1264 B
TestOpCodesControlCallL 39,880.973 ns 51.3774 ns 45.5448 ns 0.1831 1264 B
TestOpCodesControlJmpGeL 38,237.047 ns 65.2034 ns 54.4478 ns 0.1831 1152 B
TestOpCodesControlRet 2.947 ns 0.0015 ns 0.0012 ns - -
TestOpCodesControlJmpGtL 38,135.508 ns 66.4951 ns 58.9462 ns 0.1831 1152 B
TestOpCodesControlJmpEq 38,106.001 ns 65.2614 ns 57.8525 ns 0.1831 1152 B
TestOpCodesControlSysCall 94,836.846 ns 116.8518 ns 109.3032 ns 0.3662 3041 B
TestOpCodesControlCallA 19,083.756 ns 44.7367 ns 39.6580 ns 0.0916 688 B
TestOpCodesControlAssert 19,116.770 ns 27.5546 ns 25.7746 ns 0.0916 576 B
TestOpCodesControlTryCatchFinally2 3.047 ns 0.0055 ns 0.0048 ns - -
TestOpCodesControlTryCatchFinally3 3.032 ns 0.0027 ns 0.0024 ns - -
TestOpCodesControlNop 2.928 ns 0.0139 ns 0.0123 ns - -
TestOpCodesControlJmpGe 38,345.512 ns 71.9500 ns 56.1739 ns 0.1831 1152 B
TestOpCodesControlTryCatchFinally10 18,699.558 ns 161.5287 ns 134.8838 ns 0.0305 344 B
TestOpCodesControlJmpLt 38,369.703 ns 131.2910 ns 109.6340 ns 0.1831 1152 B
TestOpCodesControlJmpIf 19,329.938 ns 16.4788 ns 13.7606 ns 0.0916 576 B
TestOpCodesControlAbort 18,709.018 ns 40.5634 ns 33.8722 ns 0.0610 433 B
TestOpCodesControlJmpIfNotL 19,141.452 ns 30.5893 ns 27.1166 ns 0.0916 576 B
TestOpCodesControlTryCatch 8.383 ns 0.0072 ns 0.0057 ns - -
TestOpCodesControlTryCatchFinally4 3.089 ns 0.0032 ns 0.0028 ns - -
TestOpCodesControlJmp 38,440.009 ns 111.8139 ns 99.1201 ns 0.1831 1344 B
TestOpCodesControlTryCatchFinally8 18,843.638 ns 21.3101 ns 17.7949 ns 0.0305 344 B
TestOpCodesControlTryCatchFinally9 3.252 ns 0.0026 ns 0.0023 ns - -
TestOpCodesControlJmpLtL 38,572.772 ns 63.8797 ns 53.3424 ns 0.1831 1152 B
TestOpCodesControlTryCatchFinally 2.967 ns 0.0036 ns 0.0028 ns - -
TestOpCodesControlTryCatchFinally5 19,129.905 ns 69.7027 ns 58.2049 ns 0.0916 576 B
TestOpCodesControlThrow 19,032.999 ns 14.3384 ns 11.9733 ns 0.0916 576 B
TestOpCodesPushPushA 37,682.448 ns 33.4757 ns 31.3132 ns 0.1221 848 B
TestOpCodesPushPushM1ToPush16 2.997 ns 0.0056 ns 0.0050 ns - -
TestOpCodesPushPushInt8ToPushInt256 2.968 ns 0.0037 ns 0.0031 ns - -
TestOpCodesPushPushData1 19,297.164 ns 104.4991 ns 81.5860 ns 0.1221 800 B
TestOpCodesPushPushData2 19,395.485 ns 230.1127 ns 179.6569 ns 0.1221 800 B
TestOpCodesPushPushNull 2.984 ns 0.0130 ns 0.0115 ns - -
TestOpCodesPushPushData4 76,959.668 ns 247.6644 ns 219.5480 ns 0.4883 3185 B
TestOpCodesArithmeticGe 57,839.777 ns 107.2989 ns 89.5994 ns 0.2441 1728 B
TestOpCodesArithmeticLt 57,781.664 ns 128.2762 ns 107.1164 ns 0.2441 1728 B
TestOpCodesArithmeticModMul 19,464.562 ns 34.0245 ns 26.5641 ns 0.0916 576 B
TestOpCodesArithmeticNumNotEqual 212,414.660 ns 195.8718 ns 163.5619 ns 0.9766 6336 B
TestOpCodesArithmeticNot 19,271.983 ns 40.2337 ns 37.6347 ns 0.0916 576 B
TestOpCodesArithmeticModPow 19,316.428 ns 70.3232 ns 62.3396 ns 0.0916 576 B
TestOpCodesArithmeticLe 58,994.094 ns 1,093.5353 ns 913.1515 ns 0.2441 1728 B
TestOpCodesArithmeticShl 12.886 ns 0.0498 ns 0.0389 ns - -
TestOpCodesArithmeticGt 57,979.899 ns 113.1600 ns 94.4937 ns 0.2441 1728 B
TestOpCodesArithmeticPow 38,809.062 ns 230.8471 ns 192.7678 ns 0.1831 1152 B
TestOpCodesArithmeticNumEqual 214,391.082 ns 208.6684 ns 162.9146 ns 0.9766 6336 B
TestOpCodesArithmeticSign 96,487.545 ns 255.2416 ns 213.1383 ns 0.3662 2880 B
TestOpCodesArithmeticSqrt 19,262.133 ns 118.0621 ns 92.1751 ns 0.0916 576 B
TestOpCodesArithmeticShr 12.782 ns 0.0184 ns 0.0173 ns - -
TestOpCodesBitwiseLogicOr 134,245.572 ns 1,101.6771 ns 919.9503 ns 0.4883 4032 B
TestOpCodesBitwiseLogicEqual 38,413.623 ns 98.0403 ns 91.7070 ns 0.1831 1152 B
TestOpCodesBitwiseLogicInvert 115,535.974 ns 347.7152 ns 271.4732 ns 0.4883 3456 B
TestOpCodesBitwiseLogicXor 133,993.935 ns 202.6763 ns 179.6672 ns 0.4883 4032 B
TestOpCodesBitwiseLogicNotEqual 38,718.241 ns 129.7075 ns 108.3117 ns 0.1831 1152 B
TestOpCodesBitwiseLogicAnd 134,343.408 ns 154.9286 ns 129.3724 ns 0.4883 4032 B
TestOpCodesTypesConvert 156,399.159 ns 887.0135 ns 829.7130 ns 0.7324 4608 B
TestOpCodesTypesIsType 23.037 ns 0.1152 ns 0.0899 ns - -
TestOpCodesTypesIsNull 19,415.450 ns 28.2524 ns 23.5920 ns 0.0916 576 B

@Jim8y
Copy link
Contributor Author

Jim8y commented Jan 26, 2024

Method _blockId Mean Error StdDev Median
RunBlock 288842 138,072.38 us 1,170.349 us 1,094.746 us 138,228.71 us
RunBlock 288854 134,588.90 us 927.119 us 774.186 us 134,681.05 us
RunBlock 288856 140,153.02 us 1,079.913 us 1,010.151 us 140,135.22 us
RunBlock 288857 133,554.73 us 393.634 us 368.205 us 133,476.68 us
RunBlock 288858 66,027.39 us 331.541 us 310.124 us 66,028.79 us
RunBlock 470619 55,015.06 us 184.752 us 172.817 us 55,037.18 us
RunBlock 470619 55,077.83 us 300.836 us 251.211 us 55,031.21 us
RunBlock 715707 55,471.82 us 269.736 us 252.311 us 55,436.95 us
RunBlock 715707 55,586.27 us 219.600 us 205.414 us 55,573.48 us
RunBlock 1073113 4,963.39 us 33.525 us 27.995 us 4,957.39 us
RunBlock 1073120 5,019.32 us 86.425 us 96.061 us 4,986.78 us
RunBlock 1093317 1,632.11 us 7.397 us 6.177 us 1,632.27 us
RunBlock 1466600 661.16 us 1.613 us 1.430 us 661.07 us
RunBlock 1545151 3,423.67 us 66.305 us 68.090 us 3,391.23 us
RunBlock 1551539 39,308.86 us 734.745 us 651.333 us 39,105.07 us
RunBlock 1551550 37,855.05 us 707.932 us 1,258.349 us 37,837.41 us
RunBlock 1551551 47,419.55 us 341.787 us 285.408 us 47,445.85 us
RunBlock 1551552 69,778.46 us 1,183.306 us 1,048.970 us 69,355.32 us
RunBlock 1570420 3,786.18 us 24.155 us 22.595 us 3,783.45 us
RunBlock 1584313 58,236.04 us 345.609 us 306.373 us 58,133.39 us
RunBlock 1667870 42,613.22 us 229.463 us 214.640 us 42,672.57 us
RunBlock 1667871 42,389.42 us 390.021 us 364.826 us 42,389.84 us
RunBlock 1683031 661.19 us 2.971 us 2.779 us 661.09 us
RunBlock 1690032 4,321.50 us 16.773 us 14.869 us 4,322.98 us
RunBlock 1690810 7,597.33 us 43.522 us 40.710 us 7,604.46 us
RunBlock 1691179 62,061.27 us 532.887 us 498.463 us 62,180.77 us
RunBlock 1691180 44,588.30 us 187.126 us 156.259 us 44,614.09 us
RunBlock 1691181 27,642.74 us 91.181 us 85.291 us 27,651.46 us
RunBlock 1691492 5,045.13 us 28.037 us 26.226 us 5,039.02 us
RunBlock 1691562 3,261.60 us 12.928 us 12.093 us 3,261.99 us
RunBlock 1691721 5,158.21 us 46.579 us 41.291 us 5,152.70 us
RunBlock 1691783 4,769.85 us 23.955 us 21.236 us 4,774.92 us
RunBlock 1691784 5,530.31 us 14.992 us 14.024 us 5,524.41 us
RunBlock 1691811 7,372.55 us 18.015 us 15.970 us 7,375.12 us
RunBlock 1691968 3,114.40 us 13.870 us 12.295 us 3,110.32 us
RunBlock 1692023 6,870.11 us 13.171 us 10.283 us 6,872.33 us
RunBlock 1692102 8,345.34 us 48.089 us 42.630 us 8,330.54 us
RunBlock 1692302 3,638.23 us 22.644 us 21.181 us 3,634.99 us
RunBlock 1692680 2,923.63 us 5.566 us 5.207 us 2,922.62 us
RunBlock 1692682 5,977.65 us 18.723 us 14.618 us 5,977.22 us
RunBlock 1692692 3,609.94 us 34.636 us 32.399 us 3,598.27 us
RunBlock 1692735 3,428.15 us 8.838 us 7.835 us 3,426.87 us
RunBlock 1692772 4,718.97 us 32.030 us 28.394 us 4,720.05 us
RunBlock 1692921 4,284.67 us 25.118 us 22.266 us 4,283.00 us
RunBlock 1693099 4,190.39 us 31.475 us 27.901 us 4,188.68 us
RunBlock 1693100 2,897.98 us 10.275 us 9.109 us 2,898.87 us
RunBlock 1693182 11,922.73 us 37.117 us 34.719 us 11,919.63 us
RunBlock 1693194 3,784.10 us 21.897 us 19.411 us 3,786.58 us
RunBlock 1693241 5,703.24 us 19.604 us 18.338 us 5,708.86 us
RunBlock 1693269 8,964.62 us 36.381 us 34.031 us 8,959.12 us
RunBlock 1693274 7,674.84 us 30.092 us 26.676 us 7,678.77 us
RunBlock 1693286 6,352.32 us 23.674 us 19.769 us 6,356.66 us
RunBlock 1693294 9,397.18 us 25.096 us 20.956 us 9,400.29 us
RunBlock 1693308 5,160.42 us 33.942 us 30.089 us 5,159.66 us
RunBlock 1693343 5,582.53 us 20.986 us 17.524 us 5,579.28 us
RunBlock 1693373 2,607.12 us 13.343 us 12.481 us 2,604.56 us
RunBlock 1693398 4,059.40 us 31.019 us 27.497 us 4,059.64 us
RunBlock 1693399 3,210.26 us 11.675 us 9.749 us 3,212.32 us
RunBlock 1693428 4,104.36 us 16.687 us 14.792 us 4,103.89 us
RunBlock 1693650 3,686.52 us 17.718 us 15.706 us 3,684.77 us
RunBlock 1694343 3,268.78 us 12.183 us 11.396 us 3,266.76 us
RunBlock 1694410 3,223.65 us 9.516 us 8.436 us 3,224.39 us
RunBlock 1694594 2,039.27 us 11.139 us 10.419 us 2,040.23 us
RunBlock 1695163 3,648.82 us 8.649 us 7.667 us 3,648.18 us
RunBlock 1695746 3,214.65 us 8.561 us 8.008 us 3,213.66 us
RunBlock 1695896 8,124.88 us 19.038 us 17.809 us 8,127.02 us
RunBlock 1696740 3,107.25 us 16.961 us 15.866 us 3,104.57 us
RunBlock 1696758 51,077.07 us 387.180 us 362.169 us 50,925.11 us
RunBlock 1696759 67,120.95 us 278.214 us 246.629 us 67,082.69 us
RunBlock 1723984 4,581.10 us 30.387 us 28.424 us 4,575.16 us
RunBlock 1855694 3,304.39 us 18.025 us 15.052 us 3,309.86 us
RunBlock 1855827 4,050.20 us 22.417 us 20.969 us 4,054.74 us
RunBlock 1882087 7,748.41 us 33.217 us 31.071 us 7,751.30 us
RunBlock 1882106 10,177.22 us 50.343 us 44.628 us 10,187.93 us
RunBlock 1899635 1,676.93 us 6.250 us 5.219 us 1,678.26 us
RunBlock 1900762 6,816.76 us 42.861 us 37.995 us 6,810.82 us
RunBlock 1900767 5,169.33 us 81.038 us 79.590 us 5,137.80 us
RunBlock 1900768 4,874.95 us 97.256 us 75.931 us 4,842.96 us
RunBlock 1900845 5,741.58 us 22.891 us 19.115 us 5,744.82 us
RunBlock 1907366 5,532.58 us 39.357 us 36.814 us 5,526.83 us
RunBlock 1941906 6,907.36 us 17.827 us 16.676 us 6,910.69 us
RunBlock 1952842 9,218.03 us 153.061 us 135.685 us 9,180.36 us
RunBlock 1955263 87,925.83 us 1,302.402 us 1,218.267 us 87,601.31 us
RunBlock 1955515 6,742.22 us 28.646 us 23.921 us 6,744.20 us
RunBlock 1976901 92.84 us 0.365 us 0.341 us 92.79 us
RunBlock 1976901 93.37 us 0.411 us 0.385 us 93.29 us
RunBlock 1991342 2,409.35 us 10.006 us 8.356 us 2,406.47 us
RunBlock 2027305 454.14 us 1.729 us 1.617 us 454.11 us
RunBlock 2037494 2,383.63 us 12.646 us 11.829 us 2,378.58 us
RunBlock 2080810 2,797.44 us 16.737 us 14.837 us 2,792.23 us
RunBlock 2116627 523.61 us 2.442 us 2.284 us 523.78 us
RunBlock 2137993 1,039.10 us 2.593 us 2.298 us 1,038.59 us
RunBlock 2141425 1,263.03 us 6.445 us 6.029 us 1,261.84 us
RunBlock 2141551 2,256.08 us 13.514 us 11.979 us 2,253.05 us
RunBlock 2158835 1,300.13 us 4.425 us 3.923 us 1,301.33 us
RunBlock 2171359 959.69 us 5.190 us 4.601 us 957.63 us
RunBlock 2173910 151.75 us 0.498 us 0.465 us 151.69 us
RunBlock 2194622 1,209.82 us 8.490 us 7.526 us 1,209.10 us
RunBlock 2212206 17,813.47 us 52.758 us 41.190 us 17,817.07 us
RunBlock 2212212 17,449.21 us 133.802 us 125.158 us 17,433.66 us
RunBlock 2212242 24,789.82 us 121.513 us 113.663 us 24,768.93 us
RunBlock 2212242 25,066.29 us 130.074 us 121.671 us 25,039.33 us
RunBlock 2212261 13,996.33 us 55.868 us 49.526 us 13,994.39 us
RunBlock 2212278 22,997.61 us 457.530 us 526.892 us 23,022.62 us
RunBlock 2212278 22,699.85 us 299.760 us 265.729 us 22,634.47 us
RunBlock 2212440 22,914.14 us 192.584 us 170.720 us 22,891.95 us
RunBlock 2212440 22,866.97 us 128.074 us 119.801 us 22,879.18 us
RunBlock 2212454 21,965.22 us 152.929 us 135.567 us 21,945.58 us
RunBlock 2212544 33,498.42 us 268.560 us 209.674 us 33,537.72 us
RunBlock 2212544 33,727.12 us 486.043 us 454.645 us 33,570.14 us
RunBlock 2212575 33,375.47 us 385.592 us 321.986 us 33,275.57 us
RunBlock 2212575 33,797.07 us 386.884 us 323.066 us 33,900.80 us
RunBlock 2212681 67,470.62 us 1,331.344 us 1,731.123 us 66,863.07 us
RunBlock 2212681 45,047.26 us 263.183 us 233.305 us 45,048.55 us
RunBlock 2212706 48,440.87 us 392.841 us 348.243 us 48,417.84 us
RunBlock 2212723 23,366.72 us 399.984 us 374.145 us 23,285.79 us
RunBlock 2212723 24,172.59 us 471.907 us 504.935 us 24,308.78 us
RunBlock 2212800 24,134.16 us 471.570 us 774.804 us 24,016.01 us
RunBlock 2212800 23,319.29 us 145.117 us 121.179 us 23,295.82 us
RunBlock 2212807 24,152.40 us 470.662 us 542.015 us 24,254.98 us
RunBlock 2212833 24,127.78 us 467.004 us 590.610 us 23,910.96 us
RunBlock 2212833 34,843.55 us 533.375 us 445.392 us 34,830.47 us
RunBlock 2230072 1,347.96 us 16.984 us 15.887 us 1,346.96 us
RunBlock 2268049 849.24 us 16.639 us 19.161 us 843.95 us
RunBlock 2351614 780.57 us 15.161 us 17.460 us 777.77 us
RunBlock 2363914 1,819.63 us 13.157 us 10.986 us 1,817.29 us
RunBlock 2398019 24,666.13 us 194.543 us 172.457 us 24,640.05 us
RunBlock 2398072 47,020.10 us 803.581 us 751.670 us 46,998.68 us
RunBlock 2501961 768.94 us 12.940 us 11.471 us 769.96 us
RunBlock 2508698 32,833.03 us 656.189 us 1,216.289 us 32,273.61 us
RunBlock 2655903 5,951.55 us 101.724 us 117.145 us 5,918.45 us
RunBlock 2692530 48,007.81 us 283.604 us 236.822 us 48,016.58 us
RunBlock 3053852 31,243.93 us 220.423 us 195.400 us 31,234.90 us
RunBlock 4222547 50.76 us 0.681 us 0.604 us 50.79 us
RunBlock 4229846 29,154.95 us 365.393 us 305.119 us 29,180.76 us

@Jim8y
Copy link
Contributor Author

Jim8y commented Jan 26, 2024

Now we have a comparision, #3108 (comment) is the bench before this pr change, above is the benchmark after this pr change.

@Jim8y
Copy link
Contributor Author

Jim8y commented Jan 26, 2024

<style> </style>
_blockId Mean Mean  
288842 138,072.38 171,039.48 19.27%
288854 134,588.90 172,037.83 21.77%
288856 140,153.02 173,519.63 19.23%
288857 133,554.73 171,658.98 22.20%
288858 66,027.39 84,689.63 22.04%
470619 55,015.06 58,467.03 5.90%
470619 55,077.83 58,846.63 6.40%
715707 55,471.82 59,298.11 6.45%
715707 55,586.27 59,145.30 6.02%
1073113 4,963.39 4,941.38 -0.45%
1073120 5,019.32 4,987.47 -0.64%
1093317 1,632.11 1,739.68 6.18%
1466600 661.16 679.34 2.68%
1545151 3,423.67 3,469.45 1.32%
1551539 39,308.86 40,128.89 2.04%
1551550 37,855.05 36,566.93 -3.52%
1551551 47,419.55 36,141.94 -31.20%
1551552 69,778.46 72,352.18 3.56%
1570420 3,786.18 3,867.40 2.10%
1584313 58,236.04 79,829.37 27.05%
1667870 42,613.22 43,621.90 2.31%
1667871 42,389.42 42,972.70 1.36%
1683031 661.19 691.87 4.43%
1690032 4,321.50 4,421.11 2.25%
1690810 7,597.33 7,866.64 3.42%
1691179 62,061.27 63,170.35 1.76%
1691180 44,588.30 45,363.66 1.71%
1691181 27,642.74 39,268.71 29.61%
1691492 5,045.13 5,146.63 1.97%
1691562 3,261.60 3,365.74 3.09%
1691721 5,158.21 5,426.79 4.95%
1691783 4,769.85 4,920.97 3.07%
1691784 5,530.31 5,769.61 4.15%
1691811 7,372.55 7,598.98 2.98%
1691968 3,114.40 3,388.26 8.08%
1692023 6,870.11 7,089.55 3.10%
1692102 8,345.34 8,562.59 2.54%
1692302 3,638.23 3,921.21 7.22%
1692680 2,923.63 2,970.85 1.59%
1692682 5,977.65 6,107.17 2.12%
1692692 3,609.94 3,699.43 2.42%
1692735 3,428.15 3,570.83 4.00%
1692772 4,718.97 4,870.48 3.11%
1692921 4,284.67 4,416.63 2.99%
1693099 4,190.39 4,292.45 2.38%
1693100 2,897.98 3,004.86 3.56%
1693182 11,922.73 12,398.93 3.84%
1693194 3,784.10 3,905.12 3.10%
1693241 5,703.24 5,878.40 2.98%
1693269 8,964.62 9,201.10 2.57%
1693274 7,674.84 7,814.06 1.78%
1693286 6,352.32 6,689.36 5.04%
1693294 9,397.18 9,787.84 3.99%
1693308 5,160.42 5,245.27 1.62%
1693343 5,582.53 5,817.15 4.03%
1693373 2,607.12 2,653.35 1.74%
1693398 4,059.40 4,197.73 3.30%
1693399 3,210.26 3,349.91 4.17%
1693428 4,104.36 4,196.28 2.19%
1693650 3,686.52 3,897.83 5.42%
1694343 3,268.78 3,339.81 2.13%
1694410 3,223.65 3,368.28 4.29%
1694594 2,039.27 2,107.43 3.23%
1695163 3,648.82 3,762.68 3.03%
1695746 3,214.65 3,311.74 2.93%
1695896 8,124.88 8,356.81 2.78%
1696740 3,107.25 3,258.82 4.65%
1696758 51,077.07 51,517.44 0.85%
1696759 67,120.95 69,864.07 3.93%
1723984 4,581.10 4,685.82 2.23%
1855694 3,304.39 3,535.55 6.54%
1855827 4,050.20 4,199.66 3.56%
1882087 7,748.41 7,930.80 2.30%
1882106 10,177.22 10,390.62 2.05%
1899635 1,676.93 1,720.38 2.53%
1900762 6,816.76 6,973.64 2.25%
1900767 5,169.33 5,228.03 1.12%
1900768 4,874.95 4,910.23 0.72%
1900845 5,741.58 5,879.98 2.35%
1907366 5,532.58 5,671.58 2.45%
1941906 6,907.36 7,306.30 5.46%
1952842 9,218.03 9,365.22 1.57%
1955263 87,925.83 86,541.97 -1.60%
1955515 6,742.22 7,022.05 3.99%
1976901 92.84 93.24 0.43%
1976901 93.37 92.88 -0.53%
1991342 2,409.35 2,426.50 0.71%
2027305 454.14 486.6 6.67%
2037494 2,383.63 2,436.23 2.16%
2080810 2,797.44 2,783.88 -0.49%
2116627 523.61 533.59 1.87%
2137993 1,039.10 1,056.17 1.62%
2141425 1,263.03 1,357.55 6.96%
2141551 2,256.08 2,365.64 4.63%
2158835 1,300.13 1,345.29 3.36%
2171359 959.69 981.88 2.26%
2173910 151.75 153.2 0.95%
2194622 1,209.82 1,265.40 4.39%
2212206 17,813.47 18,358.81 2.97%
2212212 17,449.21 17,438.71 -0.06%
2212242 24,789.82 25,124.72 1.33%
2212242 25,066.29 24,865.63 -0.81%
2212261 13,996.33 14,760.83 5.18%
2212278 22,997.61 22,889.89 -0.47%
2212278 22,699.85 23,033.16 1.45%
2212440 22,914.14 23,656.93 3.14%
2212440 22,866.97 23,627.42 3.22%
2212454 21,965.22 22,416.27 2.01%
2212544 33,498.42 33,278.06 -0.66%
2212544 33,727.12 33,285.16 -1.33%
2212575 33,375.47 33,824.69 1.33%
2212575 33,797.07 33,998.52 0.59%
2212681 67,470.62 45,675.58 -47.72%
2212681 45,047.26 67,040.36 32.81%
2212706 48,440.87 48,598.08 0.32%
2212723 23,366.72 23,430.01 0.27%
2212723 24,172.59 23,748.91 -1.78%
2212800 24,134.16 23,682.75 -1.91%
2212800 23,319.29 23,751.40 1.82%
2212807 24,152.40 23,975.44 -0.74%
2212833 24,127.78 24,229.67 0.42%
2212833 34,843.55 35,471.56 1.77%
2230072 1,347.96 1,333.59 -1.08%
2268049 849.24 872.6 2.68%
2351614 780.57 774.4 -0.80%
2363914 1,819.63 1,993.98 8.74%
2398019 24,666.13 35,327.16 30.18%
2398072 47,020.10 41,127.87 -14.33%
2501961 768.94 566.76 -35.67%
2508698 32,833.03 32,638.17 -0.60%
2655903 5,951.55 5,862.38 -1.52%
2692530 48,007.81 83,346.31 42.40%
3053852 31,243.93 30,989.33 -0.82%
4222547 50.76 54.36 6.62%
4229846 29,154.95 31,076.64 6.18%

@superboyiii
Copy link
Member

@shargon Could you make a review? It looks good, at least from the test result.

@Jim8y
Copy link
Contributor Author

Jim8y commented Feb 3, 2024

@shargon Please review, 10-20 times faster for complex tasks.

Before this pr:

Benchmark: NeoIssue2528, Time: 00:00:02.3830927
Benchmark: NeoVMIssue418, Time: 00:00:00.0887476
Benchmark: NeoIssue2723, Time: 00:00:00.0002145

After this pr:
Benchmark: NeoIssue2528, Time: 00:00:00.1766972
Benchmark: NeoVMIssue418, Time: 00:00:00.0047387
Benchmark: NeoIssue2723, Time: 00:00:00.0001797

@@ -1681,6 +1681,7 @@ public StackItem Pop()
/// </summary>
protected virtual void PostExecuteInstruction(Instruction instruction)
{
if (ReferenceCounter.Count < Limits.MaxStackSize) return;
if (ReferenceCounter.CheckZeroReferred() > Limits.MaxStackSize)
throw new InvalidOperationException($"MaxStackSize exceed: {ReferenceCounter.Count}");
Copy link
Member

Choose a reason for hiding this comment

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

Does we have a ut that test this exception?

Copy link
Contributor Author

@Jim8y Jim8y Feb 7, 2024

Choose a reason for hiding this comment

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

not a thing for this pr. Its jus keeps conflict and conflic and conflic, please stop considering none pr issues. A single line pr should not take so long to review.

Copy link
Member

Choose a reason for hiding this comment

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

If you want to trust that this single line doesn't break anything, you must ensure that it works, so yes, this is a thing for this pr.

Copy link
Member

Choose a reason for hiding this comment

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

It should break things. It a limit of the vm.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, VM has its limitatoins. 2G at most actally.

Copy link
Member

Choose a reason for hiding this comment

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

I dont mean in a bad way.

* master:
  Related to neo-project#3082 (comment) (neo-project#3119)
  [VM UT] update UT name (neo-project#3115)
  Neo as dotnet standard (neo-project#3082)
  Fix ut (neo-project#3113)
@Jim8y
Copy link
Contributor Author

Jim8y commented Feb 7, 2024

@cschuchardt88 @shargon @superboyiii Please review. This is a single line pr, how come it takes so long to review?

Copy link
Member

@shargon shargon left a comment

Choose a reason for hiding this comment

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

LGTM

@shargon
Copy link
Member

shargon commented Feb 7, 2024

Very good optimization @Jim8y, congratulations!

@shargon shargon merged commit 76c368e into neo-project:master Feb 7, 2024
1 of 2 checks passed
@Jim8y Jim8y deleted the optimize-vm branch February 7, 2024 18:14
@roman-khimov roman-khimov added this to the v3.7.0 milestone Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants