logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Idle CPU use bug with nwn2server.exe: future xp_bugfix?

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Development
View previous topic :: View next topic  
Author Message
AcadiusLost



Joined: 15 Dec 2007
Posts: 26
Location: Charlottesville, VA

PostPosted: Thu Nov 19, 2009 21:22    Post subject: Idle CPU use bug with nwn2server.exe: future xp_bugfix? Reply with quote

I've been tremendously impressed with the success Skywing has had so far in working around shortcomings of the nwn2server application. I was curious whether he had tried to look into the "CPU use" bug at all, as it seems the sort of thing that might be best addressed through the same means (well, best would be a fix in an official NWN2 patch, but those aren't looking to be frequent, and it's often difficult to get good lines of communication with OEI to supply enough details to characterize bugs.

The "symptom" most module maintainers/hosts are likely familiar with, they look at the server when it's been empty for a while, and find that the CPU (or whichever core is assigned to the NWN2server process) is running at 100%. The xp_profiler plugin doesn't report any particular script running heavy. If it runs too long at 100%, the server tends to crash.

Now, if a client connects to the server during all of this (DM client or player client, doesn't matter which), the CPU drops instantly down to normal near-zero-percent utilization. (or more, if you run a script-heavy module). That client can remain on for hours to indefinitely with no recurrence of the CPU climb, but as soon as they log off (and the server moves to 0 clients logged in), up it begins to climb again.

More specifically, it is when the first client selects a character/avatar to enter the module with and begins to load the first area of the module, that you see the "return to normalcy".

To address the climb in CPU use briefly; the rate of climb is roughly proportional to the number of objects in-game which possess OnHeartbeat events. Even if the scripts in those slots merely "return;" the climb suffers. If those scripts are deleted from the module entirely (NSS and NCS), the idle CPU creep is slowed or removed. Cutting areas filled with doors possessing an empty OnHeartbeat script improves the climb incrementally, for example.

The profile of the CPU climb itself is interesting, if you watch it via task manager while running a module possessing many heartbeat-event containing objects; small peaks approximately 6 seconds apart grow and merge into each other until the CPU is entirely consumed.

So, in total, this appears to be a specific problem with the OnHeartbeat event, particularly pretaining to the condition of a server having zero clients connected. My guess would be an optimization present while PCs are on needs to be running in their absence as well; or some kind of powersaving/resource conservation system that kicks in when no clients are associated, which is horribly broken.

Is this the sort of thing that could be addressed by a future xp_bugfix?

If clarification of the symptoms, or example mods, are needed; I can see about making those available as well.
_________________
Technical Administrator
A Land Far Away, a Persistent World Project
Back to top
View user's profile Send private message Visit poster's website
Zebranky



Joined: 04 Jun 2006
Posts: 415

PostPosted: Thu Nov 19, 2009 23:33    Post subject: Reply with quote

Example mods are always nice. Aside from that, nice description.
_________________
Win32 SVN builds: http://www.mercuric.net/nwn/nwnx/

<Fluffy-Kooshy> NWNx plugin is to this as nuclear warheads are to getting rid of fire ants.

<ThriWork> whenever I hear nwn extender, I think what does NWN need a penis extender for?
Back to top
View user's profile Send private message Visit poster's website
Skywing



Joined: 03 Jan 2008
Posts: 321

PostPosted: Sun Nov 22, 2009 1:47    Post subject: Reply with quote

I've seen this happening as well, but hadn't dug into it too much as most environments I dealt with were not terribly idle or had only very limited sets of creatures active at any given time (and thus weren't severely impacted).

I suspect there's an AI event that only happens when players are present that's at the root of this somewhere, but I have not really tracked it down in more detail than that.

I think that I saw that Zebranky did a bit of analysis on this a few days ago, maybe he found which AI event the AI master keeps iterating through when CPU usage becomes high?
Back to top
View user's profile Send private message
AcadiusLost



Joined: 15 Dec 2007
Posts: 26
Location: Charlottesville, VA

PostPosted: Tue Nov 24, 2009 20:45    Post subject: Reply with quote

I should add, perhaps, that this problem is still quite evident in ALFA's mods, in which no creature instances are toolset-placed (all creatures are spawned on demand, and despawned when areas are inactive for sufficient time)- so whatever the root cause is, it does not seem to be rooted in creature AI or events.
_________________
Technical Administrator
A Land Far Away, a Persistent World Project
Back to top
View user's profile Send private message Visit poster's website
Skywing



Joined: 03 Jan 2008
Posts: 321

PostPosted: Wed Nov 25, 2009 20:34    Post subject: Reply with quote

AIUpdate processing actually happens for objects of all types.

I can try turning off restarts in one of my environments for awhile to look at this some more, perhaps.
Back to top
View user's profile Send private message
Skywing



Joined: 03 Jan 2008
Posts: 321

PostPosted: Fri Dec 26, 2014 8:00    Post subject: Reply with quote

If you install the NWScript Accelerator plugin, this issue is fixed.

The actual problem was that the server was building up an internal buffer containing a list of all scripts executed, that never gets flushed until a player is present.

If a player never logs on, the buffer keeps getting larger and reallocations take more and more time.

The functionality using this buffer is not present in the retail build of the game, so the NWScript Accelerator plugin simply disables that code.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Development All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group