Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Using 'nice' to improve desktop performance
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
max_colby
Tux's lil' helper
Tux's lil' helper


Joined: 30 Nov 2002
Posts: 149
Location: Ottawa, Canada

PostPosted: Fri Dec 06, 2002 9:54 am    Post subject: Using 'nice' to improve desktop performance Reply with quote

A couple of threads have discussed using 'renice' to improve the responsiveness of the UIs on Gentoo: particulary, by setting Nautilus to have a nice value of -1, as opposed to 0 to speed up icon drawing, and more importantly, setting X to a nice value of -10 as opposed to 0. I have been using these setting for awhile and things seem to 'feel' snappier.

My question is, what is the best way to have these setting run themselves? If I could set both to start at a different 'nice' value, all users would benefit from the settings as well. I am more interested in getting X to start at -10, but both would be ... nice. :?

Here is a related thread, for those interested:
https://forums.gentoo.org/viewtopic.php?t=2631

Thank you!
Back to top
View user's profile Send private message
sentenza
n00b
n00b


Joined: 05 Dec 2002
Posts: 30

PostPosted: Fri Dec 06, 2002 1:00 pm    Post subject: Renicing X and KDE Reply with quote

Hi,

After some test, i think that you can create a new startx script launching original startx reniced:

mv /usr/X11R6/bin/startx /usr/X11R6/bin/startx_2

create a startx script in /usr/X11R6/bin:
#!/bin/bash
nice --15 /usr/X11R6/bin/startx_2 @

Thereafter, all programs launched by X will herit this priority, so to have kde running with prio -13, you should launch kde in your .xinitrc file reniced by 2 :

nice -2 /usr/kde/3/bin/startkde

The problem is that now, only root can start X as standard users can only nice positively (lower prio).

Another solution is perhaps to launch your compilations with a lower priority :

nice -10 emerge mozilla

Hope this will help you
Back to top
View user's profile Send private message
zhenlin
Veteran
Veteran


Joined: 09 Nov 2002
Posts: 1361

PostPosted: Fri Dec 06, 2002 2:09 pm    Post subject: Reply with quote

Ahem. To compile using nice of negative values only speeds things up when building, but not when executing.

To make X -10, renice X to -10 after launching but before coming out of root. The subprocesses will not inherit the -10 unless new ones are spawned.
Back to top
View user's profile Send private message
kappax
Apprentice
Apprentice


Joined: 30 Aug 2002
Posts: 273
Location: The Moon

PostPosted: Fri Dec 06, 2002 6:02 pm    Post subject: Reply with quote

I bet someting could be set up witch sudo :P

make a script as root that will execute the commnad to renice a pid

make it so a user can use sudo without a password to renice someting.

for security you might want to make it like

sudorenice xfree kde mozilla

and the scrippt would check and see if that user can rnice xfree or kde or mozilla

something on thoes lines i think might do it.
Back to top
View user's profile Send private message
max_colby
Tux's lil' helper
Tux's lil' helper


Joined: 30 Nov 2002
Posts: 149
Location: Ottawa, Canada

PostPosted: Thu Dec 12, 2002 8:16 am    Post subject: Reply with quote

I've finally found a straight-forward solution to this problem
kerframil wrote:
Quote:
Kerframil, would you be so kind as to post that wrapper script?


My pleasure. You have Casey Cain (cjv99@shaw.ca) to thank for this one, I hope he won't mind me reproducing it here. Here's the code:
Code:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>

const char *app = "/usr/X11R6/bin/XFree86";   // the actual binary
const int root = 0;   // root's uid
const int n = -10;    // desired nice priority valid range -20..20.

