Author Topic: Server CPU Usage & Efficiency  (Read 573 times)

Legacy_EzRemake

  • Full Member
  • ***
  • Posts: 220
  • Karma: +0/-0
Server CPU Usage & Efficiency
« on: December 21, 2014, 12:11:07 am »


               

I'm curious if there are any ways of lowering CPU overhead, specifically with magic users.


 


Normally on my server I notice a ~5% CPU usage per player (roughly, usually it's less), but I notice that when casters get going the average CPU usage can easily jet up an extra 20%. It makes sense that summons and AoE abilities would chunk up some extra CPU, but I'm worried if these numbers are a little farfetched.


 


I have heard that party play exasperates this problem, with each additional player acting as a data multiplier for the server. Is this only for party members who are in the same area? Is there anything that can be done to lessen this effect?


 


And finally, last but not least, assuming CPU raises steadily with each additional player, what exactly is the behavior of a server running at or near 100%? Is it constant lag, or just a shudder here and there when big events take place?


 


 


(Misc info that might/might not matter: 3.2Ghz Dual core (running on one thread), no custom heartbeats, CPU usage is near nothing when players are idle)


 


 



               
               

               
            

Legacy_EzRemake

  • Full Member
  • ***
  • Posts: 220
  • Karma: +0/-0
Server CPU Usage & Efficiency
« Reply #1 on: December 24, 2014, 08:24:40 am »


               

Welp I'm almost at a loss here.


 


Doing some testing I've found that if a player fights multiple monsters, the CPU jets up like crazy. I know there are action servers where you fight against huge spawn numbers, so clearly something is wrong here.


 


One thing I've noticed is that this behavior only happens on the server machine, not on my main machine. I notice also that when I move my mouse around over the nwserver program window, the CPU jets up.


 


Does anyone have any ideas as to what may be going on?



               
               

               
            

Legacy_Knight_Shield

  • Hero Member
  • *****
  • Posts: 812
  • Karma: +0/-0
Server CPU Usage & Efficiency
« Reply #2 on: December 24, 2014, 02:18:38 pm »


               

I'm not sure what exactly does it but I can tell you a module with a full store did it for me.



               
               

               
            

Legacy_GIANTSWORD

  • Full Member
  • ***
  • Posts: 175
  • Karma: +0/-0
Server CPU Usage & Efficiency
« Reply #3 on: December 24, 2014, 04:25:45 pm »


               

When you say a module with a full store, do you mean you had a store that was literally completely full of items?  


 


From what I've heard it's good to have a bunch of little stores so when the store is called, it can be read very quickly.  Maybe something similar is happening with Ez's combat.  I'm going to launch my server and fight a load of stuff and see what happens.. 



               
               

               
            

Legacy_EzRemake

  • Full Member
  • ***
  • Posts: 220
  • Karma: +0/-0
Server CPU Usage & Efficiency
« Reply #4 on: December 24, 2014, 05:57:02 pm »


               

I have tried testing with full stores and empty stores and it seems to happen regardless. I have the option for players to clean out stores of their non-native items, but it doesn't get used as much as it should, so I suppose I'll have to automate that in the near future.


 


I've tried running the NWNX profiler to see if there was anything fishy going on, and for the most part I don't see anything particularly strange. The scripts with high call times seem to be the ones that must run all at once when the server starts (like the spawning scripts for instance).


 


 


Here's the profiler log:


 


http://pastebin.com/d9ZFLQKW


               
               

               
            

Legacy_GIANTSWORD

  • Full Member
  • ***
  • Posts: 175
  • Karma: +0/-0
Server CPU Usage & Efficiency
« Reply #5 on: December 24, 2014, 06:10:55 pm »


               

When your server starts and the module is up and running do all your monsters in the entire module spawn in?  


 


If so, that might be an issue.  I know some, myself included, only spawn in monsters and most NPC's when the PC enters the area.  They then despawn after a timer when all PC's have left the area.  You might just be calling all the heartbeat and perception checks of every monster in the module unnecessarily if there is no one there for them to interact with 



               
               

               
            

Legacy_EzRemake

  • Full Member
  • ***
  • Posts: 220
  • Karma: +0/-0
Server CPU Usage & Efficiency
« Reply #6 on: December 24, 2014, 06:16:51 pm »


               

Ah, yes my monsters are pre-placed and have been using an old spawning system. Even with the 200+ areas filled with NPCs, there is 0 CPU usage when there is no one in those areas. If there are 10 people logged on, but no one fighting, the CPU is only about 6%, so I know it's not causing an issue.


 


As for the Constant Ambient animations running, I am actually just testing that to see if there is a CPU difference, they normally only become animated when they perceive a player. So far I've noticed 0 difference in CPU between a creature constantly acting or not (minus pathcalling shouts while stuck, which is reason enough to not have constant animations)



               
               

               
            

Legacy_EzRemake

  • Full Member
  • ***
  • Posts: 220
  • Karma: +0/-0
Server CPU Usage & Efficiency
« Reply #7 on: December 25, 2014, 07:36:35 pm »


               

I decided to do a few tests on 3 different machines and the results are definitely strange. On two of the machines, the CPU would go up to 25-30% when one player would get surrounded by attacking badgers, the other machine (my main computer) didn't increase a single %, however the CPU was constantly at 11%, even while empty - while the other two machines idle at 0%.


 


I tried doing this test in a custom 1 room mod, filled with badgers, and I found that the CPU would also increase to 15-20% while surrounded.


 


I'm not really sure what to make of this, seeing as there are servers where a player can fight huge groups without issues. I sincerely doubt that hardware is the issue with all three of these machines. Could OS cause behaviors like this?



               
               

               
            

Legacy_GIANTSWORD

  • Full Member
  • ***
  • Posts: 175
  • Karma: +0/-0
Server CPU Usage & Efficiency
« Reply #8 on: December 26, 2014, 08:23:17 pm »


               

Are you noticing any lag during gameplay?  I'm playing NWN on the same machine I host my server from and although I only play with 2 other guys, we never experience lag.  We fight monsters in groups of 15 in one area and it seems fine.


 


My CPU stays around 25%.


               
               

               
            

Legacy_EzRemake

  • Full Member
  • ***
  • Posts: 220
  • Karma: +0/-0
Server CPU Usage & Efficiency
« Reply #9 on: December 27, 2014, 02:02:41 am »


               

I haven't noticed any lag as of yet, I am just worried about the trend. With the way it seems to increase in usage, 4 players in separate areas getting hit by 8+ monsters would cap out the CPU. It seems excessive that a player would ever be able to incur more than 10% usage at most.


 


The fact the other servers are able to allow players to fight large groups, while also facilitating high player counts, leaves me to believe that something is up here. Unless of course CPU usage doesn't behave normally with NWN, which I have seen with other applications, where 100% usage incurs no negative effects.


 


I still find it strange that a nwserver (a single threaded program) would still throw load on both threads if not told otherwise..



               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Server CPU Usage & Efficiency
« Reply #10 on: December 27, 2014, 07:47:31 am »


               

if you made a clean module for testing this you might want to try install my patch if it helps - it fixes (or rather cleans up as its not perfect fix) some AI issues that causing this.


 


Also for nonmobile plot NPCs that have only conversation remove all scripts from them. Even tho creatures in area where are no PCs doesn't drain so much resources it definitely helps a bit.


 


Also, timestopping module when there are no PCs should greatly improve performance. And lastly its cleaning up items/lootbags in areas and clean overfilled stores (my patch provides an option for that).



               
               

               
            

Legacy_EzRemake

  • Full Member
  • ***
  • Posts: 220
  • Karma: +0/-0
Server CPU Usage & Efficiency
« Reply #11 on: December 27, 2014, 04:17:52 pm »


               

Is it at all possible to 'pick and choose' what files to override from your patch Shadooow? I would really like to take advantage of some of your fixes, but I really do not feel like re-writting every spell / 2da again, as mine area already heavily edited.


 


*Edit* Read your FAQ, i'll look into adding your community patch and I'll let you guys know the results. Thanks again!



               
               

               
            

Legacy_EzRemake

  • Full Member
  • ***
  • Posts: 220
  • Karma: +0/-0
Server CPU Usage & Efficiency
« Reply #12 on: December 30, 2014, 05:54:36 pm »


               

After some exhaustive testing with Kalbaern, I believe it has come down to some sort of hardware/OS issue - as I do not experience the issue on my main PC.


 


Last night I began hosting from my main PC, and had 6-7 players get surrounded by creatures, and the CPU % would only deviate 1-2%.


 


So with the way things are looking, I'm going to have to run and play from the same machine, with the server and client on different cores.


 


My question is, while the server may only take up 5% of my total CPU on this machine, I do notice that it takes up almost the entire core it's set on. This seems to happen even if I host Prelude or Chapter 1 mods. Should I assume that only total CPU% matters, and that the % core is largely irrelevant?


 


I notice NWN itself uses pretty much 100% of whatever core it's on, without any negative effects. I almost wonder if it's a quirk from this game's age.



               
               

               
            

Legacy_Emanuel

  • Newbie
  • *
  • Posts: 2
  • Karma: +0/-0
Server CPU Usage & Efficiency
« Reply #13 on: January 09, 2015, 08:04:15 pm »


               

I went back to present the cpu problem with 100% image crash.
After the correction -ShaderSystem.ShaderQualityLevel <Medium> could play normally but the last few days the problem returned.