Large module idle CPU use, ACR hearbeat concerns
Posted: Tue Mar 11, 2008 5:28 pm
This one is primarily directed to Cipher, but others are welcome to share thoughts- currently we instruct builders to include the acf_* handler functions in each of the events of the module (areas, placeables, triggers, doors, creatures, and the module itself). These include acf_*_onheartbeat scripts, which call their respective functions in the acr includes, to give us hooks into those events for core scripting.
So far, I haven't seen much done with the OnHeartbeat functions in the ACR- the only system that consistently hooks into them is the VFX system, which checks a few local strings, then tries to apply an effect based on them (which will do nothing if the strings aren't set). According to the NWNx4 script profiler, these heartbeat scripts don't use any significant CPU time individually. However, for something like the placeables heartbeat, it's potentially firing once per six seconds for every placeable in every area of the module. The script profiler was registering that the acf_plc_onheartbeat was being called very often- for example, a 2-hour run of the 003 module with the Silverymoon university attached generated 254,818 calls to acf_plc_onheartbeat.
While players are on, these heartbeats seem not to cause problems- but for whatever reason, while the server is idle/empty, they seem to eat up more and more CPU utilization over time- in the worst cases (all complex interiors present for 003), it would reach 100% CPU use in only 20 minutes or so of idle time. A player logging in would bring it back down, but the climb would begin again when the player logged back out again.
On a hunch, I tried deleting the acf_plc_onheartbeat.ns entirely, and now the same module shows a much slower CPU climb, only becoming noteable after 10 hours or so of idle time- and even then not nearing the max-CPU behaviour present with the placeable heartbeats running.
Do we have a real need for any of the heartbeat events in the ACR, or can we safely remove it from most of them? I suspect the bulk of the remaining climb comes from area, trigger, and door heartbeats, which are always present even when players are not logged in. It seems like, for whatever reason, when no one is on, running even simple local variable checks on these events is responsible for the CPU climb which, as a host, makes me hesitant to leave the server unattended for extended periods, lest it wear on the host machine's CPU unnecessarily.
I suppose we can also see if just removing the VFX system solves the problem, as it may be something specific to that (reading local strings, or trying to apply a null effect) causing the difficulty. Thoughts?
So far, I haven't seen much done with the OnHeartbeat functions in the ACR- the only system that consistently hooks into them is the VFX system, which checks a few local strings, then tries to apply an effect based on them (which will do nothing if the strings aren't set). According to the NWNx4 script profiler, these heartbeat scripts don't use any significant CPU time individually. However, for something like the placeables heartbeat, it's potentially firing once per six seconds for every placeable in every area of the module. The script profiler was registering that the acf_plc_onheartbeat was being called very often- for example, a 2-hour run of the 003 module with the Silverymoon university attached generated 254,818 calls to acf_plc_onheartbeat.
While players are on, these heartbeats seem not to cause problems- but for whatever reason, while the server is idle/empty, they seem to eat up more and more CPU utilization over time- in the worst cases (all complex interiors present for 003), it would reach 100% CPU use in only 20 minutes or so of idle time. A player logging in would bring it back down, but the climb would begin again when the player logged back out again.
On a hunch, I tried deleting the acf_plc_onheartbeat.ns entirely, and now the same module shows a much slower CPU climb, only becoming noteable after 10 hours or so of idle time- and even then not nearing the max-CPU behaviour present with the placeable heartbeats running.
Do we have a real need for any of the heartbeat events in the ACR, or can we safely remove it from most of them? I suspect the bulk of the remaining climb comes from area, trigger, and door heartbeats, which are always present even when players are not logged in. It seems like, for whatever reason, when no one is on, running even simple local variable checks on these events is responsible for the CPU climb which, as a host, makes me hesitant to leave the server unattended for extended periods, lest it wear on the host machine's CPU unnecessarily.
I suppose we can also see if just removing the VFX system solves the problem, as it may be something specific to that (reading local strings, or trying to apply a null effect) causing the difficulty. Thoughts?