Page 1 of 1

Insane cpu use from blank window

Posted: Sun Apr 20, 2008 5:56 am
by torchLight
Hello,
I'm just wondering why running a blank window with irrlicht, like the example one from the engine examples and the dudMan guide chapter one, eat 50% cpu. I'm using a p4 3ghz, nvidia 8800 gt, with 2 gig i dont thinks its the system.
I'm not all that experienced but I'm hoping its just cycling the begin.scene and end.scene at an arbitrary speed causing the processor eating. If so I would think it would correct itself once the main loop is hefty enough even if not some thoughtful programing will fix it easy enough.
If I'm wrong how does irrlicht deal with this issue, or does it? I haven't used an engine other than irrilicht but I did shop around quite a bit and this is really nerve racking.
Really though all I need to ask is, is it the engine or is it the code. I hope I don't mean to accuse the engine, so far its great.

***edit***
the demos all take up about 50% cpu...

Posted: Sun Apr 20, 2008 7:12 am
by Halifax
I wouldn't necessarily say that it is the engine, but more or less the way your system handles application time management.

If you would like to reduce the CPU usage, then I would recommend capping the frame rate, and putting the application to sleep when the frame rate is greater than your cap.

Posted: Sun Apr 20, 2008 9:27 am
by JP
Basically it's gonna chew up a huge chunk of CPU because it's coded that way, not irrlicht but the app using irrlicht. The render loop will just continuously go round and round rendering without ever pausing and so the CPU doesn't get freed up. I guess the OS would do some stuff about that, freeing it up here and there, but then it comes down to how good that is maybe and possibly it's allowing 50% because it's the main application running and has all the focus.

As Halifax says you can just put a little sleep in the render loop and it will drop the CPU usage quite a lot, if you're actually worried about how much CPU is used up, but for a game you'd want to use as much as you can probably and not care about what else is running as the user is only gonna be playing the game at that time (not necessarily true but probably true enough for your cares).

Posted: Sun Apr 20, 2008 10:13 am
by switch_case
do you use software render mode? it could also cause high CPU usage, of course.
you can try the openGL driver, just change this:

Code: Select all

IrrlichtDevice *device =
        createDevice(EDT_SOFTWARE, dimension2d<s32>(640, 480), 16, false, false, false, 0);
to this:

Code: Select all

IrrlichtDevice *device =
        createDevice(EDT_OPENGL, dimension2d<s32>(640, 480), 16, false, false, false, 0);
this makes irrlicht use the openGL driver. you can also use :
EDT_BURNINGSVIDEO
(software, better than EDT_SOFTWARE but still slow)
EDT_DIRECT3D8
(directX8)
EDT_DIRECT3D9
(directX9)

Posted: Sun Apr 20, 2008 12:18 pm
by dejai
You must have one very small cpu.. The demos take up between 30-50k on my computer which is <7% of cpu processor.

Posted: Sun Apr 20, 2008 1:36 pm
by twilight17
Heh!! With my computer running even the Hello World demo, it has 100% CPU usage and about 23k. Of course this will happen, as I'm on one of the worst CPUs in the world! (Celeron D 346 3.06GHZ Single Core)

Posted: Sun Apr 20, 2008 2:48 pm
by torchLight
Oh that works me thanks Halifax and JP i was hoping it was that.

It is set to openGL, thats part of why the frame rate is screaming.

@ dejia The processor I mentioned in my first post is a p4 3 ghz with all the best a single core can have. I bought it to get the best single core that wasn't in the highest price bracket upwards of $500, granted multi core cpus now have around 3 ghz so the whole reason I got my single core is shot but I need a new power sorce before I upgrade more, I'm already beneath the requirements of the gphx card. Also memory usage should be the same on all systems.

100% wow i thought I had it bad, lol. Oh twilight, is your avatar something you made i think its crazy makes me want to go make one...

Posted: Sun Apr 20, 2008 3:33 pm
by twilight17
:), my avatar I found on PhotoBucket :lol:

Posted: Sun Apr 20, 2008 7:04 pm
by rogerborg
torchLight wrote:@ dejia The processor I mentioned in my first post is a p4 3 ghz with all the best a single core can have.
It's likely a Hyperthreaded CPU (two virtual cores) which is why you're getting 50% usage rather than 100%. All of the Irrlicht demos run a busy-loop, so of course they'll use 100% of whatever CPU they're running on. This is expected behaviour, and nothing to do with Irrlicht; if you remove the Irrlicht rendering, it'll still eat 100% of the CPU.

Sleep, or turn on vsync.