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

Set: comparer optimization #10861

Closed
wants to merge 15 commits into from
Closed

Set: comparer optimization #10861

wants to merge 15 commits into from

Conversation

buybackoff
Copy link
Contributor

Same as #10855

The job Main50 includes previous PR

Method Job BuildConfiguration Size Mean Error StdDev Ratio RatioSD Rank Gen 0 Gen 1 Gen 2 Allocated
containsKeyInt After After 100 21.14 ns 0.779 ns 0.121 ns 1.00 0.00 1 - - - -
containsKeyInt Main50 Main50 100 28.95 ns 1.199 ns 0.311 ns 1.37 0.02 2 - - - -
containsKeyInt NuGet50 NuGet50 100 46.82 ns 1.132 ns 0.175 ns 2.21 0.02 3 - - - -
containsKeyIntLike After After 100 59.67 ns 1.831 ns 0.476 ns 1.00 0.00 1 - - - -
containsKeyIntLike Main50 Main50 100 248.88 ns 5.699 ns 1.480 ns 4.17 0.05 2 0.0525 - - 331 B
containsKeyIntLike NuGet50 NuGet50 100 257.99 ns 3.747 ns 0.973 ns 4.32 0.03 3 0.0526 - - 331 B
containsKeyString After After 100 53.97 ns 2.617 ns 0.680 ns 1.00 0.00 2 - - - -
containsKeyString Main50 Main50 100 43.48 ns 2.182 ns 0.567 ns 0.81 0.01 1 - - - -
containsKeyString NuGet50 NuGet50 100 73.30 ns 2.800 ns 0.727 ns 1.36 0.01 3 - - - -
containsKeyRefLike After After 100 146.72 ns 10.741 ns 2.789 ns 1.00 0.00 1 - - - -
containsKeyRefLike Main50 Main50 100 229.40 ns 5.506 ns 0.852 ns 1.56 0.03 2 - - - -
containsKeyRefLike NuGet50 NuGet50 100 249.09 ns 10.063 ns 1.557 ns 1.69 0.03 3 - - - -
containsKeyIntRecord After After 100 102.18 ns 2.399 ns 0.623 ns 1.00 0.00 1 - - - -
containsKeyIntRecord Main50 Main50 100 233.32 ns 8.690 ns 1.345 ns 2.28 0.03 2 0.0526 - - 331 B
containsKeyIntRecord NuGet50 NuGet50 100 237.66 ns 8.665 ns 2.250 ns 2.33 0.01 2 0.0519 - - 331 B
containsKeyIntRefRecord After After 100 153.52 ns 1.265 ns 0.329 ns 1.00 0.00 1 - - - -
containsKeyIntRefRecord Main50 Main50 100 204.53 ns 6.879 ns 1.064 ns 1.33 0.01 2 - - - -
containsKeyIntRefRecord NuGet50 NuGet50 100 218.81 ns 4.612 ns 1.198 ns 1.43 0.00 3 - - - -
containsKeyIntLikeNonGenCmp After After 100 94.30 ns 3.296 ns 0.856 ns 1.00 0.00 1 0.0262 - - 166 B
containsKeyIntLikeNonGenCmp Main50 Main50 100 238.60 ns 3.182 ns 0.826 ns 2.53 0.02 2 0.0524 - - 331 B
containsKeyIntLikeNonGenCmp NuGet50 NuGet50 100 240.68 ns 13.277 ns 2.055 ns 2.56 0.03 2 0.0521 - - 331 B
containsKeyRefLikeNonGenCmp After After 100 182.53 ns 1.547 ns 0.239 ns 1.00 0.00 1 - - - -
containsKeyRefLikeNonGenCmp Main50 Main50 100 231.61 ns 5.116 ns 0.792 ns 1.27 0.00 2 - - - -
containsKeyRefLikeNonGenCmp NuGet50 NuGet50 100 259.06 ns 30.456 ns 4.713 ns 1.42 0.02 3 - - - -
itemCountInt After After 100 246.34 ns 6.113 ns 1.588 ns 1.00 0.00 1 - - - -
itemCountInt Main50 Main50 100 245.57 ns 9.633 ns 1.491 ns 1.00 0.01 1 - - - -
itemCountInt NuGet50 NuGet50 100 504.93 ns 23.024 ns 5.979 ns 2.05 0.02 2 - - - -
itemCountIntLike After After 100 248.94 ns 11.787 ns 3.061 ns 1.00 0.00 1 - - - -
itemCountIntLike Main50 Main50 100 247.55 ns 3.088 ns 0.802 ns 0.99 0.01 1 - - - -
itemCountIntLike NuGet50 NuGet50 100 511.33 ns 24.590 ns 6.386 ns 2.05 0.03 2 - - - -
itemCountString After After 100 220.37 ns 5.541 ns 1.439 ns 1.00 0.00 1 - - - -
itemCountString Main50 Main50 100 275.03 ns 101.002 ns 26.230 ns 1.25 0.13 2 - - - -
itemCountString NuGet50 NuGet50 100 656.19 ns 39.166 ns 10.171 ns 2.98 0.06 3 - - - -
itemCountRefLike After After 100 223.71 ns 10.711 ns 1.658 ns 1.00 0.00 1 - - - -
itemCountRefLike Main50 Main50 100 232.75 ns 44.043 ns 6.816 ns 1.04 0.03 2 - - - -
itemCountRefLike NuGet50 NuGet50 100 597.86 ns 7.059 ns 1.092 ns 2.67 0.02 3 - - - -
itemCountIntRecord After After 100 246.47 ns 4.839 ns 0.749 ns 1.00 0.00 1 - - - -
itemCountIntRecord Main50 Main50 100 251.68 ns 5.412 ns 1.405 ns 1.02 0.01 2 - - - -
itemCountIntRecord NuGet50 NuGet50 100 512.38 ns 16.553 ns 4.299 ns 2.07 0.02 3 - - - -
itemCountIntRefRecord After After 100 223.56 ns 7.727 ns 2.007 ns 1.00 0.00 1 - - - -
itemCountIntRefRecord Main50 Main50 100 234.66 ns 23.713 ns 6.158 ns 1.05 0.03 2 - - - -
itemCountIntRefRecord NuGet50 NuGet50 100 590.23 ns 11.160 ns 2.898 ns 2.64 0.03 3 - - - -
itemCountIntLikeNonGenCmp After After 100 246.00 ns 3.057 ns 0.794 ns 1.00 0.00 1 - - - -
itemCountIntLikeNonGenCmp Main50 Main50 100 252.91 ns 33.318 ns 5.156 ns 1.03 0.02 1 - - - -
itemCountIntLikeNonGenCmp NuGet50 NuGet50 100 508.31 ns 14.288 ns 3.710 ns 2.07 0.01 2 - - - -
itemCountRefLikeNonGenCmp After After 100 227.10 ns 25.343 ns 3.922 ns 1.00 0.00 1 - - - -
itemCountRefLikeNonGenCmp Main50 Main50 100 229.97 ns 17.960 ns 4.664 ns 1.01 0.01 1 - - - -
itemCountRefLikeNonGenCmp NuGet50 NuGet50 100 589.75 ns 20.821 ns 3.222 ns 2.60 0.03 2 - - - -
maximumElementInt After After 100 17.88 ns 0.358 ns 0.055 ns 1.00 0.00 1 0.0042 - - 26 B
maximumElementInt Main50 Main50 100 18.23 ns 0.739 ns 0.114 ns 1.02 0.00 2 0.0041 - - 26 B
maximumElementInt NuGet50 NuGet50 100 40.90 ns 1.787 ns 0.464 ns 2.28 0.02 3 0.0041 - - 26 B
maximumElementIntLike After After 100 18.44 ns 0.296 ns 0.077 ns 1.00 0.00 1 0.0042 - - 26 B
maximumElementIntLike Main50 Main50 100 19.00 ns 1.713 ns 0.265 ns 1.03 0.01 2 0.0041 - - 26 B
maximumElementIntLike NuGet50 NuGet50 100 40.59 ns 1.399 ns 0.363 ns 2.20 0.02 3 0.0041 - - 26 B
maximumElementString After After 100 27.09 ns 0.640 ns 0.166 ns 1.00 0.00 1 0.0041 - - 26 B
maximumElementString Main50 Main50 100 28.31 ns 0.553 ns 0.086 ns 1.04 0.01 2 0.0041 - - 26 B
maximumElementString NuGet50 NuGet50 100 61.37 ns 0.794 ns 0.123 ns 2.26 0.01 3 0.0040 - - 26 B
maximumElementRefLike After After 100 26.51 ns 1.453 ns 0.377 ns 1.00 0.00 1 0.0041 - - 26 B
maximumElementRefLike Main50 Main50 100 27.01 ns 0.422 ns 0.110 ns 1.02 0.02 1 0.0041 - - 26 B
maximumElementRefLike NuGet50 NuGet50 100 55.84 ns 3.147 ns 0.817 ns 2.11 0.05 2 0.0041 - - 26 B
maximumElementIntRecord After After 100 19.60 ns 1.537 ns 0.238 ns 1.00 0.00 1 0.0042 - - 26 B
maximumElementIntRecord Main50 Main50 100 20.40 ns 0.529 ns 0.137 ns 1.04 0.01 2 0.0042 - - 26 B
maximumElementIntRecord NuGet50 NuGet50 100 42.66 ns 0.841 ns 0.218 ns 2.18 0.02 3 0.0040 - - 26 B
maximumElementIntRefRecord After After 100 25.98 ns 0.350 ns 0.091 ns 1.00 0.00 1 0.0042 - - 26 B
maximumElementIntRefRecord Main50 Main50 100 27.13 ns 1.662 ns 0.432 ns 1.04 0.02 2 0.0042 - - 26 B
maximumElementIntRefRecord NuGet50 NuGet50 100 55.47 ns 3.145 ns 0.817 ns 2.14 0.04 3 0.0042 - - 26 B
maximumElementIntLikeNonGenCmp After After 100 18.59 ns 0.261 ns 0.068 ns 1.00 0.00 1 0.0041 - - 26 B
maximumElementIntLikeNonGenCmp Main50 Main50 100 18.78 ns 1.821 ns 0.473 ns 1.01 0.02 1 0.0041 - - 26 B
maximumElementIntLikeNonGenCmp NuGet50 NuGet50 100 40.25 ns 0.616 ns 0.160 ns 2.17 0.01 2 0.0040 - - 26 B
maximumElementRefLikeNonGenCmp After After 100 25.94 ns 0.787 ns 0.122 ns 1.00 0.00 1 0.0042 - - 26 B
maximumElementRefLikeNonGenCmp Main50 Main50 100 26.39 ns 1.779 ns 0.275 ns 1.02 0.01 2 0.0041 - - 26 B
maximumElementRefLikeNonGenCmp NuGet50 NuGet50 100 55.08 ns 1.256 ns 0.326 ns 2.12 0.02 3 0.0042 - - 26 B
subsetInt After After 100 2,051.29 ns 35.383 ns 5.475 ns 1.00 0.00 1 - - - 24 B
subsetInt Main50 Main50 100 3,498.46 ns 372.447 ns 96.723 ns 1.70 0.05 2 - - - 32 B
subsetInt NuGet50 NuGet50 100 5,202.80 ns 254.615 ns 39.402 ns 2.54 0.02 3 - - - 32 B
subsetIntLike After After 100 6,212.42 ns 118.741 ns 18.375 ns 1.00 0.00 1 - - - 24 B
subsetIntLike Main50 Main50 100 23,036.75 ns 762.015 ns 117.923 ns 3.71 0.02 2 4.4643 - - 28304 B
subsetIntLike NuGet50 NuGet50 100 23,672.89 ns 1,304.249 ns 201.834 ns 3.81 0.03 3 4.4643 - - 28304 B
subsetString After After 100 7,616.72 ns 670.060 ns 174.012 ns 1.00 0.00 2 - - - 24 B
subsetString Main50 Main50 100 6,297.17 ns 572.451 ns 88.587 ns 0.83 0.02 1 - - - 32 B
subsetString NuGet50 NuGet50 100 11,107.61 ns 679.342 ns 176.423 ns 1.46 0.04 3 - - - 32 B
subsetRefLike After After 100 14,694.03 ns 1,003.062 ns 260.492 ns 1.00 0.00 1 - - - 24 B
subsetRefLike Main50 Main50 100 21,880.39 ns 1,480.699 ns 229.140 ns 1.50 0.01 2 - - - 32 B
subsetRefLike NuGet50 NuGet50 100 23,467.05 ns 362.949 ns 94.257 ns 1.60 0.03 3 - - - 32 B
subsetIntRecord After After 100 9,933.68 ns 748.450 ns 194.370 ns 1.00 0.00 1 - - - 24 B
subsetIntRecord Main50 Main50 100 22,088.66 ns 1,598.081 ns 415.017 ns 2.22 0.07 2 4.4386 - - 28304 B
subsetIntRecord NuGet50 NuGet50 100 22,824.28 ns 366.871 ns 95.275 ns 2.30 0.04 3 4.4158 - - 28304 B
subsetIntRefRecord After After 100 15,277.12 ns 1,171.248 ns 181.252 ns 1.00 0.00 1 - - - 24 B
subsetIntRefRecord Main50 Main50 100 19,046.62 ns 4,661.956 ns 721.443 ns 1.25 0.04 2 - - - 32 B
subsetIntRefRecord NuGet50 NuGet50 100 21,030.96 ns 1,166.956 ns 180.588 ns 1.38 0.02 3 - - - 32 B
subsetIntLikeNonGenCmp After After 100 10,238.06 ns 1,185.034 ns 183.385 ns 1.00 0.00 1 2.2549 - - 14160 B
subsetIntLikeNonGenCmp Main50 Main50 100 22,550.10 ns 639.132 ns 165.981 ns 2.21 0.03 2 4.4964 - - 28304 B
subsetIntLikeNonGenCmp NuGet50 NuGet50 100 23,215.94 ns 1,003.751 ns 260.671 ns 2.27 0.05 3 4.4561 - - 28304 B
subsetRefLikeNonGenCmp After After 100 17,748.72 ns 2,141.129 ns 556.044 ns 1.00 0.00 1 - - - 24 B
subsetRefLikeNonGenCmp Main50 Main50 100 21,749.73 ns 809.943 ns 125.340 ns 1.22 0.04 2 - - - 32 B
subsetRefLikeNonGenCmp NuGet50 NuGet50 100 23,310.08 ns 701.306 ns 182.127 ns 1.31 0.04 3 - - - 32 B
iterForeachInt After After 100 2,882.68 ns 86.863 ns 22.558 ns 1.00 0.00 1 0.9613 - - 6120 B
iterForeachInt Main50 Main50 100 2,866.85 ns 31.590 ns 4.889 ns 1.00 0.01 1 0.9687 - - 6120 B
iterForeachInt NuGet50 NuGet50 100 3,734.34 ns 127.105 ns 33.009 ns 1.30 0.01 2 0.9711 - - 6120 B
iterForeachIntLike After After 100 2,968.21 ns 164.854 ns 25.511 ns 1.00 0.00 1 1.0268 - - 6520 B
iterForeachIntLike Main50 Main50 100 2,932.10 ns 234.194 ns 60.820 ns 0.99 0.02 1 1.0376 - - 6520 B
iterForeachIntLike NuGet50 NuGet50 100 4,012.36 ns 1,041.075 ns 270.364 ns 1.36 0.09 2 0.9700 - - 6120 B
iterForeachString After After 100 4,063.74 ns 193.425 ns 50.232 ns 1.00 0.00 1 1.0545 - - 6648 B
iterForeachString Main50 Main50 100 4,029.88 ns 733.674 ns 190.533 ns 0.99 0.05 1 1.0582 - - 6648 B
iterForeachString NuGet50 NuGet50 100 7,417.41 ns 7,389.587 ns 1,919.052 ns 1.82 0.45 2 0.9717 - - 6240 B
iterForeachRefLike After After 100 3,828.63 ns 248.600 ns 64.561 ns 1.00 0.00 1 1.0317 - - 6520 B
iterForeachRefLike Main50 Main50 100 3,904.19 ns 112.273 ns 29.157 ns 1.02 0.02 1 1.0265 - - 6520 B
iterForeachRefLike NuGet50 NuGet50 100 5,668.76 ns 311.854 ns 48.260 ns 1.49 0.04 2 0.9582 - - 6120 B
iterForeachIntRecord After After 100 3,050.29 ns 366.091 ns 95.073 ns 1.00 0.00 2 1.0303 - - 6520 B
iterForeachIntRecord Main50 Main50 100 2,885.37 ns 48.793 ns 12.672 ns 0.95 0.03 1 1.0370 - - 6520 B
iterForeachIntRecord NuGet50 NuGet50 100 3,704.86 ns 414.489 ns 64.143 ns 1.20 0.04 3 0.9717 - - 6120 B
iterForeachIntRefRecord After After 100 4,037.39 ns 448.080 ns 116.365 ns 1.00 0.00 2 1.0219 - - 6520 B
iterForeachIntRefRecord Main50 Main50 100 3,707.80 ns 87.314 ns 22.675 ns 0.92 0.02 1 1.0218 - - 6520 B
iterForeachIntRefRecord NuGet50 NuGet50 100 5,362.05 ns 214.266 ns 33.158 ns 1.33 0.05 3 0.9587 - - 6120 B
iterForeachIntLikeNonGenCmp After After 100 3,024.86 ns 319.624 ns 83.005 ns 1.00 0.00 1 1.0348 - - 6520 B
iterForeachIntLikeNonGenCmp Main50 Main50 100 3,099.94 ns 566.126 ns 147.021 ns 1.02 0.03 1 1.0287 - - 6520 B
iterForeachIntLikeNonGenCmp NuGet50 NuGet50 100 3,702.69 ns 92.776 ns 14.357 ns 1.21 0.02 2 0.9655 - - 6120 B
iterForeachRefLikeNonGenCmp After After 100 3,771.33 ns 319.688 ns 83.022 ns 1.00 0.00 1 1.0389 - - 6520 B
iterForeachRefLikeNonGenCmp Main50 Main50 100 3,813.37 ns 190.766 ns 49.541 ns 1.01 0.01 1 1.0246 - - 6520 B
iterForeachRefLikeNonGenCmp NuGet50 NuGet50 100 5,369.98 ns 219.536 ns 57.013 ns 1.42 0.05 2 0.9576 - - 6120 B
addItemInt After After 100 145.69 ns 20.735 ns 3.209 ns 1.00 0.00 1 0.0422 - - 267 B
addItemInt Main50 Main50 100 155.03 ns 6.993 ns 1.816 ns 1.06 0.02 2 0.0440 - - 276 B
addItemInt NuGet50 NuGet50 100 345.31 ns 10.391 ns 2.699 ns 2.37 0.03 3 0.0426 - - 276 B
addItemIntLike After After 100 196.43 ns 53.962 ns 14.014 ns 1.00 0.00 1 0.0494 - - 314 B
addItemIntLike Main50 Main50 100 376.28 ns 36.135 ns 5.592 ns 1.90 0.15 2 0.1039 - - 654 B
addItemIntLike NuGet50 NuGet50 100 570.06 ns 15.813 ns 4.106 ns 2.91 0.18 3 0.1020 - - 654 B
addItemString After After 100 158.36 ns 5.331 ns 1.384 ns 1.00 0.00 2 0.0403 - - 256 B
addItemString Main50 Main50 100 154.95 ns 7.394 ns 1.144 ns 0.98 0.00 1 0.0421 - - 265 B
addItemString NuGet50 NuGet50 100 380.02 ns 177.948 ns 27.538 ns 2.39 0.16 3 0.0421 - - 265 B
addItemRefLike After After 100 280.26 ns 6.311 ns 1.639 ns 1.00 0.00 1 0.0497 - - 314 B
addItemRefLike Main50 Main50 100 374.78 ns 18.688 ns 4.853 ns 1.34 0.02 2 0.0505 - - 322 B
addItemRefLike NuGet50 NuGet50 100 644.28 ns 25.687 ns 6.671 ns 2.30 0.02 3 0.0509 - - 322 B
addItemIntRecord After After 100 229.07 ns 7.084 ns 1.096 ns 1.00 0.00 1 0.0496 - - 314 B
addItemIntRecord Main50 Main50 100 365.65 ns 8.342 ns 2.166 ns 1.59 0.01 2 0.1025 - - 654 B
addItemIntRecord NuGet50 NuGet50 100 536.58 ns 5.678 ns 0.879 ns 2.34 0.01 3 0.1018 - - 654 B
addItemIntRefRecord After After 100 291.92 ns 9.717 ns 2.523 ns 1.00 0.00 1 0.0489 - - 314 B
addItemIntRefRecord Main50 Main50 100 349.90 ns 43.973 ns 11.420 ns 1.20 0.04 2 0.0506 - - 322 B
addItemIntRefRecord NuGet50 NuGet50 100 588.60 ns 6.167 ns 1.602 ns 2.02 0.02 3 0.0500 - - 322 B
addItemIntLikeNonGenCmp After After 100 223.55 ns 7.309 ns 1.898 ns 1.00 0.00 1 0.0755 - - 479 B
addItemIntLikeNonGenCmp Main50 Main50 100 371.68 ns 10.334 ns 1.599 ns 1.66 0.02 2 0.1027 - - 654 B
addItemIntLikeNonGenCmp NuGet50 NuGet50 100 571.63 ns 44.259 ns 11.494 ns 2.56 0.06 3 0.1018 - - 654 B
addItemRefLikeNonGenCmp After After 100 315.47 ns 7.478 ns 1.157 ns 1.00 0.00 1 0.0487 - - 314 B
addItemRefLikeNonGenCmp Main50 Main50 100 365.18 ns 6.263 ns 0.969 ns 1.16 0.01 2 0.0511 - - 322 B
addItemRefLikeNonGenCmp NuGet50 NuGet50 100 630.63 ns 19.000 ns 4.934 ns 2.00 0.02 3 0.0504 - - 322 B
removeItemInt After After 100 98.80 ns 7.370 ns 1.914 ns 1.00 0.00 2 0.0335 - - 211 B
removeItemInt Main50 Main50 100 95.20 ns 2.173 ns 0.564 ns 0.96 0.02 1 0.0350 - - 220 B
removeItemInt NuGet50 NuGet50 100 254.62 ns 64.828 ns 10.032 ns 2.58 0.14 3 0.0346 - - 220 B
removeItemIntLike After After 100 127.18 ns 2.706 ns 0.419 ns 1.00 0.00 1 0.0388 - - 246 B
removeItemIntLike Main50 Main50 100 242.89 ns 4.362 ns 1.133 ns 1.91 0.01 2 0.0738 - - 466 B
removeItemIntLike NuGet50 NuGet50 100 410.11 ns 5.409 ns 1.405 ns 3.23 0.01 3 0.0734 - - 466 B
removeItemString After After 100 203.71 ns 15.080 ns 2.334 ns 1.00 0.00 2 0.0494 - - 314 B
removeItemString Main50 Main50 100 191.98 ns 2.614 ns 0.405 ns 0.94 0.01 1 0.0508 - - 322 B
removeItemString NuGet50 NuGet50 100 479.61 ns 35.166 ns 9.133 ns 2.36 0.07 3 0.0500 - - 322 B
removeItemRefLike After After 100 181.82 ns 8.525 ns 1.319 ns 1.00 0.00 1 0.0392 - - 246 B
removeItemRefLike Main50 Main50 100 245.63 ns 6.343 ns 1.647 ns 1.35 0.01 2 0.0395 - - 255 B
removeItemRefLike NuGet50 NuGet50 100 455.84 ns 15.967 ns 2.471 ns 2.51 0.03 3 0.0386 - - 255 B
removeItemIntRecord After After 100 143.44 ns 1.979 ns 0.306 ns 1.00 0.00 1 0.0387 - - 246 B
removeItemIntRecord Main50 Main50 100 228.74 ns 23.071 ns 5.991 ns 1.58 0.02 2 0.0734 - - 466 B
removeItemIntRecord NuGet50 NuGet50 100 381.86 ns 7.295 ns 1.894 ns 2.66 0.01 3 0.0737 - - 466 B
removeItemIntRefRecord After After 100 195.07 ns 7.819 ns 1.210 ns 1.00 0.00 1 0.0387 - - 246 B
removeItemIntRefRecord Main50 Main50 100 222.92 ns 29.455 ns 4.558 ns 1.14 0.02 2 0.0404 - - 255 B
removeItemIntRefRecord NuGet50 NuGet50 100 438.37 ns 22.268 ns 3.446 ns 2.25 0.01 3 0.0398 - - 255 B
removeItemIntLikeNonGenCmp After After 100 138.98 ns 9.356 ns 2.430 ns 1.00 0.00 1 0.0555 - - 352 B
removeItemIntLikeNonGenCmp Main50 Main50 100 242.05 ns 3.054 ns 0.793 ns 1.74 0.03 2 0.0737 - - 466 B
removeItemIntLikeNonGenCmp NuGet50 NuGet50 100 396.52 ns 2.919 ns 0.452 ns 2.84 0.05 3 0.0738 - - 466 B
removeItemRefLikeNonGenCmp After After 100 207.36 ns 10.499 ns 2.727 ns 1.00 0.00 1 0.0392 - - 246 B
removeItemRefLikeNonGenCmp Main50 Main50 100 248.32 ns 17.190 ns 4.464 ns 1.20 0.03 2 0.0402 - - 255 B
removeItemRefLikeNonGenCmp NuGet50 NuGet50 100 465.90 ns 68.785 ns 10.644 ns 2.26 0.04 3 0.0385 - - 255 B

