[Hero, G2 Touch Android Development] androcheck:
First an introduction (sorry, if this got a little long, just wanted to make clear for everybody what we are talking about).

What is a scheduler?

The scheduler is a built-in part of the Linux kernel. It is that part of the kernel which decides how the available cpu power is divided among all running processes. As the cpu can only work for one process at any given time, the scheduler is responsible to assign cpu time-slices fairly to running processes.

Because of this the scheduler (among other things) plays an essential role on how responsive a system "feels" for the user. That's because responsiveness depends among other things on the time how long it takes from user input until the cpu handles the input (i.e. until "your" task/process gets cpu-cycles).

Current state of the art:

The standard Linux kernel uses the so called "Completely Fair Scheduler" (CFS) since some time (October 2007) now and seems to be useful for most use-cases (server, desktop, smartphone..).

As you may have already heard, since August 2009 there is a new player on the field, namely the "Brain **** Scheduler" (BFS). BFS promises some better latency behaviour on smaller platforms with fewer cpu-cores and mobile devices. Altough it wasn't accepted into the official Linux kernel tree, it was used by cyanogen and also adopted by Google into the mainline Android kernel (and as we are having kernel sources now, I'm sure you will see some more BFS-enabled kernels for the Hero, too).

But back to topic:

So, what I am going to talk about applies to those of you who DON'T have a kernel with the BSF scheduler (i.e. which have the standard CFS scheduler) which should be the majority of ROMs at the moment.

Tuning the CFS scheduler:

Even it's said that BFS may be better for small devices it's also possible to configure CFS for our needs:

While searching around I learned that the behaviour of the CFS scheduler can be influenced at runtime by a few parameters. All these settings can be applied at runtime and will be gone after a reboot. So it is safe to play around a little bit.

One interesting parameter I found was "NO_NEW_FAIR_SLEEPERS". As stated by some people on the Linux kernel mailinglist :

If this is true, maybe it will let the CFS behave better optimized for small devices.

But let's try it out! Let's see if it gives us some improvements. :)

How to to this:

# Step 1: Mount debugfs (which is a virtual filesystem like /proc/ or /sys/)
mount -t debugfs none /sys/kernel/debug

# Step 2 (optional): Display the current scheduler flags
cat /sys/kernel/debug/sched_features

# Step 3: Set the flag NO_NEW_FAIR_SLEEPERS
echo "NO_NEW_FAIR_SLEEPERS" > /sys/kernel/debug/sched_features

# Step 4: Unmount debugfs again
umount /sys/kernel/debug

As said before: These changes are NOT PERMANENT. They will be gone after a reboot. But therefore it's safe to play around here.

Testing:

Tuning the scheduler will not give you plain speed improvements, so testing with Linpack is useless here. Instead it changes the way how the system reacts if there is a lot of multi-tasking.

So when you have changed the settings try testing around a little bit when the system is under load (like playing music while doing CPU intensive stuff or things like that) and report if it behaves better/worse than with default settings.

How to undo the setting:

Simple reboot your phone.

Or redo the steps above and replace the command in Step 3 with this one (note that the prefix "NO_" is ommited here):

echo "NEW_FAIR_SLEEPERS" > /sys/kernel/debug/sched_features

Feel free to test and share your findings! :)