|
ragautier Beginner
Joined: 11 Aug 2007 Posts: 29
|
Posted: Wed Sep 12, 2007 5:44 pm
[2.03] Severe trigger slow-down when pattern matching significant spaces |
I created a trigger that matches text where whitespace is significant:
In my case
matching 'Invisibility' with 6 trailing spaces.
This was to ensure that 'Detect Invisibility' was not matched - the way it appears in the printout is such that the longer 'Detect Invisibility' can only ever have 4 spaces after it.
Any-who - when I added this trigger, it slowed down trigger processing whenever that trigger class is enabled. The slowdown seems to occur the first time the trigger is processed after waiting 2 minutes or so. If you enable that trigger class within a few seconds, there is no slowdown. But if you wait a while, and then (programatically) enable that trigger class containing that pattern, it slows down the MUD I/O severely as it tries to process that trigger set.
This behaviour was not present until I added this particular matching scheme. |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Wed Sep 12, 2007 6:25 pm |
I added a code tag to your post to preserve the spacing.
Check that the compiled pattern and the regex equivalent on the test trigger page aren't doing something weird. For me, that pattern doesn't compile.
You could probably use a regex to create a speedier pattern in the meantime. |
|
|
|
Thinjon100 Apprentice
Joined: 12 Jul 2004 Posts: 190 Location: Canada
|
Posted: Wed Sep 12, 2007 6:57 pm |
I agree with Fang, you'll want to check the regex pattern that it's generating... it should be something like:
Code: |
#REGEX {Invisibility\s{6,6}} {whatever}
|
That would match "Invisibility" followed by 6 spaces.
Or, if you want to get really rather advanced:
Code: |
#REGEX {(?<!Detect\s)Invisibility} {whatever}
|
This will match "Invisibility" where it is NOT preceded by "Detect ".
Which of these executes faster in the regex engine, I don't know. The second example uses negative lookbehind, so it's possible CMud might not even compile it. |
|
_________________ If you're ever around Aardwolf, I'm that invisible guy you can never see. Wizi ftw! :) |
|
|
|
gamma_ray Magician
Joined: 17 Apr 2005 Posts: 496
|
Posted: Wed Sep 12, 2007 8:00 pm |
CMud doesn't (last I tried) do lookarounds. Which annoys me, but not enough to really complain.
You can just use "Invisibility {6}" though. |
|
|
|
Seb Wizard
Joined: 14 Aug 2004 Posts: 1269
|
Posted: Wed Sep 12, 2007 11:05 pm |
ragautier, is you are right, that was a good catch! I have noticed similar trigger slow-down and excessive CPU usage when parsing a single line of text from the MUD after a while of operation but hadn't yet tracked it down.
|
|
|
|
Seb Wizard
Joined: 14 Aug 2004 Posts: 1269
|
Posted: Wed Sep 12, 2007 11:10 pm |
Having just started doing a bit of testing, CPU is a lot higher with the Package Editor open. ragautier, you may want to test with and without the Package Editor open...
|
|
|
|
ragautier Beginner
Joined: 11 Aug 2007 Posts: 29
|
Posted: Wed Sep 12, 2007 11:54 pm |
I came home and I'm not seeing the same slowdown -
btw: Invisibility{6} doesn't seem to match Invisibility followed by 6 spaces...what am I doing wrong?
For now I have it entered with the 6 spaces and the compiled says it's right... |
|
|
|
gamma_ray Magician
Joined: 17 Apr 2005 Posts: 496
|
Posted: Wed Sep 12, 2007 11:57 pm |
It's not Invisiblity{6}, it's Invisiblity_{6} where _ is actually a space, heh. Make sure you tick the Regex box, too, of course.
|
|
|
|
|
|