Insane cpu use from blank window

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
torchLight
Posts: 8
Joined: Sun Apr 20, 2008 5:36 am
Location: Albeta, Canada

Insane cpu use from blank window

Post 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...
Halifax
Posts: 1424
Joined: Sun Apr 29, 2007 10:40 pm
Location: $9D95

Post 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.
TheQuestion = 2B || !2B
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post 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).
Image Image Image
switch_case
Posts: 34
Joined: Sat Mar 08, 2008 12:46 pm
Location: Germany, FFM
Contact:

Post 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)
if life could only be written in C++...
so much features, money++, remove_childs(), choose parents, life = new life, and no more <IDIOT> templates !
if you're looking for an nerdy coding language: http://lolcode.com/
dejai
Posts: 522
Joined: Sat Apr 21, 2007 9:00 am

Post 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.
Programming Blog: http://www.uberwolf.com
twilight17
Posts: 362
Joined: Sun Dec 16, 2007 9:25 pm

Post 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)
Post this userbar I made on other websites to show your support for Irrlicht!
Image
http://img147.imageshack.us/img147/1261 ... wernq4.png
torchLight
Posts: 8
Joined: Sun Apr 20, 2008 5:36 am
Location: Albeta, Canada

Post 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...
twilight17
Posts: 362
Joined: Sun Dec 16, 2007 9:25 pm

Post by twilight17 »

:), my avatar I found on PhotoBucket :lol:
Post this userbar I made on other websites to show your support for Irrlicht!
Image
http://img147.imageshack.us/img147/1261 ... wernq4.png
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post 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.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Post Reply