minimize cpu usage

Posted By: Kartoffel

minimize cpu usage - 09/30/13 15:35

Hey there,

as some of you might have seen it already in another thread: I'm working on this simple music player:


It works great except for the performance.
The fps aren't a problem but with a resolution of 1280x720 (720p) @ 60fps it uses one full core (~3.5ghz) - which is everything it can get and for me that's kinda strange.

so, what are you're experiences with acknex's performance and what can I do to minimize the cpu usage? (except for switching to another engine :P)
Posted By: irchel2

Re: minimize cpu usage - 09/30/13 15:59

The engine is supposed to use full cpu power, I guess? If you limit the FPS via fps_max, usage should go down AFAIK.

But regarding the quality of your work, I am surprised I have to tell you this?!
Posted By: Kartoffel

Re: minimize cpu usage - 09/30/13 16:13

I'm already limiting to 60 fps smirk

however, even an A8-application which does nothing at all uses 8-10% at 60 fps. (1 core = 12.5%)

Quote:
But regarding the quality of your work, I am surprised I have to tell you this?!
it was actually pretty easy...
some flat models, the fmod plugin, my hdrr pipeline and a little bit of math, that's all grin
Posted By: Kartoffel

Re: minimize cpu usage - 09/30/13 17:14

so, can anybody help me?
otherwise I'll ask again in the 'ask the devs'-subforum
Posted By: Ch40zzC0d3r

Re: minimize cpu usage - 09/30/13 19:39

You could try to decrease the thread- or processpriority but IDK if this little boost helps you xD
Posted By: Uhrwerk

Re: minimize cpu usage - 09/30/13 20:35

Changing a process' priority doesn't change the amount of computation that needs to be done.

I guess your best bet is to reduce the complexity of the algorithms used.
Posted By: Kartoffel

Re: minimize cpu usage - 10/01/13 13:27

@Uhrwerk, thanks but as I've said before even an application which does nothing at all needs ~10% cpu usage.
Posted By: Uhrwerk

Re: minimize cpu usage - 10/01/13 13:45

Well, that's exactly what I would expect. The engine has to do some management jobs. Even if nothings happens the the task scheduler will run for example. And even if you don't render anything at all still about half a gigabyte of pixel data has to be calculated per second (assuming fullhd @ 60fps) and moved to the screen buffer...
Posted By: Kartoffel

Re: minimize cpu usage - 10/01/13 14:22

yeah... I just thought that maybe some of the background-management-stuff can be turned off (or modified / optimized).
Posted By: Wjbender

Re: minimize cpu usage - 10/01/13 16:32

An a8 application wich does "nothing" does not really do "nothing" ....

For any type op cpu intensive activity you should try and split those parts into threads thats what they are for..

However , i would not know what goes on in your app so i guess my advice is of no use.. Lite-c sucks anyway
Posted By: Superku

Re: minimize cpu usage - 10/01/13 16:50

I think lite-C is a pretty cool guy, eh makes games run and doesn’t afraid of anything.
Posted By: Wjbender

Re: minimize cpu usage - 10/01/13 18:15

I think lite-c is fucked up beyond use thats what i think about half measures when it comes to coding languages but like you have an oppinion i have my own i think the only usefullnes it has as a language for actual game dev (for ease) is its vector functions (sometimes)

edit: by the way show me the games it makes run and dont come to me with its limited by the users ability as this is suppose to be a beginner engine and then you have pro versions and stuff show me wheres the pros using it and actually producing anything beyond "hey i make little thingy move and then then then .." its a piece of junk even in the hands of a good coder period ..besides this is off topic
Posted By: Uhrwerk

Re: minimize cpu usage - 10/01/13 18:45

Originally Posted By: Wjbender
I think lite-c is fucked up beyond use [...] piece of junk even in the hands of a good coder period

Yeah. Sure. https://www.youtube.com/watch?v=fakKvlErGJE
Originally Posted By: Wjbender
For any type op cpu intensive activity you should try and split those parts into threads thats what they are for.
That doesn't help Kartoffel a bit. He is asking how to reduce cpu usage. Splitting computation to threads does not minimize the load. The load is exactly the same and even a bit more for the thread management part. Using different threads only offers benefits when you want to speed things up in terms of the duration of the computation.
Posted By: Wjbender

