Alternative To the 200-Line Linux Kernel Patch
climenole writes "Phoronix recently published an article regarding a ~200 line Linux Kernel patch that improves responsiveness under system strain. Well, Lennart Poettering, a Red Hat developer, replied to Linus Torvalds on a mailing list with an alternative to this patch that does the same thing yet all you have to do is run 2 commands and paste 4 lines in your ~/.bashrc file."
I've done some tests and the result is that Lennart's approach seems to work best. It also _feels_ better interactively compared to the vanilla kernel and in-kernel cgrougs on my machine. Also it's really nice to have an interface to actually see what is going on. With the kernel patch you're totally in the dark about what is going on right now.
-Markus Trippelsdorf
right from the article
What I don't get is why he uses
if [ "$PS1" ]; then
instead of
if [ -t 0 ]; then
Why the latter? Because it works, that's why:
# sh -c '[ "$PS1" ] && echo tty detected'
#
# sh -c '[ -t 0 ] && echo tty detected'
tty detected
The other way around, if a user has set PS1 in .profile, you'll get false positives, and cron jobs that will consume more than their fair share of resources.