Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Community > Team MacNN > Dnet client doesn't give up all its CPU time

Dnet client doesn't give up all its CPU time
Thread Tools
Addicted to MacNN
Join Date: Jan 2000
Location: Stoneham, MA, USA
Status: Offline
Reply With Quote
Jan 17, 2004, 06:37 AM
 
Has anyone else noticed this? When dnet is running, it slows apps like ffmpeg, Photoshop, Stuffit and more, down by 30% or sometimes more. And quitting dnet gives a very clear solid boost to your other apps. It kind of sucks that running dnet slows you down, its like paying for a dual 1.25 but only getting a dual 867. I hope they can do something about it. Their feature to pause if other specific apps are running also doesn't work right, so you're really stuck. It'd be nice is someone made a dnet switch you could stick in your menu bar to turn it on and off when needed.
     
Addicted to MacNN
Join Date: Jan 2001
Location: The Sar Chasm
Status: Offline
Reply With Quote
Jan 17, 2004, 08:05 AM
 
SetiDockling handles dnet clients as well as seti, I believe. I haven't used it to run dnet, but if it works as well as it does with seti, you should be all set.

CV

When a true genius appears in the world you may know him by this sign, that the dunces are all in confederacy against him. -- Jonathan Swift.
     
Forum Regular
Join Date: Feb 2003
Location: Sundsvall, Sweden
Status: Offline
Reply With Quote
Jan 17, 2004, 08:42 AM
 
i have about the same problem as you but with F@H: http://forums.macnn.com/showthread.p...hreadid=195478

here is a menu extra i made(requires Menu Extra Enabler or MenuCracker(if you have MenuMeters installed for example, MenuCracker is automatically intalled)):
dnetc_Menu_Extra.menu.tgz
(Last edited by ul1984; Jan 17, 2004 at 01:43 PM. )
     
l008com  (op)
Addicted to MacNN
Join Date: Jan 2000
Location: Stoneham, MA, USA
Status: Offline
Reply With Quote
Jan 17, 2004, 10:41 PM
 
http://n0cgi.distributed.net/bugs/show_bug.cgi?id=3566

I submitted a bug, which means in 3 years they might have this sorted out :-/
     
Moderator Emeritus
Join Date: Dec 2000
Location: College Park, MD
Status: Offline
Reply With Quote
Jan 18, 2004, 12:06 AM
 
You submitted the "bug" to the wrong place. You meant to send it to the kernel developers for every *nix based OS.
But don't worry, Windows NT doesn't have the problem you see.
My website
Help me pay for college. Click for more info.
     
l008com  (op)
Addicted to MacNN
Join Date: Jan 2000
Location: Stoneham, MA, USA
Status: Offline
Reply With Quote
Jan 18, 2004, 12:13 AM
 
I don't see where its the wrong place?
     
Moderator Emeritus
Join Date: Dec 2000
Location: College Park, MD
Status: Offline
Reply With Quote
Jan 18, 2004, 12:52 AM
 
I answered that in my post. Read it again.
My website
Help me pay for college. Click for more info.
     
Administrator
Join Date: May 2000
Location: California
Status: Offline
Reply With Quote
Jul 4, 2004, 03:15 PM
 
I wanted to explain the issue of idle priority at the time, and why it is a kernel problem, but was tied up. It's a "little" bit late, but here it is. Hope it was worth the wait.

Unix-like systems, including UNIX, BSD, OSX, Linux, and Minix all have a scheduler in the kernel. The scheduler is responsible for setting priorities for different threads, which it does by allocating "time slices". On bootup, the kernel checks what speed of CPU it is running on and sets a reasonable minimum time slice. You can see this happen on OSX during bootup, but the text passes by quickly, so get it from the system log file located at:

/VolumeName/private/var/log/system.log

If you have not rebooted in awhile, the bootup text will first end up being archived in the rotating system.log.x.gz archives, where x = 0-9. Eventually, even that archive will get overwritten. Anyway, the text you are looking for looks like this: (notes in bold)
Code:
Jun 10 16:12:45 Minerva syslogd: restart start logfile daemon Jun 10 16:12:45 Minerva mach_kernel: standard timeslicing quantum is 10000 us determine timeslice Jun 10 16:12:45 Minerva mach_kernel: vm_page_bootstrap: 332389 free pages initialize VM system ...continued...
The kernel selects a time slice big enough for a thread to do something useful, but not so big as to make other threads seem unresponsive. In the example above from my system, the time slice is 10,000 microseconds / 10 milliseconds / 1% of a second on a 350 MHz CPU, which works out to 3.5 million CPU cycles per slice. I'd have expected the slices to be smaller, but that is what the logfile says.

