I've done some benchmarks on counting to 1M in an empty loop for Integer vs Integer32 vs UInteger32:
Runtime backend: vm
1M iterations with Integer: 0.035
1M iterations with Integer32: 0.391
1M iterations with UInteger32: 0.406
I doesn't surprise me that the new types aren't necessarily faster, but I did not expect 10-12x slower.
Appending to an array of the same type in a loop with 1M iterations is a little less divergent:
Runtime backend: vm
Create 1M Array(Of Integer): 0.307
Create 1M Array(Of Integer32): 0.850
Create 1M Array(Of UInteger32): 0.851
Finally, creating 1M (U)Integer32 elements but while using an Integer for the array loop counter is less divergent still:
Runtime backend: vm
Create 1M Array(Of Integer32) using Integer counter: 0.551
Create 1M Array(Of UInteger32) using Integer counter: 0.552
These are all after warmup.
Now Garry this isn't a hill I want to die on but I'm just putting it out there. I know you added these because a plugin vendor was dealing with these 32 bit types in existing data and the expectation that they would have a particular wrapping behavior. And you have advised that people should still default to Integer for most everything. I am simply exploring some possible edge case uses. In particular if I needed, say, a hundred thousand or more pointers in memory none of which really need the range of an Int32 much less an Int64, being a little less extravagant with memory would be nice.
A few of my thoughts:
1) The new types are not bounds checked by design which makes them dangerous to use in a way, if you're unaware of that limitation. E.g., Integer32.MaxValue += 1 does not result in an overflow error by design, but results in Integer32.MinValue. So people need to be aware of that.
2) It is not a matter of simplistically cutting the storage of each element from 8 to 4 bytes, it is more like from 32 to 28 bytes because of the slot overhead on the VM side of things. There is still a 4 byte savings per element on the .NET side (correct me if I'm wrong). The point being, space savings isn't as compelling and depending on the app it's maybe not even something that's at a premium. It would only come into play for very large arrays, particularly if they are around for the life of the program and maybe particularly if they are static once loaded.
So ... at any rate. What I am suggesting is that if it's not a lot of work / ongoing maintenance for at least Integer32 to enjoy some or all of the VM optimizations that Integer clearly does, that'd be great. Failing that I still see a use case for very large arrays as described above and I would say that while the perf tradeoff would be worth it to me, it'd be nice if it were more of a no-brainer because the diff between Integer and Integer32 arrays could be narrowed or eliminated.
I also am not saying this should be high priority. Just advocating for it.
Thanks.