1
00:00:00,340 --> 00:00:02,540
 So the second source of overhead is the control

2
00:00:02,540 --> 00:00:06,230
 transfer overhead. And that is the context switches that have

3
00:00:06,230 --> 00:00:10,140
 to happen in order to effect an RPC call and

4
00:00:10,140 --> 00:00:13,110
 return. And let's now look at the context switches that

5
00:00:13,110 --> 00:00:16,700
 happen in doing the RPC. Let's say this is the

6
00:00:16,700 --> 00:00:19,580
 client machine, and on the client machine the client is

7
00:00:19,580 --> 00:00:22,450
 making a call. So, they're making the call Another call

8
00:00:22,450 --> 00:00:25,428
 is made. The kernel has to say, oh, this client

9
00:00:25,428 --> 00:00:27,606
 wants to make an RPC call and we know that

10
00:00:27,606 --> 00:00:30,444
 the semantics of RPC is that, the client is blocked

11
00:00:30,444 --> 00:00:34,900
 until the results are returned. And therefore, the operating system

12
00:00:34,900 --> 00:00:37,950
 on the client side, will switch from the current client

13
00:00:37,950 --> 00:00:40,940
 that is making the call, to another process, let's call

14
00:00:40,940 --> 00:00:43,435
 it C1. So this is the first context which that's

15
00:00:43,435 --> 00:00:47,170
 going to happen. On the client box, the RPC call is

16
00:00:47,170 --> 00:00:51,330
 sent out in the wire, reaches the server machine, and

17
00:00:51,330 --> 00:00:53,590
 when it reaches the server machine, the server

18
00:00:53,590 --> 00:00:57,760
 machine is executing some arbitrary process let's call it

19
00:00:57,760 --> 00:01:00,440
 S1, so when the call comes in, the kernel

20
00:01:00,440 --> 00:01:04,769
 has to switch to the particular server process, that

21
00:01:04,769 --> 00:01:07,540
 is going to handle this incoming RPC call. So

22
00:01:07,540 --> 00:01:10,850
 this is the second context switch. So, the server

23
00:01:10,850 --> 00:01:13,230
 machine and the operating system on the server machine

24
00:01:13,230 --> 00:01:16,500
 is currently executing some process S1. So it has

25
00:01:16,500 --> 00:01:19,640
 to S in order to answer the incoming

26
00:01:19,640 --> 00:01:23,060
 RPC call. So that is the second context switch

27
00:01:23,060 --> 00:01:26,590
 that happens. Then the server procedure executes. And once

28
00:01:26,590 --> 00:01:29,880
 the server procedure is completed execution, it's now going to

29
00:01:29,880 --> 00:01:32,570
 send the results out, and when it wants to

30
00:01:32,570 --> 00:01:36,460
 send the results out, at that point, the work

31
00:01:36,460 --> 00:01:39,140
 is done for the server. And so the server

32
00:01:39,140 --> 00:01:41,630
 operating system has to switch from S to some

33
00:01:41,630 --> 00:01:43,670
 other process S 2, so that's again a context

34
00:01:43,670 --> 00:01:46,230
 which that's going to happen because the server is done

35
00:01:46,230 --> 00:01:48,180
 with whatever it has to do. So that's the

36
00:01:48,180 --> 00:01:51,966
 third contact switch. Then the RPC result is coming over

37
00:01:51,966 --> 00:01:55,260
 the wire. Come to the client side. Exactly similar

38
00:01:55,260 --> 00:01:57,820
 to what happened over here. When it comes back to

39
00:01:57,820 --> 00:02:00,880
 the client side, the kernel at that point is

40
00:02:00,880 --> 00:02:06,710
 executing some process, C2. And this particular result message is

41
00:02:06,710 --> 00:02:10,970
 coming back, saying well the original call sent out

42
00:02:10,970 --> 00:02:14,020
 on behalf of this client's seed, the result have come

43
00:02:14,020 --> 00:02:17,680
 back. Now it is time to reschedule this client,

44
00:02:17,680 --> 00:02:21,500
 so that this client can receive the results, and continue

45
00:02:21,500 --> 00:02:24,350
 with his execution. Remember that the semantic it's like

46
00:02:24,350 --> 00:02:26,700
 a procedural call, but it is a remote procedural call,

47
00:02:26,700 --> 00:02:29,230
 the client is blocked For the result to come

48
00:02:29,230 --> 00:02:31,980
 back and when the result comes back. The kernel can

49
00:02:31,980 --> 00:02:35,280
 schedule the client to continue with its execution. So

50
00:02:35,280 --> 00:02:37,454
 that's what is going on. So potentially, there are

51
00:02:37,454 --> 00:02:40,080
 four contact switches that are going on. Now let's

52
00:02:40,080 --> 00:02:42,130
 look at these contact switches and figure out what

53
00:02:42,130 --> 00:02:46,060
 contact switches are critical. Now, this contact switch is

54
00:02:46,060 --> 00:02:48,930
 essentially to make sure that, the client box is

55
00:02:48,930 --> 00:02:53,560
 not being underutilized, right? So once the client has

56
00:02:53,560 --> 00:02:57,000
 made this call, til the result comes back, the client

57
00:02:57,000 --> 00:03:00,260
 box is underutalized, and therefore, the operating system says, well

58
00:03:00,260 --> 00:03:02,530
 let me switch to some other process that can lose

59
00:03:02,530 --> 00:03:04,880
 some useful work on this node. So that is, this

60
00:03:04,880 --> 00:03:07,740
 contact switch. Not critical from the point of view of the

61
00:03:07,740 --> 00:03:12,376
 latency for RPC. Now when the message comes over here.

62
00:03:12,376 --> 00:03:15,990
 This context switch is crucial because, at this point, when the

63
00:03:15,990 --> 00:03:19,470
 RPC call comes in, this guy, the server box is

64
00:03:19,470 --> 00:03:22,380
 executing some of the process S1. So it has to switch

65
00:03:22,380 --> 00:03:25,560
 to this server process, S, which can actually

66
00:03:25,560 --> 00:03:28,070
 execute the RPC call. So this is an

67
00:03:28,070 --> 00:03:32,060
 essential part of the RPC latency. And, similarly,

68
00:03:32,060 --> 00:03:35,010
 to this context which, that I talked about

69
00:03:35,010 --> 00:03:37,870
 This contact switch is happening in order to

70
00:03:37,870 --> 00:03:41,570
 make sure that the server's machine is not

71
00:03:41,570 --> 00:03:44,290
 underutilized. When the server is done with the

72
00:03:44,290 --> 00:03:47,360
 RPC call, it's going to send the results back,

73
00:03:47,360 --> 00:03:50,940
 and therefore, we need the contact switch out of this server

74
00:03:50,940 --> 00:03:54,530
 process. To some of the process that we can utilize this server

75
00:03:54,530 --> 00:03:59,280
 box. That's this contact switch. Again, similar to this context switch,

76
00:03:59,280 --> 00:03:59,280
 this context switch is not in the critical path of RPC latency.