Re: minimize cpu usage - 10/01/13 19:33

Actual lite-c or c++ ? Wont hold my breath for any further more proof of "lite-c" being worth anything but paperweight , seriously you dont want to argue that lite-c is anything but half measures ?

No , if he is running that computation during the time he plays the music , doung it on another thread will help taking the extreme load off the cpu because windows will split up the time every task occupies taking the load off of his main application period , do a couple of heavy algorithms in your main app and the cpu will have to dedicate time to your app and take alot of load while splitted up into seperate threads/tasks the cpus load will be split up by the time it gives to process every task and the processing load will be taken off the main app period thats why we have multicores these things are linked and designed for a reason , you want to argue that threads were actually invented for anything less ?
Posted By: Ch40zzC0d3r

Re: minimize cpu usage - 10/01/13 20:01

Well youre right that the time it takes to do all these tasks is shorten, but to get the cpu usage you have to add the usage of all (mostly 8) cores together and it will result in the same usage.
Its just a gain in terms of speed.
Posted By: Uhrwerk

Re: minimize cpu usage - 10/01/13 20:28

Originally Posted By: Wjbender
doung it on another thread will help taking the extreme load off the cpu

No, that is not the case. Using multiple threads does not magically take work away. The work to be done stays exactly the same, regardless of the number of cores or cpus being used. Multiple cores only help in terms of speed (assuming a given problem can be effectively split into separately calculable problems).

If you want to empty 20 bottles of beer and ask a friend for help you can split the "work" among you. This will half the execution time but that won't reduce the overall number of bottles to drink. If you're unlucky and you only have one 10 liter bottle instead of 20 .5 liter bottles the work cannot be split and the time required cannot be reduced.

What Kartoffel is asking for is how to reduce the overall number of beer bottles to drink. He's not keen on drinking the beer faster, he wants to drink less...
Posted By: Wjbender

Re: minimize cpu usage - 10/01/13 20:30

There is not really "8" cores mostly 4 with hyperthreading wich i am not going to elaborate on further ..

But like i have said dont know whats happening in the app therefore my advice could be ignored..

Only possible advice that could be given is to find whatever eats away at your cpu usage and try to do less of that ..

This could be hard because it very well may just be as "less" as it could be i wouldnt know but do know that cpu load is not actually a bad thing though videos music and media as such typicaly are cpu intensive
Posted By: Kartoffel

Re: minimize cpu usage - 10/02/13 16:20

thank you all for your replies!

Although it seems like I can't change anything at the (background-) tasks done by acknex itself, I'll ask in the dev's forum, maybe there's something I can do.
Posted By: Uhrwerk

Re: minimize cpu usage - 10/02/13 20:52

On a side note: What system have you got? Running acknex without default.c included but nothing else utilizes about 50% of one of my cores @ 60 fps. At 30 fps it utilizes about one quarter of one core. I got an AMD FX 8350 processor.
Posted By: Wjbender

Re: minimize cpu usage - 10/06/13 11:09

I have to bring this up again but to humble
agree that yes you were correct with threads
excuse me for the little rant there , but
one thing i wouod not back down from
is lite-c suck imo i wil never like it unless
it were actual full blown c++ ..just my prefered language

yes supercan is cool agreed ..

Hope you guys have a nice day/night

cheers
Posted By: Kartoffel

Re: minimize cpu usage - 10/06/13 11:31

@Uhrwerk: sorry, I didn't see you replied...