During operation, the scheduler hands out time slices to threads based on their priority. If all threads are the same priority, each thread will get a slice, then the next thread gets a slice, until all threads have been given time and the schedule starts over. ("i" is the idle thread in the kernel)
1:2:3:4:5:6:i:
1:2:3:4:5:6: etc

A higher priority thread will get it's slice tacked in more often. For example, if thread #3 is max priority while all others are normal:
3:1:3:2:3:4:3:5:3:6:i:
3:1:3:2:3:4:3:5:3:6: etc

If thread #3 were max and everything else was at low priority:
333:1:333:2:333:4:333:5:333:6:
333:1:333:2:333:4:333:5:333:6: etc

A low priority thread amongst others may turn up only one cycle out of 10 and looks like this:
1:2:3:4:5:6:i:
1:2:4:5:6:i:
1:2:4:5:6:i:
1:2:4:5:6:
1:2:4:5:6:i:
1:2:4:5:6:i:
1:2:4:5:6:i:
1:2:4:5:6:
1:2:4:5:6:
1:2:4:5:6:i:
1:2:3:4:5:6: etc

In practice, most threads run at normal priority (0) while a few threads run at higher levels (-10) and a few more run at lower priorities (+10 like fix_prebinding) or minimum priority (+19). It is rare for a thread to run at max priority (-19) because it drags down everything else, this should happen only for critical things that need to execute ASAP, like a security reconfig or a repair operation on the boot disk, or a dedicated crunch box that is not expected to do anything else.

When a thread receives CPU, it can run through it's full slice or return the CPU to the kernel early. A thread that watches for input will check the input buffer, no buffered contents results in a quick abort. The scheduler notes an early return, and hands out a slice to the next thread early. If all threads in the schedule table exited early, then a slice goes to the idle thread. The scheduler could restart the schedule early, but if there is nothing to do in any thread, that is a waste of energy. Sending to the idle thread causes minimum CPU resources to be used - I'd imagine it's mostly a bunch of no-op commands or even a CPU sleep command. Even so, the idle thread still takes only one time slice, so the schedule will still restart quickly. If the user sets their system to maximum energy use, the idle thread may only make a note it was called, and exit immediately so the schedule can continue instantly.

If even one thread used their full slice during the schedule, the idle thread will not be called and the schedule will repeat until all threads exit early. When a DC client is running, the DC thread will almost always run it's full slice, so there is no idle thread activity unless the client needs to do some input / output to the disk or internet.

You can see this in action by running top in Terminal. It will report relative CPU use based on CPU time each thread used. It will also report Processes: 60 total, 3 running, 57 sleeping, 1 zombie... 149 threads.
Processess are applications, which may spawn more than one thread - good for multiple CPU systems.
A running process is one with threads, where at least one used it's full slice.
A sleeping process means all it's threads exited early.
A zombie process is a process that has been killed, but the memory / VM system has not finished deallocating all it's assigned RAM, so it can't be removed from the schedule table yet. A zombie is not given a time slice, it is left in the table so you can see what the system is doing, until the system is done with it. The schedule table is most likely the master process table, so the memory system watches it. I'd guess that marking a process as a zombie in the table is what causes the memory system to notice that process and deallocate the relevant memory.

With just a few threads running and the rest exiting early, all threads get called frequently. My example hands out slices that are 1% of a second long, but if only 3 threads take their full slice and all the others collectively take 1 slice worth of time to exit, then the schedule table fully executes 25 times per second even with the full 149 threads. Even in this case, I would judge that with top updating one time per second, that the active threads will have exited early most of the time, they only need to have used one slice fully in order to be flagged as active. So the minimum number of times through the table in this example is a little under 100 times per second, and is likely 50-90 times unless a thread maxes out the CPU actually doing something.

Schedulers can get more fancy with some threads. A CD burning thread may require a slice 10 times per second, and the scheduler will guarantee that, making sure the burner thread gets called that often. No buffer underruns. The same applies to iTunes to avoid skipping, and to anything involving streaming content, to avoid frame drops.

The problem with this scheduler approach to priority is that there is no true idle priority. Every thread will eventually get some CPU, even if it only gets a slice once every 100 runs through the schedule table. To handle a real idle priority thread, you would need to patch another schedule table in between the main table and the idle thread routine.

The second table would get a slice only if the main table had exited early on all threads. After the 2nd table hands one slice out to an idle-priority thread, it returns to the main table. The next idle-priority thread in the 2nd table will not get a slice until the next time the main schedule exits early on all threads.

