From: Klistvud on
Howdie, fellow Debianites!

I've bee all over uncle G to crack this one, but to no avail. In short:
how would you go about launching a program when the computer is idle,
and launching another program when the computer stops being idle?
Specifically, I'd like my computer to switch CPU governors from
powersave to performance and vice versa, with "cpufreq-set --governor
foobar".
What I've tried so far:
* loadwatch: can make it switch governors when average load drops, but
can't make it do zilch when average load rises (at that point loadwatch
just *freezes* the target program, so it basically can't *do* anything)
* xautolock: ditto. It has provisions for launching a program when X is
idle (no keyboard/mouse activity), but has no provisions for launching
anything when X *ceases* being idle
* another approach I haven't been able to try out because of my very
non-existent bash skills: writing a script to periodically
parse/cut/grep the output of the "w" command and launch the
corresponding CPU governor.

Are there other -- preferably easier -- approaches to this? As you may
see, I'm not being picky as to how "idle" is defined: it may be no X
usage, it may be low average load, it may be no user activity, you
choose.

Why I need this: my Pentium IV uses the p4_clockmod cpu scaling module,
which has a high latency. Using the (recommended) ondemand CPU governor
yields a very noticeable lag and leaves the CPU at low clocks even when
maximum performance is required. With the performance CPU governor, on
the other hand, the things feel real snappy again, but the fans start
to roar and heat to build up, so I'd really like it to switch to
powersave when not in use.

--
TIA, and excuse the verbosity (English is not my "mother's thong")

Klistvud
Certifiable Loonix User #481801
http://bufferoverflow.tiddlyspot.com


--
To UNSUBSCRIBE, email to debian-user-REQUEST(a)lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster(a)lists.debian.org
Archive: http://lists.debian.org/1275471774.5543.1(a)compax
From: Carl Johnson on
Klistvud <quotations(a)aliceadsl.fr> writes:

> Howdie, fellow Debianites!
>
> I've bee all over uncle G to crack this one, but to no avail. In short:
> how would you go about launching a program when the computer is idle,
> and launching another program when the computer stops being idle?
> Specifically, I'd like my computer to switch CPU governors from
> powersave to performance and vice versa, with "cpufreq-set --governor
> foobar".
-- snip --
> Are there other -- preferably easier -- approaches to this? As you may
> see, I'm not being picky as to how "idle" is defined: it may be no X
> usage, it may be low average load, it may be no user activity, you
> choose.
>
> Why I need this: my Pentium IV uses the p4_clockmod cpu scaling module,
> which has a high latency. Using the (recommended) ondemand CPU governor
> yields a very noticeable lag and leaves the CPU at low clocks even when
> maximum performance is required. With the performance CPU governor, on
> the other hand, the things feel real snappy again, but the fans start
> to roar and heat to build up, so I'd really like it to switch to
> powersave when not in use.

Do you know what your actual latency is? When you have the ondemand
governor selected, you can check by 'cat
/sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate' to get
the latency in microseconds. You can write to that any value between
'sampling_rate_min' and 'sampling_rate_max' (in the same directory).
I suspect any manual selection you figure out will be slower than
that. On my Athlon II computer the default latency is 80000 (80msec)
which is faster than I really need, so I actually slow it down a
little. If you have multiple cpus or cores then you will need to
change all of them.
--
Carl Johnson carlj(a)peak.org


--
To UNSUBSCRIBE, email to debian-user-REQUEST(a)lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster(a)lists.debian.org
Archive: http://lists.debian.org/87ocftpf72.fsf(a)cjlinux.localnet
From: Carl Johnson on
I forgot to mention in my previous response that the kernel
documentation has some information about the frequency governors. The
'linux-doc-*' debian packages have the kernel documentation, and the
directory 'Documentation/cpu-freq/' contains the information that I
used. You also might want to look at the 'conservative' governor. It
will decrease speed slower, but it also increases speed slower. I
have been testing FreeBSD and its driver seems to increase speed
quickly, but drops it back down slowly.
--
Carl Johnson carlj(a)peak.org


