Upgrade to Pro — share decks privately, control downloads, hide ads and more …

.NET 7 Web-APIs mit Turbo: Deep-Dive in async/a...

.NET 7 Web-APIs mit Turbo: Deep-Dive in async/await

Slides for my Webinar

Sebastian Gingter

May 02, 2023
Tweet

More Decks by Sebastian Gingter

Other Decks in Programming

Transcript

  1. 2 ▪ 🐻💬 ▪ ▪ ▪ ▪ ▪ ▪ ▪

    ▪ Twitter: Deep Dive in async/await
  2. 9 • • • ▪ ▪ ▪ ▪ ▪ *

    Zahlen für Windows, Quelle: “Windows Internals“, Solomin, Russinovich et al. Jeffrey Richter sagt hingegen: 30 ms in Windows, Linux hat andere Zeiten… Deep Dive in async/await
  3. 10 • • • • • • • • •

    • Deep Dive in async/await
  4. 11 Kern 1 Kern 2 Kern 3 Kern 4 P2

    T1 P2 T2 P3 T1 P1 T1 P3 T2 P1 T2 Kontext- Wechsel Kontext- & Prozess- Wechsel Deep Dive in async/await
  5. 12 • • • • • • • • •

    Deep Dive in async/await
  6. 13 ALU & FPU Registers 0 Registers 1 CPU Core

    with Hyper-Threading Classic CPU Core Deep Dive in async/await
  7. 14 Kern 1 Kern 2 Kern 3 Kern 4 P2

    T1 P2 T2 MyProc T1 P1 T2 P1 T1 MyProc T2 MyProc T3 MyProc T4 MyProc T5 MyProc T7 MyProc T6 Deep Dive in async/await
  8. 15 • • • Quelle: “Systems Performance: Enterprise and the

    Cloud“, 2013, Brendan Gregg, Pearson Verlag Deep Dive in async/await
  9. 18 ▪ ▪ ▪ ▪ ▪ ▪ ⏳ ▪ ▪

    ▪ ReadFile API: https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-readfile Deep Dive in async/await
  10. 19 ▪ ▪ ▪ ▪ ▪ ▪ ⏳ ▪ ReadFile

    API: https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-readfile Deep Dive in async/await
  11. 21 • • IAsyncResult BeginSomething() • EndSomething(result) • • DoSomethingAsync()

    • event SomethingCompleted • • Task[<T>] DoSomethingAsync() Deep Dive in async/await
  12. 24 Task Task-Liste Threadpool T1 Threadpool T2 Kern 1 Kern

    3 Kern 2 Kern 4 Threadpool T3 Threadpool T4 Threadpool Management Jeder Pool-Thread arbeitet Tasks in einer Endlosschleife ab Completed Tasks Deep Dive in async/await
  13. 27 • • async Task<> MyMethodAsync() • • • await

    OtherMethodAsync() • • await • • • • Deep Dive in async/await
  14. 30 • • task.GetAwaiter().GetResult() → ❌ • Thread.Sleep() → ❌

    • await Task.Delay() → ✔ • Thread.SpinWait() • → ❌ • → ✔ Deep Dive in async/await
  15. 31 • • var task1 = DoSomethingAsync(); var task2 =

    DoSomethingElseAsync(); await Task.WhenAll(task1, task2); • • • Task.Factory.StartNew(…, TaskCreationOptions.LongRunning); • • • Deep Dive in async/await