Check out the new USENIX Web site. next up previous
Next: Applying compiler optimizations Up: Case Study: System Call Previous: Clustering mechanisms

Profiling.

Given this mechanism, the issue becomes one of identifying optimization opportunities in the program, both in the sense of identifying sequences of calls that can be replaced by a multi-call and identifying correctness-preserving program transformations that can be used to create such sequences. Profiling does this by characterizing the dynamic system call behavior of a program on a given set of inputs. Operating system kernels often have utilities for generating such traces (e.g., strace in Linux), or they can be obtained by instrumenting kernel entry points to write to a log file.

A system call graph is then constructed to provide a graphical representation of a collection of such traces for a given program. An example of such a graph for a simple copy program is shown in figure 1.c; the code for this program is in figure 1.a, while 1.b shows the control flow. Each node in this graph represents a system call with a given set of arguments. Consecutive system calls in the trace appear as nodes connected by directed edges indicating the order. The weight of each edge indicates the number of times the sequence appears. This graph forms the basis for compile-time transformations for grouping system calls. The general idea is to find frequently executed sequences of calls in the system call graph; if the corresponding system calls are not syntactically adjacent in the program source, we attempt to restructure the program code so as to make them adjacent, as described below.



Figure 1: Copy program
#include <stdio.h>
#include <fcntl.h>

#define N 4096

void main(int argc, char* argv[])
{
int inp, out, n;
char buff[N];

inp = open(argv[1],O_RDONLY);
out = creat(argv[2],0666);

while ((n = read(inp,&buff,N)) > 0) {
write(out,&buff,n);
}
}
(a) Source code
\epsfbox{callgraph.eps}


(b) Control flow graph
\epsfbox{syscallgraph.eps}

(c) System call graph



next up previous
Next: Applying compiler optimizations Up: Case Study: System Call Previous: Clustering mechanisms
Mohan Rajagopalan 2003-06-16