Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum Goto page Previous  1, 2, 3, 4
oldguy2 Posted: Sat Nov 03, 2007 8:05 am
[2.10] SLOWWWWWW
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Thu Nov 08, 2007 11:17 am   
 
Well I was wrong as usual.

Apparently just changing all my curing to use functions instead of aliases and the change to the alarms, fixed everything pretty much.

It is running smooth as can be now. However, I am still waiting to be attacked by 3 or 4 people at once so I can really see if the same slowdown happens. I did a lot of testing today and had a single person go all out on me and it worked perfectly.

I can't wait until 2.11 to get the new debugger and timestamps.
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Thu Nov 08, 2007 5:10 pm   
 
oldguy2: I hope you saved an old copy of your scripts before you made these changes so that we can still learn what caused the slowdown when the 2.11 debugger is available. Functions and aliases are almost identical in CMUD, so I'd be interested in anything that showed a big speed difference between them.

Anyway, glad you got it working better so that you can at least play with it now.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Thu Nov 08, 2007 5:19 pm   
 
The key difference between functions and aliases, though, is that functions aren't tested for each line of text you send, and he had a lot of aliases he wasn't calling from the commandline (414 aliases total - 1348 triggers, too!). If oldguy hasn't kept it, I still have a copy of the old package that we can try the debugger on.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Thu Nov 08, 2007 5:22 pm   
 
I still have it. I keep copies of everything.

Yeah do you know how long it took me to totally redo that? haha
Reply with quote
Malach
Apprentice


Joined: 03 Nov 2007
Posts: 132

PostPosted: Thu Nov 08, 2007 5:26 pm   
 
Wait, so if we're calling the alias from within a script and never will call it from the commandline we should make it a function? I'm confused.
_________________
Intel Core2 Quad CPU @ 2.4 GHZ with Windows Vista Home Premium and 2 GB Ram
Reply with quote
Asilient_1
Apprentice


Joined: 26 Apr 2007
Posts: 113

PostPosted: Thu Nov 08, 2007 5:29 pm   
 
In day-to-day use, I'm fine. In some combat, I'm fine. but at other times, my speed drops in a huge way. I've spent the last few days doing the small bits and pieces to improve the speed of my scripts. Since I've basically done all I can think of -now- I'm at a complete loss as where to go next as far as making my scripts "faster" goes.

Yes, I can wait until 2.11 for the debugger, etc, but are there any tips for things I could do now? I tend to occupy my free time playing around with my packages.

For instance, I know someone mentioned calling on aliases in triggers could be slow. Is there any way of doing that differently short of pasting the entire script into the trigger itself? Even if it's just common pointers in general, I'd appreciate it.
Reply with quote
Asilient_1
Apprentice


Joined: 26 Apr 2007
Posts: 113

PostPosted: Thu Nov 08, 2007 5:31 pm   
 
I'm actually confused as to how to make a function operate like an alias myself, actually. O.o I've not really been able to glean anything from the help files about it.

Also, sorry for the double post- I forgot to click "submit" on my last one.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Thu Nov 08, 2007 5:50 pm   
 
Changing aliases to functions seems to have worked pretty well for oldguy. Basically, because you're never going to call it from the command line, you should make it so you can't call it from the command line, and functions and aliases are both intended to do the same thing - simplify running the same command(s) repeatedly.

In the future, making a function that doesn't return a value and only runs commands will be simple. You just create a function object the same way you'd create an alias or a trigger and fill in the name and commands. The only difference with the current implementation is that the function has to have "#return something" at the end. If in the past you had an alias called "DoStuff" and you changed it into a function called "DoStuff", instead of just entering its name on a new line in a script, you'd do "#call @DoStuff()".

As for general speed boosting tips, the biggest one is simple: Less is more. Use as few triggers and aliases as you can, and there'll be fewer to check as each command/line is parsed. Also know that using string lists and data record variables is slower than using variables with a single value, because of hash lookups (but at the cost of being an arse to organise).
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Thu Nov 08, 2007 5:55 pm   
 
So you are saying I should probably change my afflictions database and defenses database and other databases back to hundreds of variables with a single value?
Reply with quote
Malach
Apprentice


Joined: 03 Nov 2007
Posts: 132