Store height in leaves. Compared to the old discussion, when Left/Right were proposed to be stored in a universal node,
this adds 4 bytes to leaves or 2 bytes per item on average (vs 16/8).
`Match` produces `sub 1` and `switch` instruction. Here, for any non-trivial count,
nodes are more frequent than leaves on the path, so branch prediction should be beneficial.
Inline primitive comparison, keep the rest the same. See Comparison/cmp comments on how and why this works.
Arrays and structural comparison may cause problems

Maybe should just copy the snippet from dotnet#9348
…ilable

It's unambiguous. If it does something different than other ways to compare then it's very weird.

F# records implement IComparable<T> that works as expected.
@buybackoff buybackoff marked this pull request as draft January 10, 2021 02:59
@buybackoff
Copy link
Contributor Author

Cannot yet understand why the build fails or reproduce locally with meaningful output.

Locally all but 10 tests from FSharp.Core do pass.

10 tests, e.g. _.``Uint16s.Collection.ArrayArray |> Array.map Set.ofArray C.I.compare``() fail with what seems like an expectation that a compare function returns only [-1,0,1] instead of [negative,0,positive] values. The failure happens only for small types, for which comparer is implemented by cast to int and sub: int(l:int16) - int(r:int16), this never overflows for int types <= 16 bytes => it's safe.

