Trustworthy Systems

Where's all the time going? Microstate accounting in Linux 2.5

Authors

Peter Chubb

    School of Computer Science and Engineering
    UNSW,
    Sydney 2052, Australia

Abstract

When you time a process using time(1), you get back three numbers: real time, user time, and system time. These numbers are generated statistically; at regular intervals, an interrupt occurs and the current process gets an extra tick in either its system time counter or its user time count.

Except for CPU-bound processes, these numbers should be viewed with extreme scepticism. Under Linux, for a start, multithreaded processes are not accounted for correctly; there are processes that wake at regular intervals, do a small amount of processing (less than a tick) then sleep (e.g., Apache) --- their wakeup interval tends to become synchronised with the timer interrupt so their time is never accounted for; and time spent in interrupt handlers is accounted to the process that was interrupted, not to the process that caused the interrupt.

In addition, there are sources of poor performance that just aren't captured by these times --- scheduler latency, IO latency, etc., etc.

We added timers using the processor's inbuilt high-resolution clock to track the time spent by each thread in each state. Also, we added timers for each interrupt vector, so that time could be accounted properly for each interrupt.

A new system call gets the extended resource usage.

On IA64, this adds around 100 cycles to each context switch, so it mustn't be turned on all the time.

The standard getrusage() system call under-reports the actual times spent for a large number of common programs: anything that sleeps more than it runs.

Other things that the extended getrusage call allows are direct measurement of scheduler latency, correlation with results from lockmeter, etc., to see what in-kernel features affect real user processes, etc.

BibTeX Entry

  @inproceedings{Chubb_03,
    address          = {Melbourne, Australia},
    author           = {Peter Chubb},
    booktitle        = {Conference for Unix, Linux and Open Source Professionals (AUUG)},
    month            = sep,
    paperurl         = {https://trustworthy.systems/publications/papers/Chubb_03.pdf},
    title            = {Where's all the time going? {M}icrostate accounting in {Linux} 2.5},
    year             = {2003}
  }

Download