Each time it's called, I get a run away. I had a freind write a custom one for us and it still runs away. I found a double call of client.inc and removed and it still runs away.
The info printed to the console shows lines of code in the 680-860 range. The script only has 400 lines of code, so I assume the part causing the problem is in one of my includes; string, skills, gumps.
Anyone else have this same experience and what have you done to stop it?
The Skill Window
Is there a for/foreach loop in there? If so just toss a SleepMS( 10 ); in there. Don't use redirect functions.
Example of a redirect function is like, GetEffectiveSkill( Who, skillid ); from attributes.inc all it does is this,
Or you could post the code and let us take a gander, lol.
Example of a redirect function is like, GetEffectiveSkill( Who, skillid ); from attributes.inc all it does is this,
Code: Select all
function GetEffectiveSkill( who, skillid )
return GetAttribute(who, GetAttributeIdBySkillId(skillid));
endfunctionYou're kidding me...
The guy who did a lot of the work customizing the server I have does that all the time. Can you tell me why that's a problem? It's not that I don't believe you, but I'd just like to understand the reasoning before I go and start fixing that kind of crap in hundreds of places in my code.
The guy who did a lot of the work customizing the server I have does that all the time. Can you tell me why that's a problem? It's not that I don't believe you, but I'd just like to understand the reasoning before I go and start fixing that kind of crap in hundreds of places in my code.
actually there can be more lines of code than you think due to calls to inc files and such (the lines in the inc file count too)...
So here's what you do. You can see the line numbers but these are not line numbers in your scripts.
Instead, look for a file (scriptname).lst.
If you dont have it, open ecompile.cfg and set GenerateListing 1.
Recompile your script.
Now the .lst file should appear and you should open it with a text editor.
The writing you see in that file is exactly what the console is displaying. Scroll down to the numbers that are being shot off in the console. Every few lines, you'll see a piece of source code and when using includes, you'll also be able to scroll up and maybe find a file name. Just keep scrolling up from the stuff that the console is listing and you'll be going backwards through the source code thats running away. Pretty much 99.9999999% of the time, its a FOR, FOREACH, WHILE, REPEAT UNTIL, or DO WHILE without a SLEEP() or SLEEPMS() in it.
So here's what you do. You can see the line numbers but these are not line numbers in your scripts.
Instead, look for a file (scriptname).lst.
If you dont have it, open ecompile.cfg and set GenerateListing 1.
Recompile your script.
Now the .lst file should appear and you should open it with a text editor.
The writing you see in that file is exactly what the console is displaying. Scroll down to the numbers that are being shot off in the console. Every few lines, you'll see a piece of source code and when using includes, you'll also be able to scroll up and maybe find a file name. Just keep scrolling up from the stuff that the console is listing and you'll be going backwards through the source code thats running away. Pretty much 99.9999999% of the time, its a FOR, FOREACH, WHILE, REPEAT UNTIL, or DO WHILE without a SLEEP() or SLEEPMS() in it.
-
Firedancer
- Grandmaster Poster
- Posts: 104
- Joined: Fri Feb 03, 2006 6:32 am
As stated by unreal, a loop is the likely cause. I'd not worry too much about it, though. I for my part have to agree, I don't know why certain things trigger endless loops, when they merely have a few hundret repeats, but fact is, the core may think your script has an endless loop if it repeats too fast (usually less a problem on loops with more operations). I guess about priority... about the number of operations in a set time... but anyway, fact is that adding as much as a sleepms(1) at the beginning of such a loop fixes the problem, as the core no longer recognizing it as a runaway loop - thus no console print lines - thus no performance impact.
So actually I think doing loops without sleep is perfectly fine. Only the endless-loop recognition is a problem on certain fast loops, as the console output will decrease your performance.
I thus see no reason to change this in all your code, but I would merely verify those scripts, where the console does report a runaway condition... and if the runaway feedback is wrong, just add a sleepms(1) to remove the problem. Alternatively, there's the option to simply surpress runaway warnings for that script as such, but doing so is usually not a good option because you might change the code at a later time and then you'd be unable to detect a real runaway script... and this can cost you weeks of coding to find!
So actually I think doing loops without sleep is perfectly fine. Only the endless-loop recognition is a problem on certain fast loops, as the console output will decrease your performance.
I thus see no reason to change this in all your code, but I would merely verify those scripts, where the console does report a runaway condition... and if the runaway feedback is wrong, just add a sleepms(1) to remove the problem. Alternatively, there's the option to simply surpress runaway warnings for that script as such, but doing so is usually not a good option because you might change the code at a later time and then you'd be unable to detect a real runaway script... and this can cost you weeks of coding to find!
Excellent. Thank you all very much. I thought that what I was hearing was essentially a band-aid to a core issue. I've noticed that a lot of scripters stick Sleep statements into scripts for "unknowable" reasons. I remove them.
Now, can someone answer my other question about "redirect functions"? In the sample function that Unreal listed, I can see that such a function is basically a waste of extra code. Is that the only problem with it? I mean, if you're just passing a couple variables to a function for the purpose of executing a core function on those variables, why bother writing the function to begin with? I could understand creating a function if you had a lot of other useful code being executed afterward....
So, is that the only reason to avoid it, or is there something else I'm missing?
Thanks!
Oh yeah, thanks Firedancer. You are, of course, correct that the other includes include more includes. That brings up yet another fairly common issue that I run across....include files that include other includes that include the original include file. I don't know if they ever went through the distro and cleaned that up, but I have found that some difficult to squash bugs related to that kind of thing....you can actually have code re-executing using old variable information if the functions were not well written.
Now, can someone answer my other question about "redirect functions"? In the sample function that Unreal listed, I can see that such a function is basically a waste of extra code. Is that the only problem with it? I mean, if you're just passing a couple variables to a function for the purpose of executing a core function on those variables, why bother writing the function to begin with? I could understand creating a function if you had a lot of other useful code being executed afterward....
So, is that the only reason to avoid it, or is there something else I'm missing?
Thanks!
Oh yeah, thanks Firedancer. You are, of course, correct that the other includes include more includes. That brings up yet another fairly common issue that I run across....include files that include other includes that include the original include file. I don't know if they ever went through the distro and cleaned that up, but I have found that some difficult to squash bugs related to that kind of thing....you can actually have code re-executing using old variable information if the functions were not well written.
I tend to not like that part either with includes including includes that go and redirect back to the old includes but the .lst file does help massively in tracking which file its in and what code is doing it.
Redirect functions basically seem like they were either made to give fancier names to core functions or were functions that did more before the core actually had the one command. They do only end up decreasing performance a bit now since POL has to do the work of carrying the variables over to a function just to do 1 command.
As for putting sleeps in for "unknown" reasons, they help in overall performance of the shard. You dont need them everywhere but they are in for a purpose. You see sleepms appear a lot because you want to give a bit of a rest without really anyone noticing it. Think of POL as your worker. If it was you and you worked overtime to do millions of tasks per minute, wouldnt you like a bit of a break? Thats what sleeps do. Dont try to make everything happen as fast as possible because unless you have one of the most powerful computers in the world, your CPU usage is going to hit the roof and your shard is going to lag horribly for it.
Redirect functions basically seem like they were either made to give fancier names to core functions or were functions that did more before the core actually had the one command. They do only end up decreasing performance a bit now since POL has to do the work of carrying the variables over to a function just to do 1 command.
As for putting sleeps in for "unknown" reasons, they help in overall performance of the shard. You dont need them everywhere but they are in for a purpose. You see sleepms appear a lot because you want to give a bit of a rest without really anyone noticing it. Think of POL as your worker. If it was you and you worked overtime to do millions of tasks per minute, wouldnt you like a bit of a break? Thats what sleeps do. Dont try to make everything happen as fast as possible because unless you have one of the most powerful computers in the world, your CPU usage is going to hit the roof and your shard is going to lag horribly for it.
-
Firedancer
- Grandmaster Poster
- Posts: 104
- Joined: Fri Feb 03, 2006 6:32 am
yep... sleeps also have the effect to tell the system to go do something else... so if your script isn't overly important but run often and having loads of operations,, this helps to make sure that other scripts also get some cpu power.CWO wrote:As for putting sleeps in for "unknown" reasons, they help in overall performance of the shard. You dont need them everywhere but they are in for a purpose. You see sleepms appear a lot because you want to give a bit of a rest without really anyone noticing it. Think of POL as your worker. If it was you and you worked overtime to do millions of tasks per minute, wouldnt you like a bit of a break? Thats what sleeps do. Dont try to make everything happen as fast as possible because unless you have one of the most powerful computers in the world, your CPU usage is going to hit the roof and your shard is going to lag horribly for it.
As to includes in includes.... seriously to me that's a no-go as long as pol compiler can't handle double references to a single include file. ==> Thus on my shard I've made it a rule, that includes that require further files will only list that as a comment in the header (so you know what they need)... but the actual include statements are only added to the src files.
Even if the include requires stuff... you never know and someday you may have the situation where you need 2 includes that both refer to the same, third, include - and then you gotta change hundrets of files.
I have been spending the last couple of years going through each system and package on my server cleaning this very thing up. I am hoping to finally be finished at some point. This is a very good rule to have IMO.Firedancer wrote: As to includes in includes.... seriously to me that's a no-go as long as pol compiler can't handle double references to a single include file. ==> Thus on my shard I've made it a rule, that includes that require further files will only list that as a comment in the header (so you know what they need)... but the actual include statements are only added to the src files.
Even if the include requires stuff... you never know and someday you may have the situation where you need 2 includes that both refer to the same, third, include - and then you gotta change hundrets of files.