This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

[bind] efficiency, multiple binds or * pubm/msgm?

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
incith
Master
Posts: 275
Joined: Sat Apr 23, 2005 2:16 am
Location: Canada

[bind] efficiency, multiple binds or * pubm/msgm?

Post by incith »

Hello all,

A bit of a debate (you make life difficult mezzanine! But I can't help but <3 you) has raised over how I do the binds in my horoscope script, using a mass [foreach] to bind all the signs to pub and msg binds. This, obviously, creates a very large [binds] list.

The alternative is using a * pubm/msgm and checking each line of text against every bind (I foresee another foreach and regexp/string matching), on every single line of text that is said. This is basically what eggdrop does anyway, no? Checking each line against it's binds list.

So I'm wondering what do you think would yield better performance, using individual binds and letting eggdrop do the work, or using pubm and checking the binds on the script level? Consider large/small channels etc, or bots on many channels.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Interesting subject. Lets try to analyze this theoretically (this is only my assumption and is not necessarily true); When using a pub bind, Eggdrop does actually do the matching but I suppose it's faster than matching using Tcl in a pubm procedure. However, a huge [binds] list means more memory usage but that shouldn't be an issue if we're just talking about what? 50 binds maximum? so, in my opinion, even in a large channel with much traffic... using pub would be better in terms of performance than pubm... but that should be put for testing of course.
User avatar
incith
Master
Posts: 275
Joined: Sat Apr 23, 2005 2:16 am
Location: Canada

Post by incith »

That is how I'm looking at it too.

Basically the main example would be my horoscope script, and in 3.0 you can set multiple commands chars, and with the option to bind signs (sorry not bragging here >_>), this adds up to 50ish binds or so (with 2 commands chars).
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

so we're talking 50 to 100 binds? how much memory does that take up? not more than 2 or 3KB if I'm not mistaken so that's not at all to be considered as a load.
User avatar
incith
Master
Posts: 275
Joined: Sat Apr 23, 2005 2:16 am
Location: Canada

Post by incith »

Well, 50 with 2 command chars (most people will use 1). Let's just say anyway that your eggdrop had 100 binds active.

If eggdrop is doing it, I picture eggdrop running a big foreach {} kind of thing against all the binds it has stored. If you start using pubm and binding to *, then you start having nested foreach {}'s, while eggdrop loops through its bind list, and then a foreach in your script to check the binds, and then back into the eggdrop loop, etc. I can't help but think it would be most optimized by having eggdrop do as much of the work as possible.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Actually, all eggdrop does is iterate through a linked list of structs. The speed of this cannot be matched by any construction in tcl involving any kind of loops.

As for the memory consumption, the footprint of the structs would not be considderably larger than the footprint of the proc that would do the "msgm/pubm version".

Personally, the only "issue" I could possibly see with using multiple msg/pub bindings, is that they do not stack, whereas msgm/pubm does. Unless you think seeing 50-100 extra lines when using the .binds command is an issue ;)
NML_375
Post Reply