PostPosted: Thu Nov 08, 2007 5:55 pm   
 
So I should be using #CALL to access my functions that are just acting as aliases instead of just @FunctionName() ?
_________________
Intel Core2 Quad CPU @ 2.4 GHZ with Windows Vista Home Premium and 2 GB Ram
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Thu Nov 08, 2007 5:57 pm   
 
Like this. Lets say your herb curing is an alias called herbheal. That's what mine is.

So on a trigger that afflicts me with an affliction that needs cured by an herb in the value of that trigger I would put #call @herbheal().
Reply with quote
Asilient_1
Apprentice


Joined: 26 Apr 2007
Posts: 113

PostPosted: Thu Nov 08, 2007 6:01 pm   
 
Ah, I had it right. I thought #CALL was applicable, but the help files didn't really offer much in the way of this. Maybe I'm just asking for a little too much detail, though. Thanks for the help. :)

I adopt one, maybe two stringlists, so I'm doubtful that will slowdown too much?
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Thu Nov 08, 2007 6:05 pm   
 
@Oldguy: No, I'm leaving that choice up to you. I'm saying that if you value the speed more than you value the nice organisation, you should change it. Either position is valid and what you want to get out of your scripts is up to you.

@Malach: Not should, must. I'm very surprised that calling a function works at all without an explicit #call command - starting a line with anything other than a command or literal text doesn't normally work. Nevertheless, not using #call doesn't behave like you'd expect. Compare:

#function omg {#say hah;#return "lol"}
#alias test1 {@omg()}
#alias test2 {#call @omg()}

test1 prints "hah" but also sends "lol" to the server because of the way aliases work ("lol" is left on the stack, and because it's on the stack when the alias finishes, it's sent to the server). You must use #call to call functions.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)

Last edited by Fang Xianfu on Thu Nov 08, 2007 6:09 pm; edited 1 time in total
Reply with quote
Malach
Apprentice


Joined: 03 Nov 2007
Posts: 132

PostPosted: Thu Nov 08, 2007 6:07 pm   
 
Okay so basically if you have an alias, every time you enter a command on the commandline it's checking every alias to find a match? So if you have a lot of aliases it's going to slow things down. So if you can cut down on aliases through only having things be aliases if they are actually going to be called from the command line then you'll see a performance increase. That's how I'm understanding it, is that right?
_________________
Intel Core2 Quad CPU @ 2.4 GHZ with Windows Vista Home Premium and 2 GB Ram
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Thu Nov 08, 2007 6:10 pm   
 
Indeed.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Thu Nov 08, 2007 7:20 pm   
 
Quote:
Okay so basically if you have an alias, every time you enter a command on the commandline it's checking every alias to find a match?

Yes, but that's why I'll be interested in oldguy's debug results with 2.11. Because CMUD uses a hash table lookup for aliases. So it actually shouldn't matter how many aliases you have defined. A hash lookup is mostly independent upon the size of the table. That's why I think there is something else going on here.
Reply with quote
Caled
Sorcerer


Joined: 21 Oct 2000
Posts: 821
Location: Australia

PostPosted: Thu Nov 08, 2007 9:07 pm   
 
@Fang
You mentioned that in the future, creating functions that return null values and only run commands will be simple. I assume by this you mean some planned future change to functions. Will this mean #CALL is not necessary for this? I'm asking because I don't want to make a larg base level change to my system if it can be done differently in a version or two's time.

Regarding the whole part about dbvars, stringlists and single-value variables, I'm wondering how big a difference is actually meant when you say they are slower.


#TR {You are paralysed} {iaff paralysis}
#AL iaff {a_%1}
#AL a_paralysis {col_bloodrootcured ; addha paralysis}
#AL addha {here I look up paralysis in a dbvar to find its priority number, then add this value to a stringlist}

Those are the different steps I take when an affliction comes in. I shall convert these to use functions (and perhaps iaff into an event since it is cross-package), but I am a little concerned now about the report of stringlists/dbvars being a bit slower. Is it only minutely slower? Will I notice a difference? As you can see it is fairly simple for me to change to single value vars, just by modifying addha (also addsa, addpa, remha, remsa, rempa), defining the variables, and of course building a new central alias.
_________________
Athlon 64 3200+
Win XP Pro x64
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Thu Nov 08, 2007 9:48 pm   
 