int main(int argc, char **argv)
{
  seteuid(root);    // The X server must be started as root under any Linux
  nice(n);          // Makes it nice
  execv(app, argv); // This is it!
  /* Should never see this unless *app points to invalid binary */
  fprintf(stderr, "Failed to execv %s with nice value of %d\n", app, n);
  exit(1);
}
Save it as wrapper.c. Now compile it (you can compile as a normal user):
Code:
$ gcc wrapper.c -o XFree86.wrapper
Ensure that /usr/X11R6/bin/X is a symlink to /usr/X11R6/bin/XFree86, it should be. Now proceed as follows (you'll su to root as the first step):
Code:
# su
# cp XFree86.wrapper /usr/X11R6/bin
# cd /usr/X11R6/bin
# rm X
# chown root:root XFree86.wrapper
# chmod u+s XFree86.wrapper
# ln -s XFree86.wrapper X
# exit

Et voila! Change the value of the n constant in the source code to whichever nice value you want before compiling. The above uses -10 which is halfway between normal priority and maximum priority. You can use this technique for any binary in a similar fashion (you'd need to rename the original binary in most cases and set the app constant to the path of the renamed binary. You should experiment with different nice values for X and your problem apps. Remember, you can experiment while you're up and running by using the renice command live as root before you mess around with creating wrappers. You only need to determine the process number of the app you're renicing.
This can also be used for other applications which is very useful
Back to top
View user's profile Send private message
kappax
Apprentice
Apprentice


Joined: 30 Aug 2002
Posts: 273
Location: The Moon

PostPosted: Wed Jan 15, 2003 5:23 am    Post subject: Reply with quote

I have some patch in my kernel that lets users in a sertan guid renice things :p

so i now have x running at -2 and mozilla -1 , i dont think i am going to see any differenc between -2 and -10, because for the most part everything else runs at 0 and -2 will still be higher than 0 any day
Back to top
View user's profile Send private message
phunkphorce
Tux's lil' helper
Tux's lil' helper


Joined: 22 Nov 2002
Posts: 145

PostPosted: Wed Jan 15, 2003 9:26 am    Post subject: Reply with quote

kappax wrote:
I have some patch in my kernel that lets users in a sertan guid renice things :p

so i now have x running at -2 and mozilla -1 , i dont think i am going to see any differenc between -2 and -10, because for the most part everything else runs at 0 and -2 will still be higher than 0 any day

To make mozilla feel faster you might want to try reading this thread: https://forums.gentoo.org/viewtopic.php?t=29226 (I know, I know, it's my own thread but I though you could be interested in it 8))
_________________
O God, Thou art in Heaven...
...please stay there!
Back to top
View user's profile Send private message
kappax
Apprentice
Apprentice


Joined: 30 Aug 2002
Posts: 273
Location: The Moon

PostPosted: Wed Jan 15, 2003 2:57 pm    Post subject: Reply with quote

phunkphorce wrote:
kappax wrote:
I have some patch in my kernel that lets users in a sertan guid renice things :p

so i now have x running at -2 and mozilla -1 , i dont think i am going to see any differenc between -2 and -10, because for the most part everything else runs at 0 and -2 will still be higher than 0 any day

To make mozilla feel faster you might want to try reading this thread: https://forums.gentoo.org/viewtopic.php?t=29226 (I know, I know, it's my own thread but I though you could be interested in it 8))


thanks, heh but i had done that, I mean faster as in the gfx part, Faster when i scrool down a page, feels much much smother when moving around. heh your tips had already helped me acheive fast page loads :) THanks!!
Back to top
View user's profile Send private message
phunkphorce
Tux's lil' helper
Tux's lil' helper


Joined: 22 Nov 2002
Posts: 145

PostPosted: Wed Jan 15, 2003 3:00 pm    Post subject: Reply with quote

kappax wrote:
thanks, heh but i had done that, I mean faster as in the gfx part, Faster when i scrool down a page, feels much much smother when moving around. heh your tips had already helped me acheive fast page loads :) THanks!!

