Have read all I can find relating to this topic but still feeling insufficiently informed.
As others have posted, I have found that some applications like Ktorrent “go to sleep” and through trial and error have determined it’s likely because once setup, I run it minimized while I’m doing other work. This seems to affect the priority of the application, putting it to sleep when the application isn’t “on top” of the desktop. Bringing the application to the fore seems to restore priority and becomes “active” again.
It looks like Linux (and OpenSuSE) employs a Scheduler module which manages running processes (I don’t think it’s actually granular to the thread), and a module called “nice” that runs on top of that which “advises” the Scheduler. Modifying the Scheduler directly is not recommended, using the nice (and renice) commands are recommended.
Is there an overall desktop configuration that applies a template to adjust foreground and background application priorities broadly? - Comparing to Windows, this is known to be one of the main differences between the Desktop and Server editions, and within parameters of the Product can be modified after installation.
My experimentation adjusting the Ktorrent application’s priority is mixed and may be colored by the availability of the file and other variables. I suspect though that the “advice” sent to the Scheduler is not sufficient to overcome overall and competing process priorities. Also, a telling symptom is that every time I click directly on the application (Ktorrent) bringing the application to the forefront, the speed increases immediately. So, is there a more detailed reference somewhere regarding how OpenSuSE sets application priorities (eg forefront, background, minimized, tray, no GUI, etc)
Some useful commands for those who are new to setting application priority
You can invoke System Activity (CTL-ESC), rt-click on the application process and set priority (haven’t checked whether this is immediately effective on a running priority, my guess is yes)
Display all processes including Priority and PID
Display a specific application’s Priority and PID, note that when I run this the column headers aren’t displayed. Displaying the above command (without grep) displays column headers.
ps axl | grep *applicationname*
Modify the process priority of a non-running process, range -2020 where the lower the n the higher the priority
nice -n *PID*
Modify the process priority of a running process, range -2020 where the lower the n the higher the priority
You call them non-running and running. but it’s more accurate to say that nice creates a process with an adjustment to the initial priority, while renice modifies the priority of a process. So the argument to nice is not a pid as the process doesn’t exist yet. The arguments are the command to start and its arguments. All in the man page. The teminology running/non-running can be confused with being in the run state or sleeping (waiting for an event), as shown by ps.
Also note that normal users can only increase the niceness, never the other way or their processes could hog the machine.
I’ll leave the other questions for others. I’ve never had problems running torrents but then I use aria2c. I’ve also not needed to adjust priorities of programs except when I know something might be long running, like a media encoding process.
After ken_yap’s post,
Did some further experimentation and sure enough, it does look like renice seems to only create a new process during the current application’s session so the setting is not persistent.
After more experimentation and reading the references more closely I can’t seem to find a command that can be run that modifies a specific application’s default priority. Although renice seems to work just fine as I described for the existing session, I can’t seem to find where SuSE may be setting each application’s default priority, the only examples I’ve been able to find using nice are in a “pre-launch” config file.
I guess unless there is a way to modify whatever SuSE uses internally, it seems to me that the next best approach might be to modify the application shortcut(s) to a custom executable script file that would call nice to set priority while launching the app.
BTW - For anyone looking for specific information running Ktorrent in the background, I’ve found that setting the priority to -20 seems to do the job (prevent the app from going to sleep). Anything less than -20 seems to be ineffective which suggests that SuSE automatically promotes an application “with focus” (eg last clicked by a mouse) to -20 regardless what is reported in ps or elsewhere).
I use KTorrent often and never had these troubles - and I doubt it makes a difference whether an application is visible on the desktop or minimized into a tray, in both cases it is running. You can check the nice value of an application via ‘top’ in a console (the ‘n’-column). My KTorrent runs with a ‘0’ nice-value, which is the default for most apps. I highly doubt that will be different on your system.
I do not find any settings in KTorrent referring to niceness or priority, yet you could try moving / renaming KTorrents config-files (~/.kde4/share/config/ktorrentrc and ~/.kde4/share/apps/ktorrent/) and restart it. Another way to test this would be creating a new user and let him start KTorrent.
Renice doesn’t create a new process, it modifies the priority of an existing process. If the process is terminated when you logout then of course the any niceness disappears with it so of course it’s not persistent. Your model is a bit of sync with reality.
Yes, and I doubt that any application will have that setting within an app, I generally view this as a KDE or SuSE type of management config, not typically within an app. I’m not sure what the objective might be to move/rename the Ktorrent config file (I assume hoping for regeneration)?
The default value is zero like practically all other applications.
As I described and others have posted in numerous threads, ktorrent seems to go inactive when it’s not touched (and generally in the background) for a long period of time, then when clicked (appy focus) I’ve noticed the speed immediately increase.
When ktorrent is running in the background, I usually have FF open and typically if I’m researching two or three different things I’l have somewhere between a dozen to two dozen tabs and windows open at once, all according to ps likely with priority -20 on an Intel Core2Duo machine which likely means that the CPU main pipelines are full.
The other circumstantial observation is that I’ve found that modifying nice to the maximum priority (-20) really does solve the problem for me… so far.
On 2010-10-22 16:06, tsu2 wrote:
> gropiuskalle;2241802 Wrote:
>> Just to make sure that no configuration of the app itself is messing
>> with the niceness.
>> What nice value is shown for KTorrent in ‘top’ anyway? What makes you
>> think the nice value is the source of the symptoms you described?
> The default value is zero like practically all other applications.
> As I described and others have posted in numerous threads, ktorrent
> seems to go inactive when it’s not touched (and generally in the
> background) for a long period of time, then when clicked (appy focus)
> I’ve noticed the speed immediately increase.
If that is true, it is a problem with ktorrent itself. I would try another torrent program.
Cheers / Saludos,
Carlos E. R.
(from 11.2 x86_64 “Emerald” at Telcontar)
> If that is true, it is a problem with ktorrent itself. I would try another torrent program.
i’m using ktorrent (KDE 4.5.2 an earlier, since KDE 4.2, i think) and never found it sleeping on the job. what i sometimes doubt is it’s wisdom in selecting among the available seeds. sometimes it gets slow, but opening the window in the foreground doesn’t help. what does help, but not always, is stopping the transfer and starting again. once in a while i find that it’s still got some connections open (via ksysguard), which i kill before restarting the download.
An additional note to anyone who uses this thread to invoke/modify niceness…
renice almost always will run without any issue modifying a running process.
On the other hand nice can be difficult to setup. Unlike renice which allows you to set a specific value, nice only modifies the value in relation to whatever the default value. Also, depending on the manner and environment nice is invoked will affect the actual direction (positive or negative) so it’s highly advisable to lookup actual examples for the very specific way you intend to use nice.
Lastly, I’ve found that although applying nice to scripts may be not difficult, applying to a GUI program, particularly a KDE application is a real headache, possibly more than it’s worth compared to just doing a renice after the application has launched.