--
To UNSUBSCRIBE, email to debian-user-REQUEST(a)lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster(a)lists.debian.org
Archive: http://lists.debian.org/87k4qhpe3z.fsf(a)cjlinux.localnet
From: Klistvud on
Dne, 02. 06. 2010 18:33:21 je Carl Johnson napisal(a):
>
> Do you know what your actual latency is? When you have the ondemand
> governor selected, you can check by 'cat
> /sys/devices/system/cpu/cpu0/cpufreq/ondemand/sampling_rate' to get
> the latency in microseconds. You can write to that any value between
> 'sampling_rate_min' and 'sampling_rate_max' (in the same directory).

Thanx for the tip, Carl, I didn't know that. My actual latency appears
to be 1 s.

> I suspect any manual selection you figure out will be slower than
> that. On my Athlon II computer the default latency is 80000 (80msec)
> which is faster than I really need, so I actually slow it down a
> little.

No such luck here. My sampling_rate_min is 500000 (yes, half a second),
so even lowering the latency from 1s to 0.5s, as you can imagine,
doesn't help much: it still takes almost a second just to switch from
one tab to the next in Iceweasel. While such common GUI tasks are so
slow that I can almost hear them crying for help, my 3 GHz CPU remains
stubbornly at 375 MHz (as checked via "watch cpufreq-info"). The
ondemand governor obviously just can't be bothered.

> If you have multiple cpus or cores then you will need to
> change all of them.

It would seem that on my system (Pentium IV HT @ 3GHz) I only have to
change one CPU and the other follows suit.

--
Thanx for your time,

Klistvud
Certifiable Loonix User #481801
http://bufferoverflow.tiddlyspot.com


--
To UNSUBSCRIBE, email to debian-user-REQUEST(a)lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster(a)lists.debian.org
Archive: http://lists.debian.org/1275514528.6061.0(a)compax
From: Carl Johnson on
Klistvud <quotations(a)aliceadsl.fr> writes:

> Dne, 02. 06. 2010 18:33:21 je Carl Johnson napisal(a):
>>
>> I suspect any manual selection you figure out will be slower than
>> that. On my Athlon II computer the default latency is 80000 (80msec)
>> which is faster than I really need, so I actually slow it down a
>> little.
>
> No such luck here. My sampling_rate_min is 500000 (yes, half a second),
> so even lowering the latency from 1s to 0.5s, as you can imagine,
> doesn't help much: it still takes almost a second just to switch from
> one tab to the next in Iceweasel. While such common GUI tasks are so
> slow that I can almost hear them crying for help, my 3 GHz CPU remains
> stubbornly at 375 MHz (as checked via "watch cpufreq-info"). The
> ondemand governor obviously just can't be bothered.

My old Athlon 64 was similar to that, so I had a script setup to
quickly switch to high speed, and a timout option. I would use that
at times when I wanted to run several small programs so they would
avoid the delay, but then if I forgot it would drop the speed back.
They aren't very long, so I will list them here. Both of these must
be run by sudo since cpufreq-set requires root permissions.

I had buttons setup on the desktop panel so I could just press the
fast button to run 'sudo fast -t 300' for 5 minutes of fast
operation. That is definitely crude, but it worked for most things I
wanted. I also had a slow program, but that was only because that cpu
would sometimes get stuck in a faster speed.

---- start /usr/local/bin/fast ---
#!/bin/sh

unset timeout
freq=`cpufreq-info -f`

while getopts "t:" opt
do
case $opt in
t)timeout=$OPTARG
;;
*) echo usage: $0 [-t <seconds>]
exit 1
;;
esac
done

cpufreq-set -g performance

if [ $timeout ]
then
(sleep $timeout;ondemand)&
fi
exit 0
---- end /usr/local/bin/fast ---

---- start /usr/local/bin/ondemand ----
#!/bin/sh

cpufreq-set -g ondemand

exit 0
---- end /usr/local/bin/ondemand ----

--
Carl Johnson carlj(a)peak.org


--
To UNSUBSCRIBE, email to debian-user-REQUEST(a)lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster(a)lists.debian.org
Archive: http://lists.debian.org/87d3w9ozgt.fsf(a)cjlinux.localnet