Home

News

About

Download

 Current version

Documentation

 Module timers

 HOWTO: Module usage

 Performances

References

Credits

Contributing


Author's homepage

APIC timer Module for Linux
Documentation


Performances of the APIC timer module.

Author: Vincent Oberle

Purpose

This document presents some performance tests in various configurations of the APIC Timer module.

Note that this document is partially outdated due to recent changes in the module.

Content

The bad start problem
A simple example
More timers
Too much timers
How to make/get more tests?

The bad start problem

Managing the timer list, calling functions, etc. take time and use a lot of cycle. With a brute implementation like:

  1. program the timer with the expires value,
  2. wait until the interrupt is fired,
  3. call the timer function.
cycles are lost until the timer function is called.

Moreover, the APIC timer is based on the bus clock, not the processor clock, but the timers are programmed with a value from the TSC based on the processor clock. So it is necessary to convert the expires value from "processor" unit to "bus" unit.
The problem is we do not know with such a high precision the values of the processor and the bus clocks, and since the processor clock is generally five times bigger than the bus clock, we also loose a lot of precision here.

So without any error management functions, the latency is big (2000 cycles, maybe more, ie a few us). That's why the module implements a mechanism to measure the error of the precedent timer issued and to try to correct the programmation of the next timer.

The test shows this mechanism is effective, but since the error correction uses the precedent timer issued to adjust the programmation of the next one, the latency of the first timer is always bad.

A simple example

This examples creates some timers with expires values betweem current TSC + 100 and current TSC + 600000.

With the exception of the bad start problemm the latency stays slow, wiht an average error < 400 cycles (1 us on a 450 MHz PC)

More timers

If a lot of timer are created and added to the timer list, the module performs well if the expires value is big enough.

With the following example, 30 timers are added to the list, with an expires value greated than the current TSC + 10000.

	for (id_cnt = 1; id_cnt < 30; id_cnt++) {
      		test_create_and_add_timer(id_cnt, 0, id_cnt * 10000, test_fn);
	}

and it performs well:

Too much timers...

If a lot of timers are created and should be issued in a short amount of time, the modul does not follow and the latency can grow really fast!

	for (id_cnt = 1; id_cnt < 30; id_cnt++) {
      		test_create_and_add_timer(id_cnt, 0, id_cnt * 1000, test_fn);
	}

and:

The error is big, even much bigger than shown by the max error field of /proc/apic_timer (4000 cycles).

How to make/get more tests?

All tests are produced by the test scripts in test_apic_timer.c

To use one of these test, just use the script iall. For example:

     ./iall 4 2
to launch the test script number 4 with the output function 2 (use this output functions to produce graphs).
If you cleaned the kernel messages buffer before with dmesg -c, you can use the get_datas.pl script to extract the measurements from the dmesg output,
and build_plots.pl to convert the data in a nice graph (requires gnuplot).

vincent at oberle dot org