Page 1 of 2

50% CPU during Demo app

Posted: Mon Aug 18, 2008 8:56 am
by Hennesey
Hello,
I have downloaded Irrlicht 1.4.1.
When I start the demo my Core 2 Duo goes up to 50% CPU working capacity.
On 1 Core machine, I get always a 100% CPU working capacity.
Is this normal?

Thanks in advance.

Posted: Mon Aug 18, 2008 9:59 am
by hybrid
Well, I suppose that your second core idles in that moment, which makes 50% according to my arithmetics.

Posted: Mon Aug 18, 2008 10:00 am
by JP
Yep, it's normal. The render loop (while (device->run()) just goes round around without pausing, if you want to reduce the CPU load then you can put a small sleep at the end of the loop. But does it matter if the app is using large amounts of the CPU time? For most cases Irrlicht will be the only app the user is interested in running, though if you're writing a tool of some sort then yeah users might want to be switching to look at folders or other apps at the same time i suppose.

Posted: Mon Aug 18, 2008 11:28 am
by Blender3D
I think he wants his Dualcore-machine working with 100% too. If so he has to change his code. OpenMP is a (easy to use) multiprocessing librarie which will make his application working on both cores (with 100%). I guess that he will have to write some extra lines of code if he wants to use openMP.

--Blender3D

Posted: Mon Aug 18, 2008 11:32 am
by hybrid
Yeah, but using OpenMP with Irrlicht will be rather difficult...

Posted: Mon Aug 18, 2008 11:35 am
by rogerborg
Why don't we just hand him a loaded gun and telling him to shove it down his pants with the safety catch off?

Posted: Mon Aug 18, 2008 11:35 am
by night_hawk
People could use multiple threads for multiple tasks. One thread for rendering, one for gameplay, one for physics, etc... Those could be a better choice.
Not the best solution, but still (I think...) solves the fact the app uses only one core. (It does, does it? :? )

Posted: Mon Aug 18, 2008 11:48 am
by rogerborg
Image

Posted: Mon Aug 18, 2008 11:51 am
by JP
physics already uses its own thread surely? on PS3 physx runs in its own thread and uses the SPUs so i assumed that all physics engines would utilise an extra thread, makes it fun for adding and removing objects though!

Posted: Mon Aug 18, 2008 1:12 pm
by rogerborg
Sure, a professional engine on a modern multi-core machine will benefit from threading, but this poster is having trouble seeing why 100% load on a single core is consistent with 50% load on a dual core.

Let's at least let him stab himself with a rogue pointer before we smother him in contention and race bugs.

Posted: Mon Aug 18, 2008 6:55 pm
by Darktib
You have a Pentium D?

You have 50% of CPU work because these processors use 2 cores and eachhave it's own memory. But now Intel and AMD have created processors with 1 shared memory for 2 or plus cores.

On a recent engine i'm not sure threads will be more efficient than no thread, even if on an quite older engine (2, 3 years...) it will be a great optimization

Re: 50% CPU during Demo app

Posted: Mon Nov 14, 2011 9:28 pm
by vectorcorpse
ok i would be intrested in that small sleep
u see, in linux (windows too, u can set cpu max and min freq in the power management profiles in vista and 7) if u'r familiar with the governor it allows u to set the cpu frequency either a specific one or ondeamand (freq goes up and down has needed avoiding high temperatures) well what happens when irrlicht starts is since it pull all cicles of the cpu core 0 or even on single core is that it triggers the ondemand and pulls the frequency to max forcing the cpu to start heating unnecessarily and i say that becaus if i force the governor to its minimum frequency irrlicht runs at the same fps and performance whatsoever at least until it get some real work to do.
so basically what i want is a chance for governor to work has intended and only scale up the frequency when it is really necessary saving my cpu and its life span.

Re: 50% CPU during Demo app

Posted: Tue Nov 15, 2011 3:50 pm
by bitplane
See the GUI editor source code, if I remember correctly it uses either Device->yield() or Device->sleep(2) to prevent Irrlicht from hogging all the CPU time.

Re: 50% CPU during Demo app

Posted: Thu Nov 24, 2011 3:23 pm
by vectorcorpse
:D nice i'll look in to it this weekend, thx for the tip.

Re: 50% CPU during Demo app

Posted: Mon Nov 28, 2011 10:32 am
by vectorcorpse
:) very nice. I had a quick look at the code and i might add de demo app seams to have a better implementation than the gui editor, i tested the sleep that features in the gui editor in the perpixel lightning tutorial, it works but it is hard do correctly tune since it differs from cpu to cpu, a problem that de demo app doesn't seam to have, does de demo app have any kind of function to adjust the sleep timing acording to the cpu power or the detected fps?!? i din't had the time to look in to it, when i get the time to it i'll have a closer look at the demo app and post my results here. this seam to be an oportunity for a new tutorial to help the noobs that wish to have a more smooth, more stable and better tuned program by requesting only the necessary resources from the computer :P