Docsity

Specialization in Real-Time Systems: Static, Dynamic, and Optimistic Approaches - Prof. Ca, Study notes of Computer Science

Toggle sidebar
bg1
1
1
CS4220 Embedded Systems
CS6235 Real-Time Systems
11A: Software Specialization
Instructor: Calton Pu
calton.pu@cc
TA: Bugra Gedik (bgedik@cc)
Some Slides by Younggyun Koh
2
Outline
zAn Overview of Specialization
–Static Specialization
–Dynamic Specialization
–Optimistic Specialization
zSpecialization Toolkit
–Tempo Specializer
zSpecialization Examples
zSpecialization in Infopipe
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download Specialization in Real-Time Systems: Static, Dynamic, and Optimistic Approaches - Prof. Ca and more Study notes Computer Science in PDF only on Docsity!

1

CS4220 Embedded Systems

CS6235 Real-Time Systems

11A: Software Specialization

Instructor: Calton Pu

calton.pu@cc

TA: Bugra Gedik (bgedik@cc)

Some Slides by Younggyun Koh

Outline

z An Overview of Specialization

  • Static Specialization
  • Dynamic Specialization
  • Optimistic Specialization

z Specialization Toolkit

  • Tempo Specializer

z Specialization Examples

z Specialization in Infopipe

3

Specialization

z Operating system – too generic

z Specialization

  • A technique for optimizing systems code
  • An application of partial evaluation
  • Specialized, simplified component
  • Better performance!

Partial Evaluation

int Multiply(int a, int b)

c = a * b;

return c;

// What if we know the value of a?

7

Dynamic Specialization

z Dynamic predicates – must hold

z Benefits

  • Exploits starting-time knowledge

z Limitations

  • Runtime overhead
  • Requires a fast runtime specializer
  • Specialization predicates must hold for remainder of the system lifetime

Optimistic Specialization

z Dynamic predicates

  • Need not hold for entire system lifetime

z Benefits

  • Can be used generally in OS code

z Limitations

  • Correctness: detecting when specialization predicates hold and cease to hold (guarding)
  • Performance: overhead of enabling and disabling specialized components (replugging)

9

Challenges

z Hard to identify predicates

  • Need system experts

z Hard to ensure correctness

  • Where to guard

z Error-prone, tedious work

z Solution: Specialization toolkit

Tempo Specializer

z Charles Consel, G. Muller, and team

z Based on partial evaluation

  • Generates C code
  • Find static and dynamic code
  • System programming features
  • Compile-time and run-time specialization
  • Need human help

13

Replugger

z Implemented at function granularity (atomic

swap of function pointers)

z Synchronizes replugging threads and

normal threads

Specialization Examples

z Static specialization of Sun RPC

z Dynamic specialization of BPF

z Optimistic specialization of Linux signals

15

Example 1: Remote Procedure Call

Client^ Server

IDL-Compiler-Generated Stubs for Marshalling (generic)

foo (a,b) { … }

XDR (foo, x, y)

XDR (results)

… foo(x,y) ...

Specializing RPC

z Predicates known at compile time

  • Message system parameters (BUFSIZE == 8800)
  • Processor-specific parameters (sizeof (long) == 4 )
  • Exact purpose of marshalling routines (x_op == XDR_ENCODE)

19

More Opportunities

z Avoid buffer boundary check

z Avoid return value check

z Loop unrolling

z Others

RPC Performance Results

21

Impact on Code Size

20 100 500 1000 2000 20004 20004 20004 20004 20004 24340 27540 33540 63540 111348

Message Size (bytes)

Generic Specialized

Code size of SunOS binaries (in bytes)

Example 2: Packet Filtering

Packet Filter

System

Network

User

25

Performance Results for BPF

Program Run time Interpretation time Null (unavoidable overhead) 2.6 sec NA Original 4.34 1. Static specialization 2.84 0. Dynamic specialization 3.35 0.

Time taken to process 10MB data (~10,000 packets):

Example 3: Signal Delivery

z Signals

  • Asynch. communication among processes
  • System call: kill(pid, sig)
  • OS delivers signal and invokes handler at receiving process

z Common execution patterns

  • Repeated use of same signal to same process
  • Locality exists, but sessions are not explicit

27

Signal Delivery in Linux

sys_kill (int pid, int sig)

kill_proc (int pid, int sign, int priv)

send_sig (int sig, task_struct * p, int priv)

generate (int sig, task_struct * p)

-- enter kernel

-- search process table for pid

-- check for permission

-- deliver the signal

kill (pid, sig)

Specializing Signal Delivery

z Problem - couldn’t recognize sessions:

  • Cache last signal sent, and destination
  • First call: test for repeat, invoke generic code
  • Second call: detect repeat, enable specialization, invoke specialized code
  • Subsequent calls: invoke specialized code if it’s a repeat, else disable specialized code

z Optimistic specialization

  • Assumes no changes to process state
  • Guards to detect updates to task_struct

31

Pipeline Example

Source Encoder Decoder Sink

Pipeline Example

Source Encoder Decoder Filter Sink

33

Infopipes

z Main component of Infosphere

z “Plain” Infopipes

  • Transform data in flow

z Complex infopipes

  • Splitters
  • Mergers/joiners
  • Buffers
  • Filters – when requested, may be placed in network to reduce data flow

Advantages of Specialization

z Several opportunities

  • Communication links: TCP, Shared memory, Function, …
  • Wire formats: XML, XDR, Raw structure, …

z Systematic code transformation

  • Explicitly identified invariants
  • Guarding of invariants guarantees correctness