Menu

#5 Optimize the clock interrupt handler

open
None
3
2011-07-03
2011-07-03
No

The 256 Hz interrupt (Int 1) handler takes about 3700+ CPU clock cycles to complete. At 12 MHz the interrupt fires every 46875 cycles, so the handler takes about 8% CPU time all the time. Some of the tasks that it performs do not need to be done this often or can be streamlined. Some changes that can be made include:

* replace calls to BUMPNTIME() with simpler (faster) increments (of a long long variable, for example)
* move load average computation to a callout (set a repeating timeout for every 5 seconds)
* optimize calls to sched_tick() (eg, set a timeout)
* calculate per-process cpu usage with a timeout
* move scankb() to a callout/soft interrupt

As the time of day doesn't matter to anything but gettimeofday(2), that system call can convert tick counts to seconds and microseconds itself. The time of day is also maintained more accurately via the 1Hz timer (Int 3) anyway. Handling time adjustments (via adjtime()) might be tricky, though.

Discussion


Log in to post a comment.

MongoDB Logo MongoDB