If you wanted to prioritize idle threads, things would get still more involved. None of the Unix-like operating systems provide the 2nd schedule table, so none of them have a true idle priority, just a minimum priority. From things I've heard, it appears that Windoze32 versions do provide a true idle priority, but I do not have an x86 box to check that for sure.

Personally, I would like the added utility of a true idle priority, particularly if it offered prioritization with the idle processes. Perhaps the kernel developers of the various operating systems will provide that someday, but it does mostly apply to situations like ours' with DC clients. I've been hard pressed to come up with any other process that would benefit from a true idle, every other example that comes to mind may execute rarely, but does need to be guaranteed to execute sometime. A disk integrity check that normally finds nothing wrong may be postponed with little concern, but it does need to run eventually. A true idle priority thread may never get called, especially if a DC client were running at a low priority rather than an idle priority.

If anyone can think of other processes that would legitimately run at true idle, please post. The kernel developers are more likely to grant our wish if we can provide *cough* legitimate uses for it. That, or we could compile our own kernel and related utilities for setting the idle priorities.

Ok, that looks like a decent summary. Note that I am not a kernel developer, so it is possible that some of this is muxed up. Kernel experts, feel free to chime in and correct as needed.

ps - Scott, your "explanation in the above post" is condensed by about 10 KB and at least an hour.
     
Forum Regular
Join Date: Feb 2003
Location: Sundsvall, Sweden
Status: Offline
Reply With Quote
Jul 4, 2004, 10:44 PM
 
very good read

It is rare for a thread to run at max priority (-19) because it drags down everything else
on a linux system, yes, but on OS X the priorities that you can set using nice/renice seems far from the real underlaying mach priorities, for example if you run "sudo nice -n -19 yes > /dev/null" the system will still be fully usable, only the scrolling will be slightly jumpy. the WindowServer seems to have way higher priority, since window movement is still butter smooth.

another thing id like to add, i think the scheduler has an internal priority for each thread as well, for each time the scheduler is run, all threads that are waiting for IO for example(Sleeping), will get this priority increased, so that when the IO they need is ready, their priority will be a higher then other threads. once the thread is running its priority will decrease again, for each time its scheduled.

however im not sure if what i just said is correct, i believe ive read something like that somewhere.

anyway if i remember correctly FreeBSD has true idle priority
     
Administrator
Join Date: May 2000
Location: California
Status: Offline
Reply With Quote
Jul 5, 2004, 12:49 AM
 
You are remembering a feature correctly. Since the scheduler has so much to do with a system's speed and responsiveness, modern schedulers play considerable tricks in order to speed things up. These include internally nudging up the priority of threads checking on I/O so the system will respond faster to user input. Kicking up the priority on a sleeping thread is painless since it costs almost nothing, but makes the system recognize and respond to input faster - ie, snappy.

The scheduler does other advanced tricks too, many of which I'm not grounded enough in the field to even know of. The above post is meant as a basic summary, I'd want to do some serious reading before posting a complete explanation. Tricks like these are often the reason why a new OSX version with a new Darwin (Mach) kernel is faster on the same hardware.

Edit: This Ars article may be where you read about it.
(Last edited by reader50; Jul 5, 2004 at 11:41 AM. )
     
Senior User
Join Date: Feb 2002
Location: Silly Valley, Ca
Status: Offline
Reply With Quote
Jul 9, 2004, 02:16 AM
 
Good summary!
Hopefully, that should help clear up some of the confusion for folks.
The underlying mach system/kernel threads get their own magic scheduling, which is the hardest part to make any sense of since we really don't know what the priorities are or what the table looks like.

One thing is clear though, if you have free CPU, it is going to get used if a DC client is running.

Another major thing to consider with performance of multiple applications is RAM.
OS X likes a nice 512Mb to be happy with a very active user running lots of stuff.
If you have 256Mb and are running 10 apps and one DC client in the background, you are going to have sluggishness.
There just isn't enough RAM to avoid paging in and out memory to disk when you switch between applications and when your DC client gets its time slice.
This will be especially true with an optimized DC client that makes heavy use of caching and RAM. The same is true of trying to play RAM intensive games (Quake3, Halo, UT2004, etc) while running a DC client in the background - your game play will suffer.

So if you have no sluggishness without the DC client running and a perceivable slowdown when running it, look at your RAM. Chances are it is not enough.

You can see paging on a process level with top.
Running top -ud in a Terminal window that is always visible while you have your regular workload of apps running and your DC client will show you how bad things are when you do something like load a web page.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 11:30 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2