Fastest Trigger Types

User avatar
Vadi
Posts: 5035
Joined: Sat Mar 14, 2009 3:13 pm

Re: Fastest Trigger Types

Post by Vadi »

I'm also wondering if you'll still get 12million trigger-fails with the build in https://github.com/Mudlet/Mudlet/pull/3463 - let me know.

User avatar
demonnic
Posts: 884
Joined: Sat Dec 05, 2009 3:19 pm

Re: Fastest Trigger Types

Post by demonnic »

So then why don't we just nix exact match? If you put the full line into begin of line type it's the same thing from the user standpoint, but apparently fails much more swiftly.

fordpinto
Posts: 34
Joined: Wed Sep 25, 2019 4:59 pm

Re: Fastest Trigger Types

Post by fordpinto »

I am using pre-compiled binaries. Was already thinking to try compiling myself - it's much easier in Linux than any other system I think. Will try to do that as soon as I am done with a mud project I am half way thru on.

At any rate - my main takeaway from this is that while Regex performance is clearly behind, the throughput on it is still extremely high. Even on my ancient machine I do not expect to see a tangible difference until having ~100,000 triggers in use at once. That number is about a factor of 100 higher than what I would expect to ever need, even in my most ambitious dreams. At least at the moment :).

I have used this opportunity to test the MLObj package, and I have thrown it together quickly so it's not suitable for reuse atm. Looks like there is some interest for people to run their own tests, and I do not think it will be too hard to rework it without MLObj. I'll package it as an XML file with just a test alias defined in it.

A more immediate bottleneck would be that strange behavior (I could not create more than 1600 temp triggers for some reason), so the test code I will post could be used to see if it can be reproduced.

fordpinto
Posts: 34
Joined: Wed Sep 25, 2019 4:59 pm

Re: Fastest Trigger Types

Post by fordpinto »

I have cleaned up and I am attaching an alias that allows to run tests such as
trigtest regex
trigtest head
trigtest exact

I do not see the 1,600 trigger limit, so this could be something to do with the older machine I ran it on, or with the MLObj library. As configured now, the alias creates 10,000 triggers, and that works fine. I have managed to run it with 100,000 triggers, but it takes a very long time to create/delete them. It also seems to have crashed the script editor window for some reason, so it's an interesting stress test in other ways as well.

The performance on a per-trigger basis is worse in the case of 100,000 triggers (maybe by ~20%?), perhaps because caching becomes less effective.

Another interesting note, I have added feedTrigger()-s to the script in order to finalize trigger deletion, I think it's indicated in the Wiki documentation. However, the extra feedTrigger statements did not seem to initiate trigger deletion, and did not show up on screen either.
Attachments
TriggerTiming.xml
(1.55 KiB) Downloaded 447 times
Last edited by fordpinto on Wed Mar 18, 2020 4:58 pm, edited 1 time in total.

User avatar
Vadi
Posts: 5035
Joined: Sat Mar 14, 2009 3:13 pm

Re: Fastest Trigger Types

Post by Vadi »

Nice, thanks for sharing! Can you also run the test against the builds I posted to see how the original post stacks up?

fordpinto
Posts: 34
Joined: Wed Sep 25, 2019 4:59 pm

Re: Fastest Trigger Types

Post by fordpinto »

The test build posted above gives me roughly same throughput numbers as stock 4.6.1

fordpinto
Posts: 34
Joined: Wed Sep 25, 2019 4:59 pm

Re: Fastest Trigger Types

Post by fordpinto »

Just a quick note: I found out why the triggers weren't cleaned out in the test script. I mentioned this above, the triggers are "deleted" but Mudlet finalizes the deletion on the next received line rather that immediately. I added that extra line but it did not work and I did not see why. It's my own fault - I have placed the additional feedTriggers that was supposed to finalize trigger deletion *before* the tests. Just a brain fart. I have moved that statement where it's supposed to be (the .xml is reuploaded with the fix). Doesn't affect the test results, just a more neat and tidy sequence.

User avatar
SlySven
Posts: 1019
Joined: Mon Mar 04, 2013 3:40 pm
Location: Deepest Wiltshire, UK
Discord: SlySven#2703

Re: Fastest Trigger Types

Post by SlySven »

Also for regular expressions it may help to optimise them - for the raw PCRE library that involves studying them and within the Qt QRegularExpression class making use of the optimize() method...

fordpinto
Posts: 34
Joined: Wed Sep 25, 2019 4:59 pm

Re: Fastest Trigger Types

Post by fordpinto »

@SlySven

I am not familiar with Qt, but I have checked the documentation for the QRegularExpression class you mentioned. If it says what I think it says, then all regular expressions are optimized on first use (unless preemptively optimized by calling the optimize() method you also mentioned). So, all regex matches except first are optimized, and it's the performance of the optimized match that matters. The test above is run against 1000 feedTriggers() with 1 of them having extra overhead from the load required to optimize the regex. I quickly redid the test by adding an extra feedTrigger() before the timer is started to remove the optimization overhead from the statistics, and I did not notice much difference.

I think I will try running some more tests with other trigger types as well, but that's more for curiousity. From practical standpoint it seems to me Mudlet has quite a lot of firepower to spare.

Post Reply