So then, does it really feel faster if you renice things like X and Mozilla? Can you "feel" any improvement over the previous situation? (I know that this kind of things are rather subjective, but I'd like to know anyway...)
_________________
O God, Thou art in Heaven...
...please stay there!
Back to top
View user's profile Send private message
gerb
n00b
n00b


Joined: 15 Jan 2003
Posts: 1
Location: Oregon, USA

PostPosted: Wed Jan 15, 2003 7:53 pm    Post subject: Re: Using 'nice' to improve desktop performance Reply with quote

max_colby wrote:
My question is, what is the best way to have these setting run themselves? If I could set both to start at a different 'nice' value, all users would benefit from the settings as well. I am more interested in getting X to start at -10, but both would be ... nice. :?


My main development box at work runs Mandrake 8.2, and I think they do this by default. When running XDM/KDM/GDM as a graphical login manager, it starts the X server process at a higher 'nice' value.

In the XDM configuration file /etc/X11/xdm/Xservers the server entries look like this:

Code:
:0 local /bin/nice -n -10 /usr/X11R6/bin/X :0


Applying that to Gentoo's configuration, I would try something like this:

Code:
:0 local /usr/bin/nice -n -10 /usr/X11R6/bin/X :0


(The trailing :0 tells the X server which display to use. You probably don't need to worry about this unless you run multiple X instances on the same workstation.)

The end result is that the X server process is run as root with the higher priority value, since XDM/KDM/GDM run as root, and all of its spawned processes inherit a normal (zero) nice value. It does seem to make a difference in performance.

Hope this helps...
_________________
--
The Weasel Wrangler
Back to top
View user's profile Send private message
Scorp
Tux's lil' helper
Tux's lil' helper


Joined: 16 Feb 2003
Posts: 118

PostPosted: Sun Apr 13, 2003 5:38 pm    Post subject: Reply with quote

hmm on my gentoo box if I run nice -10 nautilus it works? (I'm doing this as a regular user in group wheel) so now do I just make my x start with "nice -10" and that should speed it up? thanks.
_________________
PowerBook G3, 400 Mhz, 192 megs of Ram Running Gentoo 1.4 and XFCE4
Back to top
View user's profile Send private message
Lovechild
Advocate
Advocate


Joined: 17 May 2002
Posts: 2858
Location: Århus, Denmark

PostPosted: Sun Apr 13, 2003 5:43 pm    Post subject: Reply with quote

Renicing X is an evil hack to get around a nasty bug in the Linux scheduler..
Back to top
View user's profile Send private message
cerri
Bodhisattva
Bodhisattva


Joined: 05 Mar 2003
Posts: 2957
Location: # init S

PostPosted: Sun Apr 13, 2003 8:04 pm    Post subject: Reply with quote

Yep.
The gaming source has a patch to avoid that bug (have a look here.
_________________
Enjoy your freedom.
Sex is like hacking. You get in, you get out, and you hope you didnt leave something behind that can be traced back to you.
<----------------------->
Andrea Cerrito
Back to top
View user's profile Send private message
shm
Advocate
Advocate


Joined: 09 Dec 2002
Posts: 2380
Location: Atlanta, Universe

PostPosted: Sun Apr 13, 2003 8:17 pm    Post subject: Reply with quote

Or.. instead of using a hackish technique, you can use a kernel that speeds things up automatically, like ck-sources, gaming-sources, and 2.5.xx :)
Back to top
View user's profile Send private message
fca
Guru
Guru


Joined: 22 Feb 2003
Posts: 345
Location: Netherlands

PostPosted: Sun Apr 13, 2003 8:27 pm    Post subject: Reply with quote

I've been working with a gss-sources 2.4.21-pre7 with a load of over 4 and with the low-latency patch and pre-emptive scheduling, it behaved quite nicely, though loading-times were a little longer :wink:
Though I'm gonna try this, if just for kicks.
Back to top
View user's profile Send private message
fca
Guru
Guru


Joined: 22 Feb 2003
Posts: 345
Location: Netherlands

PostPosted: Sun Apr 13, 2003 8:41 pm    Post subject: Reply with quote

Hehehe...
Emerging 3 things at once, XMMS playing, but not skipping, load right at 6, and scrolling in Konqueror is smooth as a baby....
This is evil :twisted:
But not very good for compile times I reckon. Well, whatever...
Back to top
View user's profile Send private message
Schmolch
l33t
l33t


Joined: 16 Jun 2002
Posts: 746
Location: Germany

PostPosted: Mon Apr 14, 2003 5:45 pm    Post subject: Reply with quote

I have a question:

I reniced nautilus and XFree and it felt nicer.
So i tried to get X auto-reniced and modified Xserver like suggestet in this thread. It had no effect and then i thought:
Hey you dumbass, yes you, dont you use gdm?
So i edited gdm.conf the same way, but then it says:
/usr/bin/nice: command not found.
Of course i have nice, and nice works when i start it with /usr/bin/nice.
Any idea?
Do i need to edit Xserver or gdm.conf?
And what could be the reason, X fails to start with
"/usr/bin/nice -n -10 /usr/blabla/X" in gdm.conf?
Isnt it one command (nice) plus /blabla/X as argument?

And just in case sophisticated aliens observe this forum, you can post anonymous here, you just need a valid email-adress!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum