Slide 1

Slide 1 text

Thinktecture AG | Consultant

Slide 2

Slide 2 text

3 Deep-dive in async/await bei Backend-APIs

Slide 3

Slide 3 text

4 Deep-dive in async/await bei Backend-APIs ▪ ▪ ▪ ▪ ▪ ▪ ▪ ▪ ▪ Twitter:

Slide 4

Slide 4 text

5 ▪ ▪ ▪ ▪ ▪ Deep-dive in async/await bei Backend-APIs

Slide 5

Slide 5 text

6 ▪ ▪ ▪ ▪ ▪ ▪ Deep-dive in async/await bei Backend-APIs

Slide 6

Slide 6 text

7 Deep-dive in async/await bei Backend-APIs Nein, aber effizienter!

Slide 7

Slide 7 text

8 Deep-dive in async/await bei Backend-APIs

Slide 8

Slide 8 text

9 ▪ ▪ ▪ ▪ ▪ ▪ ▪ Deep-dive in async/await bei Backend-APIs

Slide 9

Slide 9 text

10 Deep-dive in async/await bei Backend-APIs Kern 1 Kern 2 Kern 3 Kern 4 P2 T1 P2 T2 P3 T1 P1 T2 P3 T2 OS Scheduler P1 T1

Slide 10

Slide 10 text

11 • • • ▪ ▪ ▪ ▪ ▪ Deep-dive in async/await bei Backend-APIs * Zahlen für Windows, Quelle: “Windows Internals“, Solomin, Russinovich et al. Jeffrey Richter sagt hingegen: 30 ms in Windows, Linux hat andere Zeiten…

Slide 11

Slide 11 text

12 • • • • • • • • • • Deep-dive in async/await bei Backend-APIs

Slide 12

Slide 12 text

13 Deep-dive in async/await bei Backend-APIs 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

Slide 13

Slide 13 text

14 • • • • • • • • • Deep-dive in async/await bei Backend-APIs

Slide 14

Slide 14 text

15 Deep-dive in async/await bei Backend-APIs ALU & FPU Registers 0 Registers 1 CPU Core with Hyper-Threading Classic CPU Core

Slide 15

Slide 15 text

16 Deep-dive in async/await bei Backend-APIs 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

Slide 16

Slide 16 text

17 Deep-dive in async/await bei Backend-APIs • • • Quelle: “Systems Performance: Enterprise and the Cloud“, 2013, Brendan Gregg, Pearson Verlag

Slide 17

Slide 17 text

18 Deep-dive in async/await bei Backend-APIs • • • • • •

Slide 18

Slide 18 text

19 Deep-dive in async/await bei Backend-APIs

Slide 19

Slide 19 text

20 • • • • • • .ContinueWith() • Deep-dive in async/await bei Backend-APIs

Slide 20

Slide 20 text

21 Deep-dive in async/await bei Backend-APIs 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

Slide 21

Slide 21 text

22 • • • • • 🤯 Deep-dive in async/await bei Backend-APIs

Slide 22

Slide 22 text

23 Deep-dive in async/await bei Backend-APIs

Slide 23

Slide 23 text

24 ▪ ▪ ▪ ▪ ▪ ▪ ⏳ ▪ ▪ ▪ Deep-dive in async/await bei Backend-APIs ReadFile API: https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-readfile

Slide 24

Slide 24 text

25 ▪ ▪ ▪ ▪ ▪ ▪ ⏳ ▪ Deep-dive in async/await bei Backend-APIs ReadFile API: https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-readfile

Slide 25

Slide 25 text

26 Deep-dive in async/await bei Backend-APIs • • IAsyncResult BeginSomething() • EndSomething(result) • • DoSomethingAsync() • event SomethingCompleted • • Task[] DoSomethingAsync()

Slide 26

Slide 26 text

27 Deep-dive in async/await bei Backend-APIs

Slide 27

Slide 27 text

28 • • async Task<> MyMethodAsync() • • • await OtherMethodAsync() • • await • • • • Deep-dive in async/await bei Backend-APIs

Slide 28

Slide 28 text

29 Deep-dive in async/await bei Backend-APIs

Slide 29

Slide 29 text

30 Deep-dive in async/await bei Backend-APIs

Slide 30

Slide 30 text

31 • • task.GetAwaiter().GetResult() → ❌ • Thread.Sleep() → ❌ • await Task.Delay() → ✔ • Thread.SpinWait() • → ❌ • → ✔ Deep-dive in async/await bei Backend-APIs

Slide 31

Slide 31 text

32 • • var task1 = DoSomethingAsync(); var task2 = DoSomethingElseAsync(); await Task.WhenAll(task1, task2); • • • Task.Factory.StartNew(…, TaskCreationOptions.LongRunning); • • • Deep-dive in async/await bei Backend-APIs

Slide 32

Slide 32 text

33 • • • • Deep-dive in async/await bei Backend-APIs

Slide 33

Slide 33 text

34 Deep-dive in async/await bei Backend-APIs

Slide 34

Slide 34 text

35 ▪ ▪ ▪ ▪ ▪ ▪ Deep-dive in async/await bei Backend-APIs

Slide 35

Slide 35 text

36 ▪ ▪ ▪ ▪ ▪ 😉 Deep-dive in async/await bei Backend-APIs

Slide 36

Slide 36 text

No content