Writing high performance code
in Net 7.0
@jcant0n
Javier is a Computer Science Engineer who has
always had a passion for 3D graphics and
software architecture. His professional
achievements include being MVP for Windows
DirectX and DirectX XNA for nine years, Xbox
Ambassador, as well as Microsoft Student
Partner and Microsoft Most Valuable Student
during his years at college. Currently he works as
Chief technology innovation officer.
Javier Cantón
Evergine
Net 7.0
.NET is unified
Net 7.0
Generic Math
C# 11
Auto-default
struct
Numeric IntPtr
UTF-8 string
ref scope variables
Pattern match
span<char>
P/Invoke source
generation
Micro-optimization
• BCL and Runtime
• Real Time applications
• Graphics development
• ML libraries
What is faster (Assignment)?
@badamczewski01
What is faster (Struct Locals)?
@badamczewski01
What is faster (Nullable)?
@badamczewski01
What is faster (Try-catch)?
@badamczewski01
Measure
Measure
Principles
Value Type vs Reference Type
Stack Heap
Reference Type Memory Location
Int var = 10
Value Type
Int var = 10
Boxing and Unboxing
Stack Heap
j Int 4
o Int 4
i int 4
int 10
.NET Managed Heap
Size >= 85.000 bytes
LOH = GEN 2 = FULL GC
IL and JIT
GPU Command Queue
OpenGL Issue
OpenGL CommandQueue
• Queue<T>
• Interface and struct
MemoryPool
Custom Collection
Custom collection
Final Results
Vectorize Math
SIMD
Math Performance
Hardware intrinsics
• System.Runtime.Intrinsics
• Vector64<T>
• Vector128<T>
• Vector256<T>
• System.Runtime.Intrinsics.X86
• Sse, Sse2,… Sse42
• Avx, Avx2
• Fma
• System.Runtime.Intrinsics.Arm.Arm64
• AdvSimd
SIMD Math
Results
Matrix4x4
Memory
More…
XPlat
Runtime Boost
Apple M1
Questions
@jcant0n
Writing high performance code in Net 7.pptx

Writing high performance code in Net 7.pptx