View previous topic :: View next topic |
Author |
Message |
Baaleos
Joined: 02 Sep 2007 Posts: 830
|
Posted: Sun Feb 15, 2015 13:51 Post subject: Decreasing area AI priority |
|
|
So I have just moved my server to a new server infrastructure that offers burstable performance.
Eg: when my cpu usage is below 20-30% I gain credits, which can then be used when the cpu usage is above 20-30 to give full access to a 3ghz processor.
I am trying to fine tune my server to make full use of this, I've been using the nwnx profiler to try and identify causes of cpu cycle consumption but it's not really narrowing it down for me.
My symptoms are as follows
Before anyone logs in, CPU is quiet 10-15%
When someone logs in 20-30, occasional spikes to 50%
When logging out back to 10-15ish
If however a rift spawns in the server ( a rift is a semi random event that spawns monsters in areas) then even after the rift is gone, and the player leaves, the CPU persists at 30-35% which although isn't high, it's not low enough to gain CPU credits. This CPU level would drain all CPU credits in 8 hours etc.
(the idea is that idle server accrues CPU credits, then uses them when players are on for increased performance)
My theory is that once combat occurs in an area, that area gains a flag giving it higher priority for hb's etc
If this is the case, I'm just wondering if there is anyway to return CPU priorities back to starting levels)
Has anyone got any idea on how to fix my CPU issue here?
Profiler doesn't highlight any bad scripts
Everything that gets called looks genuine and the call count is usually higher than the Ms count- suggesting an efficient script
Eg 4000 calls equating to 100ms is good vs
100 calls equating to 4000ms |
|
Back to top |
|
|
elven
Joined: 28 Jul 2006 Posts: 259 Location: Germany
|
Posted: Mon Feb 16, 2015 3:03 Post subject: |
|
|
Can't you just softlimit the process to 5% of wallclock time while no players are online? Should be enough to keep the hb scheduler happy, unless there is anything important going on while no one is there? _________________ silm.pw, a player-driven Forgotten Realms NWN1 persistent world for tinkerers. |
|
Back to top |
|
|
Baaleos
Joined: 02 Sep 2007 Posts: 830
|
Posted: Mon Feb 16, 2015 12:51 Post subject: |
|
|
Im not sure how I would do that in windows.
Most OS's don't have the power to refuse CPU cycles to applications.
The applications themselves have to govern their cpu cycles.
What I have been doing so far is putting
Code: |
if(GetFirstPC()==OBJECT_INVALID){return;}
|
into the tops of many of the scripts that run regularly
If you can suggest a way of restricting cpu cycles to nwserver - I'd be willing to hear it, as thats the end goal I have |
|
Back to top |
|
|
Baaleos
Joined: 02 Sep 2007 Posts: 830
|
Posted: Mon Feb 16, 2015 13:07 Post subject: |
|
|
http://stackoverflow.com/questions/71257/suspend-process-in-c-sharp
It seems we are both right.
OS's don't generally allow you to limit CPU, infact- you cannot limit CPU.
CPU is just used when its needed.
What you can do however, is suspend threads or full processes at rapid intervals in order to slow a process down.
I am using such an application now - which is called BEX - Which can set an upper limit for your cpu usage per process.
I am going to study its source and try to port to C# and then make it adaptive so it adjusts for player count. |
|
Back to top |
|
|
elven
Joined: 28 Jul 2006 Posts: 259 Location: Germany
|
Posted: Mon Feb 16, 2015 13:47 Post subject: |
|
|
Baaleos wrote: | http://stackoverflow.com/questions/71257/suspend-process-in-c-sharp
It seems we are both right.
OS's don't generally allow you to limit CPU, infact- you cannot limit CPU.
CPU is just used when its needed.
What you can do however, is suspend threads or full processes at rapid intervals in order to slow a process down.
I am using such an application now - which is called BEX - Which can set an upper limit for your cpu usage per process.
I am going to study its source and try to port to C# and then make it adaptive so it adjusts for player count. |
That's exactly what I meant. Linux has cgroups noawadays, or the simple SIGSTOP SIGCONT trick (that you mentioned).
If there isn't anything important going on inside nwserver when no players are online, you might as well suspend the process until someone tries to log in. Is that even cheaper? :) _________________ silm.pw, a player-driven Forgotten Realms NWN1 persistent world for tinkerers. |
|
Back to top |
|
|
virusman
Joined: 30 Jan 2005 Posts: 1020 Location: Russia
|
Posted: Mon Feb 16, 2015 18:40 Post subject: |
|
|
Try nwnx_optimizations _________________ In Soviet Russia, NWN plays you! |
|
Back to top |
|
|
Baaleos
Joined: 02 Sep 2007 Posts: 830
|
Posted: Wed Feb 18, 2015 2:03 Post subject: |
|
|
is nwnx_optimizations around for windows? |
|
Back to top |
|
|
Baaleos
Joined: 02 Sep 2007 Posts: 830
|
Posted: Wed Feb 18, 2015 2:04 Post subject: |
|
|
elven wrote: | Baaleos wrote: | http://stackoverflow.com/questions/71257/suspend-process-in-c-sharp
It seems we are both right.
OS's don't generally allow you to limit CPU, infact- you cannot limit CPU.
CPU is just used when its needed.
What you can do however, is suspend threads or full processes at rapid intervals in order to slow a process down.
I am using such an application now - which is called BEX - Which can set an upper limit for your cpu usage per process.
I am going to study its source and try to port to C# and then make it adaptive so it adjusts for player count. |
That's exactly what I meant. Linux has cgroups noawadays, or the simple SIGSTOP SIGCONT trick (that you mentioned).
If there isn't anything important going on inside nwserver when no players are online, you might as well suspend the process until someone tries to log in. Is that even cheaper? |
I'd say you cannot suspend it completely - otherwise a player cannot log in.
Need to keep some sort of process activity going to accept the connection, then after login, can release the kraken |
|
Back to top |
|
|
elven
Joined: 28 Jul 2006 Posts: 259 Location: Germany
|
Posted: Wed Feb 18, 2015 10:43 Post subject: |
|
|
Baaleos wrote: | I'd say you cannot suspend it completely - otherwise a player cannot log in.
Need to keep some sort of process activity going to accept the connection, then after login, can release the kraken |
Yeah I know. I was thinking about some kind of very simple udp proxy that just resumes the process when a packet arrives. Haven't ever tested that idea though since I'm not limited by CPU cycles. _________________ silm.pw, a player-driven Forgotten Realms NWN1 persistent world for tinkerers. |
|
Back to top |
|
|
Baaleos
Joined: 02 Sep 2007 Posts: 830
|
Posted: Thu Feb 19, 2015 15:15 Post subject: |
|
|
Strangely enough - it looks like my server has suddenly become more efficient in regards to its heart beats etc
I was using that BES application to limit the CPU usage to 70 of normal, but even with it turned off now - it seems that I am getting passive / idle CPU Usage at around 6-9%
Normally after 2-3 hours, when the heartbeats and events start spawning on the server, the CPU would spike to 60-80% even without players online.
I guess the check I added in for
if(GetFirstPC() == OBJECT_INVALID){return;}
Is having a positive impact. |
|
Back to top |
|
|
|