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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
fattony
Apprentice


Joined: 27 Dec 2001
Posts: 105
Location: USA

PostPosted: Thu Aug 29, 2002 12:45 am   

Trigger Question
 
My settings file is ~450kb now, and it seems the larger the file gets the more it lags my computer. Much of that 450k are triggers. It is lagging too much to be effective now, so I am trying to speed it up some. I turned the triggers off, just to test it, and zMUD runs much faster. I was wondering if, when zMUD recieves a line from the MUD, does it check through EVERY trigger in my settings looking for matches? Would deleting a large chunk of them make it run any faster? Do aliases and vars and paths etc have any effect on speed? And finally, are there any other ways? I'd rather not delete my stuff if I can avoid it.

Fat Tony
Reply with quote
Charbal
GURU


Joined: 15 Jun 2001
Posts: 654
Location: USA

PostPosted: Thu Aug 29, 2002 1:38 am   
 
I was wondering if, when zMUD recieves a line from the MUD, does it check through EVERY trigger in my settings looking for matches?
Yes, zMUD goes through every _enabled_ trigger and runs a fairly quick check (detailed below) to figure out which triggers it should process further and see if there are matches.

Would deleting a large chunk of them make it run any faster?
Yes.

Do aliases and vars and paths etc have any effect on speed?
Compared to triggers, these have virtually no effect. Unless you are running up against your available memory and/or have an obscene number of them, I wouldn't expect any sort of problem.


And finally, are there any other ways? I'd rather not delete my stuff if I can avoid it.
Yes, and that's what the rest of this post is about :P


As you have seen, the triggers are the main part of the speed problem. When zMUD gets a line of text from the MUD, it compares it to each pattern and attempts to FAIL it as quickly as possible. As I understand it, this is done by finding the largest piece of text that must be present in a line for it to match the trigger (for example zMUD would look for the text "testing 123" in a trigger with the pattern "%w testing 123 {1|2|3}"). While this test must run through all the triggers, it is relatively fast. When a line passes this initial test for one or more trigger patterns, zMUD has to use the full-fledged parsing engine to figure out if it is really a match or just superficially similar. This is not as fast.

There are several ways to increase this speed. One method is eliminating triggers either permanantly or merely disabling them when not needed. Another is to revise those you have with patterns that are less likely to invoke the zMUD pattern parser. In addition to larger quantities of plain text, use of ^ and $ (see here) help considerably.

A related goal is making your triggers as restrictive as possible through the pattern. For example,

#TRIGGER {^(%w) says '*'$} {#IF (%1 = "Zugg" or %1 = "Charbal") {#CAPTURE FriendSays}}

becomes much slower than

#TRIGGER {^{Zugg|Charbal} says '*'$} {#CAPTURE FriendSays}

when you receive many says which don't pass the #IF check although both are logically equivalent.


So, the best way to design triggers is so that you have as few as possible matching as few things from the MUD as possible while anchoring the patterns with ^ and $ and matching as much plain text as you can.

Finally, an extreme example:

This is good:
#TRIGGER {^%w pokes you in the ribs.$} {say Hey, that's not nice!}

This isn't:
#TRIGGER {[a-z .]} {#IF (%trigger =~ "%w pokes you in the ribs.$") {say Hey, that's not nice!}}


 - Charbal
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
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

© 2009 Zugg Software. Hosted by Wolfpaw.net