Jan Oksfeldt Jonasen <jonasenREMOVE@THISit.dk> wrote:
> Thomas Boelskifte <engineering@boelskifte.dk> wrote:
>
> > Du kan jo prøve at su til root og fyre følgende af:
> >
> > renice -10 -p `ps -ax | grep WindowServer | cut -c1-5 | sort | head -1`
> >
> En af de usandsynligt logiske kommandoer vi vil komme til at se ofte til
> mac'enn fremover
Ja, og jeg skal lige beklage at jeg ikke uddybede den bedre end det der.
Jeg fik gæster så indlæget røg bare ud af døren med det samme, sorry! :)
Herunder følger en tråd fra Shane Anderson's Xlist (ham med den nye
MacEvangelist). Det er lidt rodet da det er en mail videresent til mig
selv fra arbejde. Shane har desværre ikke et arkiv over indlæg oppe
endnu, så jeg kan ikke URL'e til det.
Men der er en detaljeret forklaring begravet i det, hvis man selv lige
gider dekode det
Jeg har slettet Jack's og Charles' mailadresser, hvis nogen vil i
kontakt med dem så mailer i mig bare, så sender jeg deres adresser.
Og Jan, jeg er helt enig, det er godt nok noget nyt. Men hva', det her
er hacks der vel ikke bliver nødvendige efter et par opdateringer. Og
jeg synes jo bare det er sjovt at lege med
======= herunder det oprindelige indlæg ======
Subject: Speed up Mac OS X - a quick fix
From: "Jack Shedd" <mmmm@mmmmm.com>
Date: Wed, 28 Mar 2001 09:08:08 -0600
--Apple-Mail-807947185-1
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
format=flowed;
charset=us-ascii
Hey Everyone,
One of my main complaints in OS X is how slow the Window Manager seems
to be.
Here's a fix:
renice -10 -p `ps -ax | grep WindowServer | cut -c1-5 | sort | head -1
"su" into root and run the above command.
It makes it a little faster.
--
Jack Shedd
===== herunder forklaringen på de enkelte kommandoer =====
Subject: re: What does 'renice' do?
From: "Charles C Wells" <nnnnn@nnnnnn.com>
Date: Wed, 28 Mar 2001 11:42:49 -0800
Jack Shedd provided this command to improve the performance of the
Window Manager (Server) in OS X:
renice -10 -p `ps -ax | grep WindowServer | cut -c1-5 | sort | head
-1
Here's an explanation of what that command does:
Short version: It gives the WindowServer process more CPU time which
should improve its performance.
Long version:
Let's start with the `ps -ax |grep WindowServer | cut -c1-5 | sort |head
-1` (<-note required close-quote)
ps provides "process status", the -a option indicates to include all
running processes not just ones started by your username, -x indicates
to include processes that are run without a controlling terminal, i.e.
system initiated processes. The output of 'ps -ax' on my system includes
the following:
[localhost:/Users/charlie] root# ps -ax
PID TT STAT TIME COMMAND
1 ?? SLs 0:00.13 /sbin/init
2 ?? SL 0:12.60 /sbin/mach_init
38 ?? Ss 0:01.85 kextd
56 ?? Ss 12:02.53
/System/Library/Frameworks/ApplicationServices.framework/.../ATSServer
(shortened for this example)
58 ?? S<s 38:32.14 /System/Library/CoreServices/WindowServer
60 ?? Ss 0:20.72 update
63 ?? Ss 0:05.11 dynamic_pager -H 40000000 -L 160000000 -S
80000000 -F /private/var/vm/swapfile
....
grep is a utility to search for an expression within a file or, in this
case, output from another command. The pipe symbol (|) is used as the
"connection" between ps and grep - i.e. "take the output of the ps -ax
command and pass it as input to grep". The other input to grep in this
command is the expression we're looking for, WindowServer. So the output
of 'ps -ax | grep WindowServer' is:
[localhost:/Users/charlie] root# ps -ax | grep WindowServer
58 ?? S<s 38:46.44 /System/Library/CoreServices/WindowServer
657 std S+ 0:00.01 grep WindowServer (<-note that 'grep
WindowServer' is it's own process...)
the cut command simply takes characters 1-5 (-c1-5) from the output of
the grep command, in this case giving us the Process ID number (PID):
[localhost:/Users/charlie] root# ps -ax | grep WindowServer | cut -c1-5
58
657 (<-remember, this is from the 'grep WindowServer' command)
We now send the output from 'cut' to 'sort', putting the lines into
order by PID (which in this case, they already were).
[localhost:/Users/charlie] root# ps -ax | grep WindowServer | cut
-c1-5 | sort
58
697
And finally, we want the first line, because we're assuming that the
earliest (i.e. lowest PID) process with "WindowServer" in the process
name, is, in fact, the one we want to send to, you guessed it, renice,
so here's the output from the command so far:
[localhost:/Users/charlie] root# ps -ax | grep WindowServer | cut
-c1-5 | sort | head -1
58
Now we have the PID of the WindowServer process, which here is 58. The
command then:
renice -10 -p`ps -ax |grep WindowServer | cut -c1-5 | sort |head -1` is
now effectively:
renice -10 -p58 (<-note 58 is output from the `ps -ax |grep
WindowServer | cut -c1-5 | sort |head -1` command)
so, in the end, renice reduces the "niceness" or "works and plays well
with others" rating of the WindowServer process by the default increment
of 10 for process 58 (-p58):
[localhost:/Users/charlie] root# renice -10 -p`ps -ax | grep
WindowServer | cut -c1-5 | sort | head -1`
0: old priority 0, new priority -10
BTW, the reason the single quotes (` `)are important is that they force
the commands between them to be evaluated by the OS first, passing the
result to the renice command.
Hope this is helpful.
CCW
Seattle, WA
****************************************************************
MacOSX: The power of UNIX, the beauty of Macintosh.
http://www.apple.com/macosx/
****************************************************************
--
"Mac users prefer the one-button mouse for one simple reason: They
click the mouse with their index finger; they reserve the next finger
over for when people tell them they should be using Windows."