Pages: 1 2 3 »
  Print  
Author Topic: Overuse of the CPU ?  (Read 36702 times)
Offline (Unknown gender) egofree
Posted on: June 25, 2013, 11:00:37 am
Contributor
Joined: Jun 2013
Posts: 601

View Profile Email
As i am developing a game, i am trying to optimize the code. I did some tests, but i found that even with the most simple project possible (one sprite, one object, a room with one object, no code, no special events) the CPU use is 13 % !  As i use a rather powerful computer with an Intel Core i7 CPU and with 16 GB of memory this seems to me a little bit overkill. I tried the same project with GM 8.1 and the CPU use is not significant. What do you think ?
« Last Edit: June 25, 2013, 11:06:19 am by egofree » Logged
Offline (Male) Josh @ Dreamland
Reply #1 Posted on: June 25, 2013, 11:09:03 am

Prince of all Goldfish
Developer
Location: Pittsburgh, PA, USA
Joined: Feb 2008
Posts: 2950

View Profile Email
What's your GL support look like? It's possible something is being done software side which should not be. Also, what is the room speed of your game? High room speeds mean high CPU usage, just by virtue of doing something many times per second.
Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Offline (Unknown gender) egofree
Reply #2 Posted on: June 25, 2013, 11:40:02 am
Contributor
Joined: Jun 2013
Posts: 601

View Profile Email
I am using the latest drivers from NVIDIA for my GTX 660 card. As far as i understand the Open GL drivers are included in these drivers. The room speed is the default one : 30. I am running Windows 7 64 bits.
I tried to edit the ENIGMA settings and to use DirectX 10.0 instead, but the compilation crashes. I've DirectX 11.0 installed on my computer.
« Last Edit: June 25, 2013, 11:49:03 am by egofree » Logged
Offline (Male) Goombert
Reply #3 Posted on: June 25, 2013, 12:14:34 pm

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 2991

View Profile
egofree, theres a reason for that, we don't have DirectX ^_^
Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Offline (Unknown gender) egofree
Reply #4 Posted on: June 25, 2013, 12:53:50 pm
Contributor
Joined: Jun 2013
Posts: 601

View Profile Email
egofree, theres a reason for that, we don't have DirectX ^_^

Yes, i know there is no DirectX on linux  :). But still a lot users are using Windows, and i am afraid that if you need a powerful computer on Windows to run ENIGMA games, it will hinder its success  :( I am still using Windows because it's convenient if you want to run mainstream games, but i hate the new Windows 8 with Modern UI and i really hope linux will get more and more success in the future.
« Last Edit: June 25, 2013, 12:56:14 pm by egofree » Logged
Offline (Unknown gender) TheExDeus
Reply #5 Posted on: June 25, 2013, 01:27:10 pm

Developer
Joined: Apr 2008
Posts: 1860

View Profile
Empty games usually use more CPU. Just like the most intensive part of SC2 was the menu (where there was a sphere rendered). The same here. Your GPU has nothing to do so the CPU boost to the max. It shouldn't really happen at 30FPS though. I previously found a problem that having the room_speed set over the max CPU/GPU can handle, then CPU will spike to 100% (for the one core it runs on), you lower the FPS by 1 (like 61 to 60) and it falls to 0%. We need a more intelligent system which would run in the background and monitor and change the performance. Although VSYNC and adaptive vsync (which we should implement, it's the same function like we have now, but with -1 set instead) it usually doesn't happen.

And I just tested with one animated sprite with one object and in one room with default 30fps. I get 0-1% CPU load. I also have i7, 16gigs of RAM and 660TI. So it could be something else on your side. Is something else using the CPU? As I said, it seems to use a lot of CPU when it can't catch up. So if you can't easily render 30FPS because of some massive processes, then the game could just up in CPU usage. It seems like a devilish circle, but for now I don't know what can be changed. For me that happens when I render over 300FPS (or more) in the 1mil cube demo.

edit: Also I though we had a memory leak because ram usage kept increasing from about 18mb on startup to about 20mb after about 1 minute. Then it stabilized though. I don't think we cache anything so it seems weird.
« Last Edit: June 25, 2013, 01:28:47 pm by TheExDeus » Logged
Offline (Unknown gender) egofree
Reply #6 Posted on: June 25, 2013, 02:28:03 pm
Contributor
Joined: Jun 2013
Posts: 601

