iesd - Interactivity Enhancing Shell Daemon

Recently on the LKML there was a lot of excitement when a nearly 200 line patch to the kernel was posted which grouped CPU scheduling to each TTY. This alone improved interactivity hugely, enabling people to do crazy things like 'make -j64'ing kernels whilst playing movies and browsing the web all at the same time. A little later in the thread a four line shell implementation was given that improved things even further.

Both the kernel patch and shell script have their advantages and disadvantages:

  • kernel
  • shell
    • advantages
      • no need to patch your kernel (should work since kernel 2.6.24)
      • effect is the same
    • disadvantages
      • depends on bash
      • does not feel 'correct' putting the logic into the users shell script
      • grouped by TTY and not Session ID (SID)

So, to try and find a well blended solution, I opted to put together a shell daemon that groups tasks firstly by User ID (regular users on the system, ignoring system processes) and then with a second level of grouping by Session ID.

Download is available at https://github.com/jimdigriz/iesd

The daemon should work on kernels since 2.6.24 (tested with 2.6.32) supporting grouping CPU scheduling, and if your kernel is equal or newer than 2.6.38 it also has the ability to group task disk IO which improves things further (not done by sched_autogroup_enabled).

Save the daemon to '/usr/local/sbin' and make it executable ('chmod +x /usr/local/sbin/iesd'). Now run it by typing as root:

# iesd start

Stopping the daemon is easy:

# iesd stop

N.B. the daemon takes a while to start up and shutdown, so do not expect the effects to take place immediately

To make the daemon automatically load on boot, place the following in your '/etc/rc.local' file (TODO: use runit instead):

[ -f /proc/sys/kernel/sched_autogroup_enabled ] && echo 0 > /proc/sys/kernel/sched_autogroup_enabled
nohup /usr/local/sbin/iesd start || true

Thanks

Thanks to Steven Capper (@robotmonkeys.org.uk) for testing, giving feedback and suggestions plus providing some actual improvements; the 'brains' behind the 'quit()' subroutine.

Links

iesd.txt · Last modified: 2013/01/20 10:44 by alex
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Run by Debian Driven by DokuWiki