Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / CPU usage of DB Pro applications

Author
Message
Monzi
20
Years of Service
User Offline
Joined: 10th May 2004
Location: Denmark
Posted: 22nd Feb 2005 06:34
i've noticed that db pro apps take up 90%+ of the cpu on my athlon xp 2000+ cpu.

is there any way to lower the cpu usage?

mm0zct
20
Years of Service
User Offline
Joined: 18th Nov 2003
Location: scotland-uk
Posted: 22nd Feb 2005 06:52
you could change their priority from normal to low if you are running xp, ctrl+alt+del to open task manages, open the processes tab, right click the dbp app and change it, this is not permenant though and will need doing every time you run it. obviously this will greatly reduce fps and responsivenes of the application too.

http://www.larinar.tk
AMD athlon 64 3000+, 512mb ddr400, abit kv8, 160gb hdd, gigabit lan, ati radeom 9800se 128mb.
Monzi
20
Years of Service
User Offline
Joined: 10th May 2004
Location: Denmark
Posted: 22nd Feb 2005 06:59
i'm looking for a permanent solution to the problem, wouldnt be very cool to release something finished if it hogs up the cpu like this

Cryptoman
20
Years of Service
User Offline
Joined: 24th Nov 2003
Location: Utah Mountains
Posted: 22nd Feb 2005 08:07
If you are doing 3d, then you want to hog the cpu, but here's a secret. When your program is idle use sync off. Then you program only gets attention when windows feels like it.


Clueless
20
Years of Service
User Offline
Joined: 16th Feb 2004
Location: Corbin, KY, USA
Posted: 22nd Feb 2005 09:56
Quote: "wouldnt be very cool to release something finished if it hogs up the cpu like this
"


You don't have a lot of options under Windows. I just wasn't designed to give you the level of control you want (and need) over resource usage.

Keep in mind though that your CPU is always 100% in use, even if it isn't "100% busy" -- if there are no processes asking for CPU time then an idle process gets it. It'll typically do something equivalent to "10: GO TO 10" in Basic parlance, until another process aks for time.

There is nothing wrong with keeping your CPU 90% busy -- the problems occur when you need to place limits on one process' usage because you have others that also need time (like, if you're writing a networked multiplayer game and want to allow both a host process and a client process execute on the same machine). Windows follows the "give until it hurts" resource management plan. You don't get a lot of control over process scheduling and resource usage.

Usually, with a game, your user is going to be 100% focused on your program anyway and isn't going to be concerned that Sync Manager or the indexing service couldn't run while they were blasting away at bad guys.

IMHO, you'll probably notice the ill effects with memory or disk I/O before the CPU issue. For example, MS Access routinely pegs the CPU when I have it and other programs running, but the other programs still seem to run. On the other hand, a program that opens large files (like Photoshop) will be given all the physical memory it asks for, even at the expense of Windows system processes you would consider important. Physical memory is rarely released when you think it is (for example, when you've closed the 15 30MB images of Jennifer Lopez, you'll typically free zero MB of RAM).
Cryptoman
20
Years of Service
User Offline
Joined: 24th Nov 2003
Location: Utah Mountains
Posted: 22nd Feb 2005 10:07 Edited at: 22nd Feb 2005 10:15
There is control. The Kernel has a sleep function. If your program doesn't use the sleep function then your program gets all the cpu that is allowed to your priority setting. Its your job to call the sleep function everyloop when you don't need the cpu, like waiting for a button click.

When you are drawing to the screen you obviously want the cpu. File I/O is another, or perhaps you are doing intense calculations. Sync off sends a sleep command every Pro internal loop and sets a lower priority on the priority stack.

Like I said, if you are sitting idle, then call the sync off command in pro. Its up to you to handle it.

If you would like to add more sleep to your loop to free more cpu, then use the wait command also.

I.E.



Monzi
20
Years of Service
User Offline
Joined: 10th May 2004
Location: Denmark
Posted: 23rd Feb 2005 00:40
thanks man .... was just what i was looking for, i'm not programming 3d but programming a 2d file manager, volkov commander style, but cooler

Monzi
20
Years of Service
User Offline
Joined: 10th May 2004
Location: Denmark
Posted: 23rd Feb 2005 01:09 Edited at: 23rd Feb 2005 01:11
I cooked the following up which i call from every program cycle. Basically it puts the program idle if there hasnt been any keyboard activity in the program for 5 seconds. But the second a key has been touched the idletimer is counting down from 5 again before going idle (if there hasnt been any keyboard activity that is).

Its better than using the wait command which it is not possible to break away from.



Cryptoman
20
Years of Service
User Offline
Joined: 24th Nov 2003
Location: Utah Mountains
Posted: 23rd Feb 2005 01:40 Edited at: 23rd Feb 2005 01:49
If you use wait 10, then you are still looping about 70 times a second which is plenty to catch events. That would free the max cpu. Go over that and start to miss input. Sync off by itself doesn't free all the cpu, Depending on what Pro has to do in your loop you may still be running 50% in a simple loop, adding the wait sleeps some more to free the rest. It all depends on what your loops do on whether or not to use wait. don't wait too long though, 10 is the max I use. Wait 1 does the job I need, 3-10% usage is dandy for me.

Edit: Plus only use the "Wait" command at the end of your loop, after you have done everything and its ready to go back to the "Do". or before everthing is to be checked in your loop. That's important. It wouldn't work in you sub too well.


Monzi
20
Years of Service
User Offline
Joined: 10th May 2004
Location: Denmark
Posted: 23rd Feb 2005 04:11
OK. I changed it to include the wait 10. And now it doesnt come over 10% cpu usage when idle. Fantastic



Login to post a reply

Server time is: 2024-11-11 23:51:42
Your offset time is: 2024-11-11 23:51:42