runtime program evolution

33
1 University of Maryland Runtime Program Evolution Jeff Hollingsworth ' Copyright 2000, Jeffrey K. Hollingsworth, All Rights Reserved.

Upload: others

Post on 29-May-2022

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Runtime Program Evolution

1University of Maryland

Runtime Program Evolution

Jeff Hollingsworth

© Copyright 2000, Jeffrey K. Hollingsworth, All Rights Reserved.

Page 2: Runtime Program Evolution

2University of Maryland

Motivation

� Software systems are � becoming more complex� being built from component parts� running in complex and varied environments

� Tools are required to� understand the behavior of such systems� react to changing environments� manage software components

Page 3: Runtime Program Evolution

3University of Maryland

dyninstAPI

� API for runtime code patching� new code can be added to a program while it executes� permits instrumentation and modification of

programs

� Provides processor independent abstractions� same patching can be applied to multiple systems

� Includes meta-instrumentation� tracks overhead on inserted code

Page 4: Runtime Program Evolution

4University of Maryland

Applications of Runtime Code Patching

� Performance measurement� Recording application behavior

� Correctness debugging� Fast conditional breakpoints� Data breakpoints

� Execution driven simulation� Architecture studies

� Testing� Code coverage testing� Forcing hard to execute paths to be taken

Page 5: Runtime Program Evolution

5University of Maryland

Advantages of Runtime Code Patching

� No forethought needed� No user inserted probes� No special compiling or linking� Start anytime during execution

� Only insert code when needed� No wasted checks for �disabled� code� Can add new code during execution

Page 6: Runtime Program Evolution

6University of Maryland

MachineDependentCode

Structure of the Dyninst Library

Mutator Mutatee

Mutator App

API

DyninstCode

Ptrace or procfs

ApplicationCode

Snippets

Run-time Library

Page 7: Runtime Program Evolution

7University of Maryland

API Library

� Provides:� Functions for control of mutatee� Runtime code generation� Information about mutatee

� A set of C++ classes� Bpatch_thread� BPatch_image� BPatch_snippet� BPatch_variableExpr� BPatch_block

Page 8: Runtime Program Evolution

8University of Maryland

Representing Code Snippets

� Platform Independent Representation� Same code can be inserted into apps on any system

� Simple Abstract Syntax Tree� Can refer to application state (variables & params)� Includes simple looping construct� Permits calls to application subroutines

� Type Checking� Ensures that snippets are type compatible� Based on structural equivalence

� allows flexibility when adding new code

Page 9: Runtime Program Evolution

9University of Maryland

Snippet Exampleif (flagVar == 0) fdVar = open(filename, ...)

BPatch_ifExpr

BPatch_constExpr(0)BPatch_variableExprflagVar

BPatch_boolExpr(BPatch_eq, �)

BPatch_VariableExprfdVar

BPatch_arithExpr(BPatch_assign, �)

BPatch_constExpr(0666)

BPatch_constExpr(filename)

BPatch_constExpr(O_WRONLY | O_CREAT)

BPa

tch_

Vect

or

BPatch_funcCallExpr

BPatch_function �open�

Page 10: Runtime Program Evolution

10University of Maryland

Type Support in Dyninst

� Access to local (stack) variables� Complex types

� non-integer scalars� structures� arrays

� Correctness debugging� print contents of data structures

Page 11: Runtime Program Evolution

11University of Maryland

Implementation

� Use Compiler debugger info (stab records)� access to user defined types� information about local variables� type information for all variables� line number to text segment address mapping

� Incremental parsing� parse stabs for a module on first use

� dyninst User can define types� allows the creation of new types for patched code� permits reconstruction of stripped symbols

Page 12: Runtime Program Evolution

12University of Maryland

API Example// find all variables defined in an imageBPatch_Vector<BPatch_variableExpr *> vars =

appImage->getGlobalVariables()

for (i=0; i < vars->size(); i++) {BPatch_variableExpr *v = (*vars)[i];switch (v->getType()->type()) {

case BPatch_scalar:printf(�%s is a scalar of type %s\n�, v->getName(),

v->getType()->getName());case BPatch_structure:

FieldVector *fields = v->getType()->getComponents();for (j=0; j < fields->size(); j++) {

Bpatch_field *f = (*fields)[j];printf(�field %s is of type %s\n�, f->getName(),

f->getType()->getName());} } }

Page 13: Runtime Program Evolution

13University of Maryland

Code Coverage Testing Using Dyninst

� Code Coverage� identifies source code lines not executed � ensures each basic block is taken at least once

� Using Dyninst� Allows use on arbitrary binaries� Permits removing code once a block is covered

� Long running programs can be tested faster� Permits incremental instrumentation

� First instrument function entry� On first call, instrument function�s blocks

Page 14: Runtime Program Evolution

14University of Maryland

1

2

3

4

5

6

7

CFG Dominator Tree1

2

3 4

5 7

6

Using Dominators to Reduce Counters

�instrument basic blocks that are leaf nodes in dominator tree

�Also instrument basic blocks with outgoing edge(s) to blocks not dominated by them

Page 15: Runtime Program Evolution

15University of Maryland

Postgres with Wisconsin benchmark

0

20

40

60

80

100

120

140

160

180

exec

ution

time(

sec)

original 0 2 10 25deletion interval(sec)

execution time for postgres

all basic blocksdominator info

coverage for postgres

0

5

10

15

20

25

1 11 21 31 41 51 61 71 81

time(interval)

perc

enta

ge

percentage

Page 16: Runtime Program Evolution

16University of Maryland

Slow down

0

5

10

15

slow

down

rat

io

postgres vortex perl mk88sim ijpeg