I'm using an Intel i7 (4770k) with 8 threads (4 cores) running at 3.5ghz each.
My graphics card is an AMD Radeon HD 7850 (in case that's important, too).

this application uses ~8-10% (64-80% of one core or 2.24-2.8ghz):
Code:
#include <acknex.h>

void main()
{
	wait(1);
	fps_max = 60;
	
	video_set(sys_metrics(0) * .5, sys_metrics(1) * .5, 0, 2);
}

Posted By: Aku_Aku

Re: minimize cpu usage - 10/06/13 12:03

Just a side note.
You should not compare lite-c to c++.
The first one is a script language, it drives an engine behind the script.
The second one does not drive an engine, it is simple a language.
Posted By: Wjbender

Re: minimize cpu usage - 10/06/13 12:17

On a note beside that note , lite-c sucks
no matter what you say on its behalf
it sucks they tried to get close to
the real language with it which would
be okay for any newcomer but it still
sucks to me even the c++ of gamestudio
sucks , lite-c is not exactly much of a scrypting language , it looks like a chopped down c language
..half measures .. So who is comparing here ? Me or acknex
Posted By: Superku

Re: minimize cpu usage - 10/06/13 12:29

Maybe it's not the language that sucks but the one who tries to use it.
Posted By: WretchedSid

Re: minimize cpu usage - 10/06/13 14:15

Wbjender is right, kindaish, I mean, Lite-C really isn't that good. Though that's pretty much all I'm agreeing on with him, and don't get me started on the Apple and Oranges comparison between Lite-C and C++.

Anyhow, the reason your CPU activity is so high, despite gamestudio not doing anything, is most likely because it is busy looping it's run loop. You see, there are cases where it makes sense to do only work in bursts and give CPU time back otherwise, not only for performance but also battery uses, but it doesn't make sense for Gamestudio.

If you limit the FPS to 60, it makes sense to only dispatch a run through the run loop every 16 milliseconds, that's what you expect after all. It doesn't make sense to give the CPU time back though, busy looping for the 16 milliseconds to pass would be the wiser decision. The reason for this is that putting your program to sleep relies on the scheduler to wake the program up again in time, which is definitely not going to happen. That's fine for normal applications, but not for applications where milliseconds make a difference. Forcing a reschedule marks your application as nice, and will implicitly lower your priority within the scheduler. The contract is simple: You don't use everything, you don't need everything, so you are less likely to get scheduled. Again, not desirable in an application where time is critical. You want to burn CPU cycles that you don't use, simply to look active and maintain a high priority, stupid jittering just because the game got suddenly more CPU intensive is the least thing you want.

tl;dr: Don't use gamestudio for things it wasn't made.

Edit: And Kartoffel, please bring back the vibrant colours to your music player. The ones of your last screen without the saturation look pretty meh if anyone wants to know my opinion.
Posted By: Wjbender

Re: minimize cpu usage - 10/06/13 14:19

Luckily i dont do sissyfit very well but what i do Do well is the following , **gone**
Posted By: Aku_Aku

Re: minimize cpu usage - 10/06/13 14:51

That is not enough, when you wrote
Quote:
lite-c sucks

You should give evidence of that.
Now i am curious, why is so bad this language compared to c++?
Posted By: Uhrwerk

Re: minimize cpu usage - 10/06/13 15:35

No, please don't do this here. Don't destroy Kartoffel's thread any further with this nonsense discussion. I know, I shouldn't have answered wjbenders troll post in the first place...
Posted By: Wjbender

Re: minimize cpu usage - 10/06/13 15:37

edit : said something good but saw the post above ..

so like i said gone .. i mentioned this is off topic but as others shared an oppinion i shared mine .. so go fuck yourself dude

sid everytime you write something i bow down ,
"me tiny grasshopper , you big master , you kung-fu gooooood"
Posted By: Feindbild

Re: minimize cpu usage - 10/06/13 16:00

Why so pissed, man?
Posted By: Wjbender

Re: minimize cpu usage - 10/06/13 17:08

this is the normal kind of behaviour around here
you say somerhing being oppiniated and
these type of guys try to share their oppinion
but in a manner of trying to make you sound
like a troll or inteligently fucked compared
to what they think about everything thats what
im pissed at , they may say whatever they want about WED SED or anything for that matter
but by god do not share what you think because
the high and mighty may just came down from their self proclamed seats of ever knowing wisdom to smite you with theire own oppinion ...

f that i am not their humble little peasant to laugh at and bestow their oppnions on me like i dont have my own , and to top it off with being called troll when they threw oppinions my way wich i just happend to voice my own back .

i dont want to throw this thread off tracks i wish kartoffel finds something wich would lead him to a decision as to what engine he wants "as if my litec sucks was sooooo off topic anyway"

enough said ..have a nice day no hard feelings just oppinions
Posted By: checkbutton

Re: minimize cpu usage - 10/07/13 22:50

Wjbender, please watch your language. If you don't like the products discussed on these boards, feel free to leave. However, you are very welcome to engage in a factual and objective discussion.
Consider this your first and last warning.
Posted By: sadsack

Re: minimize cpu usage - 10/08/13 23:58

Well Wjbender, I think I like you, ha ha ha, they get mad At me too.
sadsack
Posted By: checkbutton

Re: minimize cpu usage - 10/09/13 09:58

Oh he is very welcome to criticise! So are you and is everybody here. But there is no need for an over-emotional argumentation, strong language or even insulting other people for their opinion (which didn't happen here in my eyes, but it already happend on this board). Everybody is welcome to state their honest opinion, that's what discussion boards are for, right? wink
Posted By: Wjbender

Re: minimize cpu usage - 10/09/13 12:34

mmm i see foul language all over the place around here but warning heeded non the less ..

checkbutton no need , i am leaving anyway , please
continue on topic .

yeah i think i like me to ;-)
Posted By: Rackscha

Re: minimize cpu usage - 10/09/13 14:10

I am not a mod, but this is going VERY Off-Topic.
I'd suggest to continue this discussion in a seperated thread or via PM.

Greetings
Rackscha
Posted By: Kartoffel

Re: minimize cpu usage - 10/09/13 17:10

well, I think my question's answered (at least to some degree...)

It seems like there's no way to optimise / modify acknex's background tasks.

But still I wonder if it's just a problem I'm having and what's exactly the cause of this high cpu usage.
Posted By: sivan

Re: minimize cpu usage - 10/09/13 17:26

maybe the developers would describe it happily in details, maybe not... laugh anyway, it is an interesting question, it would be fine to know what is the minimum stuff always done behind.
Posted By: Kartoffel

Re: minimize cpu usage - 10/10/13 13:34

@^: yeah, I'll probably ask there, thanks.
Posted By: rojart

Re: minimize cpu usage - 10/10/13 20:28

Hi Kartoffel, i've similar system, an i7 4770; Geforce GTX 760, 16GB RAM, Win8P, but i got ~0,02% usage, take a look at the screenshot, maybe your MB bios was not optimized yet?

What you meant with 64-80% of one core or 2.24-2.8ghz?


Posted By: Kartoffel

Re: minimize cpu usage - 10/11/13 14:07

well I meant 8-10% in total (the number that the task manager shows) . and since there are 8 threads: 1 thread = 12.5%.

so, for example if acknex.exe uses 12.5% it means its using one full core which is 3.5ghz
Posted By: rojart

Re: minimize cpu usage - 10/11/13 14:32

Ok, understood.
Can you upload exe demo or pm me?
I'll test on my pc.
Posted By: Kartoffel

Re: minimize cpu usage - 10/11/13 15:02

that's the cpu usage:


and here's the simple test application.
Posted By: rojart

Re: minimize cpu usage - 10/12/13 12:51

I meant the simple music player to test it.
But with aaa.c i got ~0,03% & 0 CPU usage.
Some time ago i had similar problem with one shader on Win7 here.
Posted By: Kartoffel

Re: minimize cpu usage - 10/12/13 12:56

that's strange... I think I'll ask jcl about this.
Posted By: rojart

Re: minimize cpu usage - 10/12/13 20:04

Yes, this is very strange, forget all my testing i've posted above.
My ressourcemonitor was started in wrong way.

So, now i got ~7% cpu usage.
Posted By: Roel

Re: minimize cpu usage - 10/12/13 20:50

There is a code snippet on the wiki about saving the cpu.
I don't know if it (still) works, it is in wdl so it could be from the A6 time.

http://opserver.de/nwik5/index.php?title=Tips_and_Tricks#Save_CPU_when_task_swiched
Posted By: Uhrwerk

Re: minimize cpu usage - 10/12/13 21:03

This works just for task switching when you do not care about the framerate and screen refreshing...
© 2024 lite-C Forums