Clink the link, Caled. That's not what I mean. I shouldn't have said simple (because that implies that the current way is complex - it's not) I should've said "slightly simpler". The only difference is going to be that right now, your function must end in a #return command (the actual value is irrelevant as long as there is one). If it doesn't, it causes an error. In the future, if there's no #return command at the end of your function, a null return will be added automagically.

#CALL has been, is and will remain needed to properly call functions. Also, even if it were to become optional, it'd be just that - optional, and changing it now probably won't lead to it breaking in the future. Zugg's a stickler for backwards compatability.

You may or may not notice the speed difference. It depends on many things, not least of which is the kind of thing you're doing with the variable. If it's not broken, don't fix it - if you're not noticing a speed problem, like oldguy is, there's not much point in improving it when you could use the time to improve it some other way. The best thing you can do is try it and see if you notice the difference.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Fri Nov 09, 2007 12:03 am   
 
I think this talk about string lists is a bit confusing. A string list that contains only a single value is slightly slower than a plain variable that contains that value. This is because CMUD needs to build the hash table of one item. But if you need a string list, you should certainly use it.

Maybe what Fang is talking about is that you shouldn't put string lists into database variables. For example:

#ADDKEY DbVar List {a|b|c}

because CMUD treats each value of a database variable as a plain string value, and it will not store any hash table for that string list. So each time you reference the @DB.List string list, CMUD needs to rebuild the hash table for it.

Building the hash table doesn't take very long. Basically, if CMUD needs to rebuild the hash table, then you will get a speed that is about the same as the speed in CMUD 1.34. So I wouldn't think of it as "slow", I'd just remember that if you nest lists within lists or lists within database variables, then you won't get the speed boost that hash tables might provide otherwise.

Anyway, don't get carried away with this stuff. Remember that I still consider any difference between using an alias and using a function as a bug. So I wouldn't spend a lot of time changing stuff unless you absolutely need to. And definitely don't get the idea that you shouldn't use string lists or database variables. The hash tables in v2.0x make these *much* faster than in older versions of CMUD and zMUD, and you'd be losing a lot of these improvements if you got rid of your string lists.
Same thing for storing a nested string list within a string list. CMUD only saves the hash table of the main variable and not for any sub-lists within it.
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Fri Nov 09, 2007 1:42 am   
 
Quote:
I'm very surprised that calling a function works at all without an explicit #call command - starting a line with anything other than a command or literal text doesn't normally work.


Fang he reason for this in two-fold. First backwards compatibility with zMUD style functions and so that they can be used in Status Lines and Windows.
_________________
Asati di tempari!
Reply with quote
Caled
Sorcerer


Joined: 21 Oct 2000
Posts: 821
Location: Australia

PostPosted: Fri Nov 09, 2007 7:48 am   
 
Thanks for the reassurance, Zugg. I designed my system a long time ago when speed was really difficult to get (old versions of zmud with crap computers) so I'm comfortable with the way I do things as is and was not liking the idea of changing everything to functions.

As for stringlists, even if they were going to be a bit slower, I doubt I would have gone away from it. They are too convenient to use.
_________________
Athlon 64 3200+
Win XP Pro x64
Reply with quote
Asilient_1
Apprentice


Joined: 26 Apr 2007
Posts: 113

PostPosted: Sat Nov 10, 2007 11:05 am   
 
I've not tested this too extensively on 2.11 (bearing in mind I have not changed all too much in my package.) but it doesn't seem like there's a slowdown at all on 2.11.

The only time I've noticed the client itself being slow is when the debugger is running. (for obvious reasons.)

I'll try picking a few fights and see how it holds up to try and confirm this further.
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Sat Nov 10, 2007 3:04 pm   
 
I don't notice it either. I can't really tell much from the debugger though everything is repeating itself.
Reply with quote
Asilient_1
Apprentice


Joined: 26 Apr 2007
Posts: 113

PostPosted: Sat Nov 10, 2007 3:31 pm   
 
The only repeating I noticed was if I had something colored in the line I triggered, etc.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum All times are GMT
Goto page Previous  1, 2, 3, 4
Page 4 of 4

 
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

© 2009 Zugg Software. Hosted by Wolfpaw.net