Update performance for nullable int/decimal types
See original GitHub issueAs mentioned in #3253 the fix for that issue did not solve what we are seeing in AWS. I used @aarondk-dev solution as a starting point and with @zacbre’s help were able to isolate the problem. Here’s a solution to help reproduce the issue:
https://github.com/pebezo/Linq2DbUpdate
The good news is that it’s not dependent on MySQL, Docker, or anything in AWS. The examples below use Sqlite. Also, the issue seems to happen only on nullable int and nullable decimals. Here are the results for version 3.5.0
Method | Mean | Error | StdDev | Median | Ratio | RatioSD | Allocated |
---|---|---|---|---|---|---|---|
Compiled | 244.5 us | 14.57 us | 60.90 us | 223.0 us | 1.00 | 0.00 | 63 KB |
String | 446.1 us | 23.54 us | 98.62 us | 407.5 us | 1.93 | 0.63 | 128 KB |
String_Nullable | 450.1 us | 25.08 us | 105.91 us | 406.1 us | 1.93 | 0.58 | 127 KB |
Int | 285.0 us | 12.94 us | 52.34 us | 270.0 us | 1.23 | 0.31 | 83 KB |
Int_Nullable | 13,986.1 us | 335.66 us | 1,417.55 us | 13,766.7 us | 60.39 | 15.29 | 1,542 KB |
DateTime | 286.9 us | 10.67 us | 41.91 us | 276.8 us | 1.24 | 0.29 | 85 KB |
DateTime_Nullable | 343.9 us | 20.75 us | 81.53 us | 316.1 us | 1.48 | 0.43 | 89 KB |
Bool | 320.4 us | 18.58 us | 77.66 us | 293.5 us | 1.38 | 0.43 | 82 KB |
Bool_Nullable | 285.6 us | 10.80 us | 43.54 us | 281.2 us | 1.24 | 0.32 | 82 KB |
Decimal | 305.5 us | 16.75 us | 69.44 us | 288.0 us | 1.31 | 0.38 | 84 KB |
Decimal_Nullable | 14,308.3 us | 292.09 us | 1,217.45 us | 14,305.0 us | 61.68 | 14.33 | 1,545 KB |
Float | 328.3 us | 19.04 us | 79.78 us | 302.3 us | 1.41 | 0.44 | 83 KB |
Float_Nullable | 286.0 us | 10.14 us | 40.68 us | 285.6 us | 1.24 | 0.29 | 86 KB |
The Compiled
run includes all the columns, that’s why some of the other tests are able to beat it. Notice how the Int_Nullable and Decimal_Nullable take 60x more than the rest.
In our AWS app we have a combination of int?/decimal? columns which explains that 100x slowness.
For kicks we ran the exact same benchmark against version 2.9.8:
Method | Mean | Error | StdDev | Median | Ratio | RatioSD | Allocated |
---|---|---|---|---|---|---|---|
Compiled | 156.1 us | 0.37 us | 1.53 us | 155.8 us | 1.00 | 0.00 | 52 KB |
String | 4,656.2 us | 9.77 us | 40.40 us | 4,652.4 us | 29.82 | 0.37 | 1,317 KB |
String_Nullable | 4,731.0 us | 17.20 us | 71.32 us | 4,718.4 us | 30.30 | 0.55 | 1,320 KB |
Int | 3,163.1 us | 26.51 us | 110.80 us | 3,160.0 us | 20.26 | 0.74 | 820 KB |
Int_Nullable | 3,101.4 us | 22.99 us | 95.07 us | 3,098.2 us | 19.86 | 0.64 | 816 KB |
DateTime | 136.3 us | 0.48 us | 1.99 us | 136.1 us | 0.87 | 0.02 | 58 KB |
DateTime_Nullable | 139.9 us | 0.48 us | 2.01 us | 139.9 us | 0.90 | 0.02 | 58 KB |
Bool | 121.7 us | 0.27 us | 1.12 us | 121.5 us | 0.78 | 0.01 | 53 KB |
Bool_Nullable | 126.3 us | 0.28 us | 1.17 us | 126.1 us | 0.81 | 0.01 | 54 KB |
Decimal | 3,562.3 us | 17.69 us | 70.31 us | 3,565.6 us | 22.82 | 0.49 | 823 KB |
Decimal_Nullable | 3,638.4 us | 19.10 us | 80.02 us | 3,649.0 us | 23.31 | 0.56 | 820 KB |
Float | 127.4 us | 0.25 us | 1.05 us | 127.3 us | 0.82 | 0.01 | 53 KB |
Float_Nullable | 135.3 us | 0.42 us | 1.72 us | 135.1 us | 0.87 | 0.01 | 57 KB |
It looks like some scenarios are actually better than in the latest version; something that may be worth investigating…
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:10 (10 by maintainers)
Awesome work @MaceWindu 👏 🚀
master
3.5.0
2.9.8
@pebezo nullable fix merged