Does F# spec require [-1,0,1] or the tests depend on an implementation detail?

image

@cartermp cartermp closed this Jan 12, 2021
@cartermp cartermp reopened this Jan 12, 2021
@cartermp
Copy link
Contributor

Re-triggering CI to see if there's something wrong environmentally, every CI leg shows an NRE when building the boostrap compiler which would be unrelated to your changes...

@cartermp
Copy link
Contributor

@buybackoff yes, there are I think a few tests that I think do depend on some implementation details, in comparersregression.fs. It's a ridiculously large file that's generated by a tool, and consequently, kind of hard to diagnose :(

@dsyme could speak more towards the F# spec in this space.

@buybackoff
Copy link
Contributor Author

buybackoff commented Jan 12, 2021

yes, there are I think a few tests that I think do depend on some implementation details, in comparersregression.fs. It's a ridiculously large file that's generated by a tool, and consequently, kind of hard to diagnose :(

In the last commit I've forced Set.compare to return [-1;0;1] and all tests for FSharp.Core pass locally

Re-triggering CI to see if there's something wrong environmentally, every CI leg shows an NRE when building the boostrap compiler which would be unrelated to your changes...

It is related. I've isolated the problem to these lines:

let normalCmp =
not (typeof<IStructuralComparable>.IsAssignableFrom(ty))
&& isNull (Attribute.GetCustomAttribute(ty, typeof<NoComparisonAttribute>))
&& isNull (Attribute.GetCustomAttribute(ty, typeof<StructuralComparisonAttribute>))
&& not (ty.IsArray)

If I add && normalCmp to the IComparable<T> if check below, everything works. There are at least two possibilities:

  • There is a type that implements IComparable<T> and has structural comparison, but the two work differently for T
  • Some code depends on [-1;0;1] return values - not only for Set.compare ( tried to build after making Set.compare to return [-1;0;1] but it still fails. I've also tried to exlude all types of tuples as in The performance of Comparing and Ordering things #9348)

@cartermp
Copy link
Contributor

Will close this out as per #10855 (comment)

(in case folks don't click the link, the rationale is that regressing reference types here could make the tradeoff not worth it, at least not without more information that it's the right tradeoff.)

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.

None yet

2 participants