.NET Systems Programming Learned the Hard Way

preview_player
Показать описание
What is a thread quantum and why is it different on Windows Desktop and Windows Server? What's the difference between a blocking call and a blocking flow? Why did our remoting benchmarks suddenly drop when we moved to .NET 6? When should I try to write lock-free code? What does the `volatile` keyword mean?

Welcome to the types of questions my team and I are asked, or ask ourselves, on a regular basis - we're the makers of Akka.NET, a high performance distributed actor system library and these are the sorts of low-level questions we need to answer in order to build great experiences for our own users.

In this talk we're going to learn about .NET systems programming, the low level components we hope we can take for granted, but sometimes can't. In particular:

- The `ThreadPool` and how work queues operate in practice;
- Synchronization mechanisms - including `lock`-less ones;
- Memory management, `Span{T}`, and garbage collection;
- `await`, `Task`, and the synchronization contexts; and
- Crossing user-code and system boundaries in areas such as sockets.

This talk will help .NET developers understand why their code works the way it does and what to do in scenarios that demand high performance.

(0:00) Intro
(2:05) Garbage Collection
(4:11) GC Generations
(8:22) Stack vs. Heap Memory
(11:36) GC Performance Considerations
(12:46) ObjectPool{T}
(16:25) GC Configuration [HIGH IMPACT]
(22:45) Delegate Allocations
(27:00) ValueDelegate Pattern
(28:38) Empty Collection Overhead
(31:26) Value Types vs. Reference Types
(33:22) Boxing Allocations
(36:15) Value Types: Not a Silver Bullet
(43:01) ThreadStatic and ThreadLocal Memory
(45:54) Context Switching
(53:42) Data Structures & Synchronization
Рекомендации по теме