05-10-2013, 10:24 AM
Another thread discussed rubberbanding at one of the major KittyCatS market regions. Charm uses that region, and she's made some comments about it, as well.
Now, there are a number of possible causes for problems. But a major cause is the sheer number of scripts in the region. So I took a couple minutes to examine the script usage.
In boxes, I note there very few scripts. But in live cats, there are quite a few.
Scripts cause lag in several ways.
When the script is executing, it takes processing time.
If the script is not executing, but is "running", it's waiting for events. Cats seemingly sitting doing nothing are waiting for events such as timers and communications from scratching posts, HUDs, etc. The means, for each likely event which the script might be waiting for, the simulator must check that running script to see if it's interested in the event.
Cats are ALWAYS listening for communications from the HUDS. The means for EVERY script in EVERY cat, which is currently running, the simulator must check THAT script to see if a message (say, you saying "Hi, how's it going" to a friend in Local Chat) is one the script might be interested in.
So, even though the script is "running" but "idle, waiting for an event" it's still using processing time. That's tiny, per script, per cat, but it adds up in a hurry when you consider that an active simulator will be throwing hundreds and thousands of events per second.
A script which is NOT running, such as many of the scripts in a live cat, still causes lag. Why? Because, even though it's not running, it still consumes memory. Even though only 3 of the one or two dozen scripts in a live cat are generally running, the memory for ALL of those two dozen scripts must be allocated and reserved for each script.
This means, if there are a LOT of live cats, there's a HUGE amount of memory reserved for their non-running scripts.
Now, if there is enough actual memory, that's not a problem. But there may not be. In fact, there probably isn't. When there isn't enough memory, the operating system "swaps" some out to a file on disk. That takes time. And, if the memory is needed again, it must swap something else out to make room, and re-load the saved memory In the trade, when this occurs, we call it "thrashing" (think of trashing wheat and the mess it makes and you get the idea).
My theory is that one of the reasons some of the major KittyCatS market regions are seeing performance problems is that, with so many cats, meaning so many scripts (running or not), and coupled with the fact that several regions share the physical machine's memory, the memory is thrashing.
The question is: is there anything KittyCatS can do to help alleviate this issue?
The answer is: YES!
Many of those "not-running" scripts don't NEED to be there!
Consider: if a cat is in 2D mode, it can't move, it can't be posed, it won't talk, it can't be cuddled, etc. So ELIMINATE those scripts which can't possible be activated, based upon the cat's current mode.
Often, of course, we'll see full 3D cats. But they're posed for display and the owner does not want them DOING anything. Adding a special "marketing mode" (offering a selection of set poses) and rezzing a new Market-Mode cat would allow many of those unneeded scripts to be candidates for elimination.
For scripts which can't be eliminated, consolidating several features into a single script, especially is those features are generally running or not-running at the same time, can reduce scripts, as well and should be considered.
Now, there are a number of possible causes for problems. But a major cause is the sheer number of scripts in the region. So I took a couple minutes to examine the script usage.
In boxes, I note there very few scripts. But in live cats, there are quite a few.
Scripts cause lag in several ways.
When the script is executing, it takes processing time.
If the script is not executing, but is "running", it's waiting for events. Cats seemingly sitting doing nothing are waiting for events such as timers and communications from scratching posts, HUDs, etc. The means, for each likely event which the script might be waiting for, the simulator must check that running script to see if it's interested in the event.
Cats are ALWAYS listening for communications from the HUDS. The means for EVERY script in EVERY cat, which is currently running, the simulator must check THAT script to see if a message (say, you saying "Hi, how's it going" to a friend in Local Chat) is one the script might be interested in.
So, even though the script is "running" but "idle, waiting for an event" it's still using processing time. That's tiny, per script, per cat, but it adds up in a hurry when you consider that an active simulator will be throwing hundreds and thousands of events per second.
A script which is NOT running, such as many of the scripts in a live cat, still causes lag. Why? Because, even though it's not running, it still consumes memory. Even though only 3 of the one or two dozen scripts in a live cat are generally running, the memory for ALL of those two dozen scripts must be allocated and reserved for each script.
This means, if there are a LOT of live cats, there's a HUGE amount of memory reserved for their non-running scripts.
Now, if there is enough actual memory, that's not a problem. But there may not be. In fact, there probably isn't. When there isn't enough memory, the operating system "swaps" some out to a file on disk. That takes time. And, if the memory is needed again, it must swap something else out to make room, and re-load the saved memory In the trade, when this occurs, we call it "thrashing" (think of trashing wheat and the mess it makes and you get the idea).
My theory is that one of the reasons some of the major KittyCatS market regions are seeing performance problems is that, with so many cats, meaning so many scripts (running or not), and coupled with the fact that several regions share the physical machine's memory, the memory is thrashing.
The question is: is there anything KittyCatS can do to help alleviate this issue?
The answer is: YES!
Many of those "not-running" scripts don't NEED to be there!
Consider: if a cat is in 2D mode, it can't move, it can't be posed, it won't talk, it can't be cuddled, etc. So ELIMINATE those scripts which can't possible be activated, based upon the cat's current mode.
Often, of course, we'll see full 3D cats. But they're posed for display and the owner does not want them DOING anything. Adding a special "marketing mode" (offering a selection of set poses) and rezzing a new Market-Mode cat would allow many of those unneeded scripts to be candidates for elimination.
For scripts which can't be eliminated, consolidating several features into a single script, especially is those features are generally running or not-running at the same time, can reduce scripts, as well and should be considered.