New BitVector64 and/or revised BitArray #8457
Replies: 2 comments 1 reply
-
This is not a language concern. This is a runtime concern. |
Beta Was this translation helpful? Give feedback.
-
Honestly if you are on net 6 or so and need more than 32 bits you might be better off using smallest or biggest SIMD available to you (eg. |
Beta Was this translation helpful? Give feedback.
-
Summary
Currently in C# there is a BitVector32() struct on stack and a BitArray() dynamic heap. Developers have had to manually create their own data structures for 64-bit and to enhance the properties and methods. Can you make a 64-bit (or maybe dynamically chooses native bit of the box) version of BitVector or a BitArray that works on the stack? Could AMD help with making optimizations to AMD chips?
Motivation
GOAL 1- Can there be speed ups of existing code so that the compiler detects non-fancy coding (maybe of Boolean or integer or short character segments) and chooses to use this new struct under the hood? (This could be a way to improve performance of C# compared to other languages.)
GOAL 2- Improve properties and methods especially in non-bit specific ways (meaning BitVector32 wants you to interact with it with only masks)
GOAL 3- Do this as struct if we know it is static length and within the size.
GOAL 4 - Perhaps use the new Span functionality to improve performance.
GOAL 5 - Low priority - Perhaps work with chip makers (such as AMD) to improve performance.
GOAL 6 - Very low priority - Perhaps this would help porting C++ code that has bit operations on 64-bit to C#.
Planning
I like some of the properties and methods found under the BigInteger:
https://learn.microsoft.com/en-us/dotnet/api/system.numerics.biginteger?view=net-8.0
I like his commentary of what are issues with BitVector32 and BitArray. Also he attempts to fix it.:
https://www.jacksondunstan.com/articles/5126
Here is another developer adding the BitVector64:
https://www.codeproject.com/Tips/838362/A-bit-Bit-Field-in-Csharp
I suggest glancing at other vendors that do something similar:
Unity.Collections has NativeBitArray, BitField32, BitField64
Beta Was this translation helpful? Give feedback.
All reactions