I’ve been following recent development of C# as a language and it seems that there is a strong focus on providing the means to write code more efficiently. This is definitely neat. But what about providing ways to write more efficient code?
For context, I’m using C# mostly for game development (as in "lowlevel / from scratch") which has a habit of gladly abandoning the usual ways of safe code design for that 0.1% of the bottleneck code in favor of maximum efficiency. Unfortunately, there are cases where C# gets in the way of that last bit of optimization.
Issues related to this:
- Ref returns / ref locals: Issue#118
- Slicing: Issue#120
- Array views of blittable data types:CoreCLR Issue 1015
- Generic API for unsafe read / write:CoreFx Issue 5474
- Support for SSE4 Intrinsics:CoreFx Issue 2209
- Efficient unmanaged memory operations:CoreCLR Issue 916
- Vector shuffling SIMD operations:CoreFx Issue 1168
- Handling overlapped explicit FieldOffsets in structs: Issue#10319 and#7323
- Extended JIT time constants:CoreCLR Issue 2591
- Extended unsafe generics: Issues#3208 and#3210
- Custom memory allocations:CoreCLR Issue 1235
- There are probably more – please share them in a comment
Other sentiments regarding this:
- The only way to improve / guarantee memory locality right now seems to be putting the data into an array of structs. There are scenarios where this is a bit impractical. Are there ways to handle this with classes?
- Language support for object pooling / limited control over what exactly "new" does for a given class / reference type.
- A way to instantiate a reference type "within scope", making cleaning it up more efficient by somehow providing the GC with the extra knowledge about an explicit / intended lifespan.
- Please share your own in a comment
This is probably more of a broader discussion, but I guess my core question is: Is there a general roadmap regarding potential improvements for performance-focused code in C#?
转载本站任何文章请注明：转载至神刀安全网，谢谢神刀安全网 » [Discussion] State/Direction of C# as a High-Performance Language