tested programs

slow down ratio wrt. original execution

purecov

all basic blocks

dominator info

Page 17: Runtime Program Evolution

17University of Maryland

Dyner Command Utility� TCL-based command line tool

� provides access to most dyninst features� easier to program for simple applications� can be used as a simple command-line debugger

� fast conditional breakpoints� dynamic addition of printfs

� Command Summary� declare: create a new variable in the application� cbreak: insert conditional breakpoint� print: show contents of application data structures� at: insert a code snippet into the application� load, run, exit: process creation and manipulation

Page 18: Runtime Program Evolution

18University of Maryland

TCL Command Example

% load application% declare int counter% at main entry { counter = 0; }% at importantFunc entry { counter++; }% at main exit {

printf(�function called %d times\n�, counter);

} % run

Page 19: Runtime Program Evolution

19University of Maryland

Dyninst Status

� Supported platforms� SPARC (Solaris)� x86 (Solaris, Linux, NT)� Alpha (Tru64 UNIX)� MIPS (IRIX)� Power/PowerPC (AIX)

� Software available on the web� http://www.cs.umd.edu/projects/dyninstAPI� Includes TCL command tool (soon)

Page 20: Runtime Program Evolution

20University of Maryland

Expanding the Application/System Interface

Past Model:Start program execution, hope for best

New Model:Application exposes alternatives

different algorithms/parametersperformance expectations for options

System adapts application to optimize execution

Page 21: Runtime Program Evolution

21University of Maryland

Harmony Structure

TuningControl

Applicationsand Libraries

System

Controller

Capacities andRequirements

TuningOptions

TuningControl

Availabilities andRequirements

MetricInterface

ResourceRequirements

Page 22: Runtime Program Evolution

22University of Maryland

Features of Harmony RSL

� Bundles� primary unit of adaptation� mutually exclusive sets of application options

� Resource Requirements� expected utilization for each option and resource

� Performance Prediction� expected performance of selected bundles� allows optimizing multiple applications on a system

Page 23: Runtime Program Evolution

23University of Maryland

Bundles

� node� CPU speed/disk capacity/available memory

� link� latency/bandwidth/protocol between nodes

� communication� entire application�s communication requirements

� performance� entire application�s performance

� granularity� switching between options at runtime

Page 24: Runtime Program Evolution

24University of Maryland

Harmony API

harmony_startup(<unique id>, <use interrrupts>)

harmony_bundle_setup(“<bundle definition>”)

void *harmony_add_variable(“name”, <default>, <type>, <func>)

harmony_wait_for_update()

harmony_end()

Used by application to:� define options� learn of harmony selections� receive information about the environment

Page 25: Runtime Program Evolution

25University of Maryland

Architecture of Harmony ImplementationHarmony Process

ApplicationOptions

PerformanceData

OptionInstantiation

C Code

Option Selection (TCL Code)

Send/Recv (TCP)

Application Process Application Process

Parameters

(e.g., cache size)

Alternative

Algorithms

Harmony Library

Application Code

Parameters

(e.g., cache size)

Alternative

Algorithms

Harmony Library

Application Code

Page 26: Runtime Program Evolution

26University of Maryland

Example: Client-Server Database

ClientQuery-Shipping

Server

ClientData-Shipping Server

Page 27: Runtime Program Evolution

27University of Maryland

Database BundleharmonyBundle Dbclient:1 where {

{QS {node server{seconds 9}{memory 20}}

{node client {seconds 1}{memory 42}}

{link client server 2}}

{DS {node server{seconds 1}{memory 20}}

{node client{memory >=17}{seconds 9}}

{link client server {44 + (client.memory > 24 ? 24 : client.memory) - 17}}

}}

Page 28: Runtime Program Evolution

28University of Maryland

Client Response Times

0

5

10

15

20

25

0 100 200 300 400 500 600 700 800 900Time [s]

Resp

onse

tim

e [s

]

Client #1Client #2Client #3

Clients added one at a time:� First two clients run with query-shipping� Third client flips all to data-shipping

Page 29: Runtime Program Evolution

29University of Maryland

Results from PSTSWM

� Solves nonlinear shallow water equations� Contains many options:

� Multiple algorithms embedded in the code � Problem-specific options� Communication Parameters

All CombinationsSize Nodes Min Max T42L16 4 0.75 1.52 T42L16 8 0.50 1.03 T85L32 4 9.55 20.89 T85L32 8 5.99 11.41

Best CombinationsMin Max

0.75 1.49 0.50 0.779.55 15.385.99 7.90

Page 30: Runtime Program Evolution

30University of Maryland

Current Work

� Application resource usage� potential, not necessarily achievable� user, compiler, profiling

� Performance prediction� structural models� POEMS, AppLeS

� Scheduling!� Heuristics

� More applications� real-time vision, web server, video server

Page 31: Runtime Program Evolution

31University of Maryland

Active Harmony Conclusions

� Launch and forget is not sufficient:� Capacities are dynamic� Demands are dynamic

� System-directed adaptation gives us:� Complete information� Handles to running applications

� But requires:� Application restructuring (or layering, i.e. DSM)� Detailed resource requirements

Page 32: Runtime Program Evolution

32University of Maryland

Acknowledgements

� Co-PIs� Pete Keleher (Harmony)� Bart Miller (dyninst)

� Graduate Students� Harmony - Heonsang Eom, Dejan Perkovic, Cristian Tapus� dyninst - Bryan Buck, Mustafa Tikir

� Research Staff� Mehmet Altinel

� Funding Agencies� DARPA, DOE, DOD, NSF, NIST

Page 33: Runtime Program Evolution

33University of Maryland