slides on cross domain call and remote procedure call rpc
play

Slides on cross-domain call and Remote Procedure Call (RPC) - PowerPoint PPT Presentation

Slides on cross-domain call and Remote Procedure Call (RPC) This classic paper is a good example of a microbenchmarking study. It also explains the RPC abstraction and serves as a case study of the


  1. Slides ¡on ¡cross-­‑domain ¡call ¡and ¡ Remote ¡Procedure ¡Call ¡(RPC) ¡

  2. This classic paper is a good example of a microbenchmarking study. It also explains the RPC abstraction and serves as a case study of the nuts-and-bolts of I/O, and related performance issues. Or is it “just hacking”?

  3. Request/reply messaging client ¡ server ¡ request ¡ compute ¡ reply ¡

  4. Messaging: examples and variations • Details vary! – Supercomputing: MPI over fast interconnect – High-level messages (e.g., HTTP) over sockets and network communication – Microkernel / Mach / MacOS: high-speed local cross- domain messaging ports. (Also Windows/NT) – Android: binder, and per-thread message queues • Common abstraction: “Remote Procedure Call” – RPC for clients/serves talking over a network. – For local processes it is often called cross-domain call or “Local Procedure Call” (LPC, in Windows).

  5. Network File System (NFS) Remote ¡Procedure ¡Call ¡(RPC) ¡ External ¡Data ¡Representa<on ¡(XDR) ¡ [ucla.edu]

  6. Cross-domain call: the basics A B A: syscall to post a B: syscalls to receive an message to B (e.g., a incoming message. message queue). Wait Wait for request. for reply. Request: block A, wakeup B. Reply: block B, wakeup A.

  7. Cross-domain call: the basics Copy data from A to B, or use a shared memory region. A B A: syscall to post a B: syscalls to receive an message to B (e.g., a incoming message. message queue). Wait Wait for request. for reply. Transfer control through kernel: block A, wakeup B. Note: could use a socket, or fast IPC for processes on same host.

  8. “Marshalling” (“serializing”) A B What if the data is a complex linked structure? Must “pack” it as a sequence of bytes into a message, and reconstitute it on the other side.

  9. Concept: RPC Remote Procedure Call (RPC) is request/response interaction through a published API, using IPC messaging to cross an inter- process boundary. API stubs generated from an Interface Description Language (IDL) Establishing an RPC connection to a named remote interface is often called binding . RPC is used in many standard Internet services. It is also the basis for component frameworks like DCOM, CORBA, and Android. Software is packaged into named “objects” or components . Components may publish interfaces and/or invoke published interfaces of other components. Components may execute in different processes and/or on different nodes.

  10. The classic picture Implementing RPC Birrell/Nelson 1984

  11. RPC Execution • In general, RPC enables request/response exchanges (e.g., by messaging over a network) that “looks like” a local procedure call. • In Android, RPC allows flexible interaction among apps running in different processes, across the kernel boundary. • How is this different from a local procedure call? • How is it different from a system call?

  12. RPC: Language integration

  13. RPC: Language integration Stubs link with the client/server code to “hide” the boundary crossing. – They “ marshal ” args/results – i.e., translate to/from some standard network stream format – Also known as linearize, serialize – … or “flatten” – Propagate PL-level exceptions – Stubs are auto-generated from an Interface Description Language (IDL) file by a stub compiler tool at software build time, and linked in. – Client and server must agree on the protocol signatures in the IDL file.

  14. Marshalling: a metaphor Android Architecture and Binder Dhinakaran Pandiyan Saketh Paranjape

  15. Stubs • RPC stubs are procedures linked into the client and server. – RPC stubs are similar to system call stubs, but they do more than just trap to the kernel. – The RPC stubs construct/deconstruct a message transmitted through a messaging system. – Binder is an example of such a messaging system, implemented as a Linux kernel plug-in module (a driver) and some user-space libraries. • The stubs are generated by a tool that takes a description of the application’s RPC API written in an Interface Description Language . – Looks like any interface definition … – List of method names and argument/result types and signatures. – Stub code marshals arguments into request message, marshals results into a reply message.

  16. Stubs and IDL This picture illustrates the stub generation and build process for an RPC system based on the C language (e.g., ONC or Sun RPC, used in NFS).

  17. Another picture of RPC Implementing RPC Birrell/Nelson 1984

  18. Threads and RPC Q: How do we manage these “call threads”? A: Create them as needed, and keep idle threads in a thread pool . When an RPC call arrives, wake up an idle thread from the pool to handle it. On the client, the client thread blocks until the server thread returns a response. [OpenGroup, late 1980s]

  19. Thread pool: idealized worker Magic elastic worker pool loop Resize worker pool to match incoming request load: create/ handler Handle one destroy workers as needed. event, dispatch blocking as necessary. Incoming handler request When handler idle workers (event) is complete, queue return to Workers wait here for next worker pool. request dispatch. (Workers are threads.) handler

  20. Event/request queue We can synchronize an event worker queue with a monitor: a loop mutex/CV pair. handler Protect the event queue data Handle one structure itself with the mutex. event, dispatch blocking as necessary. Incoming handler event When handler threads waiting on CV queue is complete, return to Workers wait on the CV for worker pool. next event if the event queue is empty. Signal the CV when a new event arrives. This is a handler producer/consumer problem.

  21. Some details • How is incoming data delivered to the correct process? • On the return, how does the Receiver know which thread to wake up? • How does the wakeup happen? • What if a request/reply is dropped in the net? • What if a request/reply is duplicated? • How does the client find the server? (binding) • What if the server fails? • How to go faster if client/server are on the same host? (“LRPC” or “LPC”)

  22. Firefly vs. Web/HTTP etc. • Firefly does not use TCP/IP. • Instead, it has a custom packet protocol. Tradeoffs? • But some of the basics of network communication are similar/identical. • How is (say) HTTP different from RPC?

  23. Networked services: big picture client ¡host ¡ ¡ NIC ¡ device ¡ ¡ Internet ¡ “cloud” ¡ client ¡ kernel ¡ ¡ server ¡hosts ¡ applica5ons ¡ network ¡ with ¡server ¡ Data is sent on the ¡ so9ware ¡ applica5ons ¡ network as messages ¡ ¡ called packets .

  24. A simple, familiar example request “ GET /images/fish.gif HTTP/1.1 ” reply client (initiator) server s = socket( … ); sd = socket( … ); bind(s, name); connect(sd, name); sd = accept(s); write(sd, request … ); read(sd, request … ); read(sd, reply … ); write(sd, reply … ); close(sd); close(sd);

  25. End-to-end data transfer sender receiver move data from move data from application to system buffer to system buffer application buffer ¡queues ¡ buffer ¡queues ¡ (mbufs, ¡skbufs) ¡ TCP/IP protocol TCP/IP protocol compute checksum compare checksum packet ¡queues ¡ packet ¡queues ¡ network driver network driver DMA ¡+ ¡interrupt ¡ DMA ¡+ ¡interrupt ¡ transmit packet to deposit packet in network interface host memory

  26. Ports and packet demultiplexing Data ¡is ¡sent ¡on ¡the ¡network ¡in ¡messages ¡called ¡ packets ¡addressed ¡to ¡a ¡ des<na<on ¡node ¡and ¡ port . ¡ ¡Kernel ¡network ¡stack ¡ demul5plexes ¡ incoming ¡network ¡traffic: ¡choose ¡process/socket ¡to ¡receive ¡it ¡based ¡on ¡ des<na<on ¡port. ¡ Apps ¡with ¡ open ¡ sockets ¡ Incoming ¡network ¡packets ¡ Network ¡adapter ¡hardware ¡ aka, ¡network ¡interface ¡ controller ¡(“NIC”) ¡

  27. Wakeup from interrupt handler return to user mode trap or fault sleep ¡ ready ¡ queue ¡ queue ¡ sleep ¡ switch ¡ wakeup ¡ interrupt Example ¡1: ¡ NIC ¡interrupt ¡wakes ¡thread ¡to ¡receive ¡incoming ¡packets. ¡ Example ¡2: ¡ disk ¡interrupt ¡wakes ¡thread ¡when ¡disk ¡I/O ¡completes. ¡ ¡ Example ¡3: ¡clock ¡interrupt ¡wakes ¡thread ¡aQer ¡N ¡ms ¡have ¡elapsed. ¡ ¡ Note : ¡it ¡isn’t ¡actually ¡the ¡interrupt ¡itself ¡that ¡wakes ¡the ¡thread, ¡but ¡the ¡ interrupt ¡ handler ¡(soQware). ¡ ¡The ¡awakened ¡thread ¡must ¡have ¡registered ¡for ¡the ¡wakeup ¡before ¡ sleeping ¡(e.g., ¡by ¡placing ¡its ¡TCB ¡on ¡some ¡sleep ¡queue ¡for ¡the ¡event). ¡

  28. Process, kernel, and syscalls process user space syscall stub user buffers read () { … } Return trap copyin copyout syscall to user dispatch mode table read () { … } I/O descriptor write () { … } table kernel I/O objects

  29. Firefly: shared buffers Performance of Firefly RPC Michaels Schroeder and Burrows

  30. Binding Implementing RPC Birrell/Nelson 1984

Recommend


More recommend