Alexandre Mutel — Behind the burst compiler, converting .NET IL to highly optimized native code

Опубликовано: 15 Октябрь 2024
на канале: DotNext — конференция для .NET‑разработчиков
3,369
74

Подробнее о конференции DotNext: https://jrg.su/3WmFRE
— —
Автор многих крутых проектов (например, SharpDX и Markdig) и умных низкоуровневых постов, MVP, один из самых хардкорных девелоперов из Unity Technologies.

From mobile to console, games are often trying to push the limit of our hardware to provide a better gaming experience, in a very constrained time, the famous 60 FPS or even at a higher framerate, while still saving power consumption. With a budget of 16.6ms per frame, a game has to perform lots of complex calculations in different programming domains including physics, rendering, audio, machine learning.

We believe that .NET and specially C# for games can provide a fantastic balance between productivity, safety and performance. But for certain critical code, we know also that C# is currently not able to deliver the performance that some games are looking for.

In order to lower the gap between the performance of C# games versus a more optimized language like C++, and even to go beyond what we can achieve with C++, we have been developing for the past year at Unity Technologies the "burst" compiler: a solution to compile a subset of the C# language to highly optimized native code using the LLVM compiler infrastructure.

In this talk, we will go through the details behind this challenge and how we were able to unlock it:
The challenges of generating better native code from IL/.NET than existing solutions like RyuJIT
The subset of the C# language used to maximize the performance
How to allow auto-vectorizing IL code?
Using data-oriented programming in C# without a GC
Integrate dedicated optimizations for mathematic functions
Developing an automatic Structure-Of-Array (SOA) approach into the compiler
How much difference between JIT and AOT in this solution?

Attendees will learn about Unity Technologies' approach to deliver a new JIT/AOT compiler for a subset of the C# language to unlock performance in games.

The target audience consists of people interested in low-level optimizations, native code generation, compilers, IL bytecode, .NET JIT and AOT, and LLVM.