View Profile Email
Is something else using the CPU?

No, in the tasks manager, i see nothing unusual for others processes. Well, i don't know what is the problem for the moment. We will see. It would be interesting to know if others windows users have the same problem, or i am the only one.
« Last Edit: June 25, 2013, 02:30:13 pm by egofree » Logged
Offline (Unknown gender) egofree
Reply #7 Posted on: June 25, 2013, 02:29:45 pm
Contributor
Joined: Jun 2013
Posts: 601

View Profile Email
egofree, theres a reason for that, we don't have DirectX ^_^

I heard an interesting rumor about migrating to MinGW64 and support of DirectX. Does anybody have some news about this rumor ?  :)
Logged
Offline (Male) Goombert
Reply #8 Posted on: July 03, 2013, 12:30:17 am

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 2991

View Profile
Yes, good luck getting it to link correctly, I tried and tried, I can only get the DirectX10 headers included, but I can not manage to link the libraries, knock yourself out. :P
Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Offline (Unknown gender) TheExDeus
Reply #9 Posted on: July 03, 2013, 08:42:12 am

Developer
Joined: Apr 2008
Posts: 1860

View Profile
I doubt DirectX would change anything. It just happens that for some hardware/software combinations stuff like that happens. I doubt the CPU use would increase even if the room wasn't empty. Just like when people cried that GM games are 2mb even when just having 1 empty room, but when you make the game it usually grows to only 4mb. So it's hard to tell why it shows 13% CPU load, but it's possible the load wouldn't change with a basic game.
Maybe now something has changed? Like downloaded newer drivers or installed/uninstalled something and it shows a different load now?
Logged
Offline (Unknown gender) egofree
Reply #10 Posted on: July 03, 2013, 11:00:33 am
Contributor
Joined: Jun 2013
Posts: 601

View Profile Email
Maybe now something has changed? Like downloaded newer drivers or installed/uninstalled something and it shows a different load now?

I've installed the latest drivers from Nvidia today (320.49), and the result is the same.
Logged
Offline (Unknown gender) egofree
Reply #11 Posted on: July 03, 2013, 11:01:59 am
Contributor
Joined: Jun 2013
Posts: 601

View Profile Email
I doubt DirectX would change anything.

I don't know, but i heard that the support of Open GL on Windows is not good. That's why i was thinking about DirectX.
Logged
Offline (Unknown gender) TheExDeus
Reply #12 Posted on: July 03, 2013, 02:31:59 pm

Developer
Joined: Apr 2008
Posts: 1860

View Profile
Well anything is possible, but CPU load shouldn't be changed by the graphics system. Maybe some more detailed profiling is possible to see what exactly the game is doing on the CPU. Looking at this thread http://social.msdn.microsoft.com/Forums/vstudio/en-US/ef38c900-f2e2-4ae7-8e03-2a3941805aa3/profiling-what-code-causes-high-cpu-usage even the most basic timer profiling could do the trick. You could check which function executes the longest and thus see why it shows that CPU usage at 13%. In that case it is possible that the some GL function (like GL swap buffers or something) cause a stall which takes a larger amount of time and thus shows up as higher CPU usage (while in reality CPU was just waiting).

Try turning off the background in room, if that doesn't show anything then set automatic redrawing to false. I don't think "Sleep on minimize" thing is implemented, but if it is then try that as well.
« Last Edit: July 03, 2013, 02:34:49 pm by TheExDeus » Logged
Offline (Male) Goombert
Reply #13 Posted on: July 03, 2013, 03:05:07 pm

Developer
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 2991

View Profile
Harri, forthevins update timer takes into account wherever you are rendering things or not, and tries to pick a suitable CPU usage.
Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Offline (Unknown gender) TheExDeus
Reply #14 Posted on: July 03, 2013, 04:49:31 pm

Developer
Joined: Apr 2008
Posts: 1860

View Profile
But the timer works between frames, I am thinking something goes wrong during the rendering (or as nothing is really rendered, then the buffer flipping). Still, profiling can be done and checked why it consumes CPU like that. I have almost identical PC to him and I don't have that problem. I still think he should also try some games or example to check if CPU usage actually increases. Maybe because of some compatibility problems the 13% will be the default and additional computation will not really increase that.
Logged
Pages: 1 2 3 »
  Print