ID:159769
![]() Jan 15 2009, 3:05 pm
|
|
Well, I was wondering if there was a way to control the CPU Usage of the game so it cuts lag down.
|
![]() Jan 15 2009, 3:18 pm (Edited on Jan 17 2009, 1:06 pm)
|
|
*
|
Well I guess It's my coding it's probably not to clean for starters.
My rsc. file is rather large I don't know how to make that smaller. |
Gizhy wrote:
My rsc. file is rather large I don't know how to make that smaller. The .rsc file has nothing to do with CPU usage. |
Although it does give signs of how well you programmed your source. Having a huge rsc file with very little to do is a big problem.
|
A very large RSC could also be the result of a large overworld with varying clothing, vegetation, terrain, people, etc., so it's hardly a direct correlation.
|
Well yeah, I was going more towards like if he had a single icon for grass and two npcs with a large file size, that would be a problem.
|
Exactly. The .rsc file is what stores all the icons and anything that has to be preloaded with your game. You can have a MASSIVE .rsc file in a game that uses 0% cpu at all times just for the fact that you have very high detail icons.
Lets talk about your game: What kind of game is it? Do you have AI loops for monsters? What other kind of loops do you have? Any other notable processes you may have running? Perhaps snippits of your AI codes will help us understand where your CPU is going. |
Any loop can cause a significant amount of processing power to be used. Always remember the adage, "90% of the processing is done in 10% of the code." That 10% in almost always the loops. Optimize your loops and you'll greatly optimize the program as a whole.
|
Correcto! Hence why I'm asking about what his loops look like, so as to find a way to clean them up a bit.
|
AJX wrote:
I'm going to tell you now that there is nothing you could possibly be doing that should be causing your CPU to even be effected on any serious level. Unless you're specifically referring to CPU damage here, this is clearly wrong. It's very easy to max out a CPU with a bad loop. Loop Efficiency: If you have an AI code that runs often then it is obviously very important that you don't create any memory leaks. I'm not sure what you mean here, either, but it's not the first time I see you using this term and it looks like you don't understand it. A memory leak occurs when a programmer fails to release previously-allocated memory the program no longer needs, and can no longer reference that memory (ie, the pointer to it wasn't kept). Regardless of this not having to do much with CPU usage, in DM you wouldn't be able to cause such unrecoverable memory leaks because it internally manages memory allocation and disallocation for you, including garbage collecting objects. And even if an object can't be garbage collected and you don't have any known reference to it, you could still find it at least most of the time. Now the question is, what do you have right now that is using up your CPU? A good thing to mention here is the world profiler, which eases finding such bottlenecks. You can start it with the .profile command or from Options & Messages. |
So when you say "memory leak," you're saying he should cut lag down by cutting lag down.
He's asking how, not another way of saying how. |
AJX wrote:
Defiantly, but it is my assumption that most people who have gotten far enough in programming to create these problems would have an idea of where their resources are going. Example being someone is making a game, they know they have monster AI in said game, that would be a typical response if they were asked what uses CPU. If the person didn't know why their CPU was high then that would be when I would break out the profiler, but I do believe the poster has enough knowledge of his game to answer without using it. That's a stupid thing to say, why have them guess where the problem might be when the profiler will show them exactly where the problem areas are and to what extent they're using up the CPU? There are plenty of other things besides loops that use up CPU, rgb()ing an icon is a major one, and probably any other code that modifies an icon such as turn or shift (though I've never directly tested those), adding/removing things from client.screen, creating any substantial amount of atoms (mobs/objs), ect. |
AJX wrote:
Here are some starter points: So. Rather than actually contributing anything useful (or actually reading what I typed before you opened your mouth) you'd rather criticize my choice of words... Even though there is not much more that can be said without knowing what exactly it is he is doing. If in my effort to help other programmers in situations where I can all that is going to happen is people like you and Falacy are going to make stupid remarks that actually benefit nobody then I suppose there is no point in even bothering. At least Kaioken listed his responses to what I was saying and things to add... All you're doing is mouthing off. Seeing as you are obviously such a superior programmer to myself you are more than welcome to handle the situation, which I can tell you already have so well with your two sentences of insult. Good work. |
Yeah, I think I kinda get the point that it's the icons/loops/rgb()/other useless things in the source, I can fix these.
|
AJX wrote:
...If in my effort to help other programmers in situations where I can all that is going to happen is people like you and Falacy are going to make stupid remarks that actually benefit nobody then I suppose there is no point in even bothering... Excuse me? Not only did I point out why your comment was idiotic, but I also listed several CPU intensive alternatives to look for that none of you had mentioned. |
Popisfizzy wrote:
A very large RSC could also be the result of a large overworld with varying clothing, vegetation, terrain, people, etc., so it's hardly a direct correlation. Sending the RSC to all clients requires a fair bit of processing, especially if the RSC is rather large. |
Gizhy wrote:
Well, I was wondering if there was a way to control the CPU Usage of the game so it cuts lag down. Aside from good programming practices, you can lower CPU by adjusting world.tick_lag when appropriate. Of course, this shouldn't really be seen as a solution since it will make your game run slower. |