mIRC Home    About    Download    Register    News    Help

Print Thread
Starting many timers hangs mIRC #263894 06/10/18 10:43 PM
Joined: Sep 2018
Posts: 4
S
skiironmask Offline OP
Self-satisified door
OP Offline
Self-satisified door
S
Joined: Sep 2018
Posts: 4
When starting many timers at once (I'm trying with 80-100), mIRC hangs for 5-20 seconds while the timers are being added. I'm trying to use the timers in place of a sleep command. Here's roughly what I'm trying to do below, it creates many timers at once to delay running socketalias for 5 seconds after each run. Does anyone know if there's a better way to implement a delay without mIRC hanging?


while (%looptimeout < 500) {
timer 1 %looptimeout socketalias $read(nicklist,1) | write -dl1 nicklist
inc -zs %looptimeout 5
}

Re: Starting many timers hangs mIRC [Re: skiironmask] #263895 06/10/18 11:36 PM
Joined: Jan 2004
Posts: 1,165
maroon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,165
as written, this creates timers which would run the socketalias at 5 second intervals for the next 500 seconds, but the write command would execute 100 times immediately. If you change the pipe into $(|) it would put the /write as part of the alias.

A better way would be to have a timer do 100 repetitions at 5 sec intervals:

Code:
timer 100 5 socketalias $!read(nicklist,1) $(|) write -dl1 nicklist


using $!read makes it wait until the timer executes to evaluate the identifier, instead of using whatever is the #1 nick as the timer is created. i.e.

//timer 5 1 echo -a $asctime
vs
//timer 5 1 echo -a $!asctime

Edit: The act of launching 100 timers at the same time is not causing the delay. The /write might be causing the delay due to your AV program. Try the alias to see if your AV is causing the problem.
https://forums.mirc.com/ubbthreads.php/topics/260678/Windows_8.1_/write_very_very_v#Post260678

Last edited by maroon; 06/10/18 11:54 PM.
Re: Starting many timers hangs mIRC [Re: skiironmask] #263896 07/10/18 01:11 AM
Joined: Feb 2003
Posts: 2,620
Raccoon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,620
I'm going to estimate that you don't really need to use a file on your harddrive, given that you are deleting each line one by one, which is a pretty resource intense file operation.

Instead, consider using a custom /window -l @window that you /aline $nick to, and then /dline from.

Or. Since you are only dealing with 80 to 100 nicknames, you can easily store them to a single tokenized (space delimited) variable. In the current retail version, you can store just over 4000 bytes to a variable, and the beta lets you store just over 8000 bytes. 4000 bytes will hold 400 nicknames 9 characters in length, or over 150 nicknames 25 characters in length. Easily within the breadth of your script. Use $gettok(%nicklist,%i,32) to iterate through them. You shouldn't necessarily need to delete each nickname one at a time.


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Re: Starting many timers hangs mIRC [Re: Raccoon] #263897 07/10/18 07:01 AM
Joined: Jan 2004
Posts: 1,165
maroon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,165
I hadn't looked at it from the angle of whether the disk writes were needed, but it's definitely a good idea to avoid disk writes whenever possible, as that's always much slower than writing to a @window or a hash table.

But OP should take a look at that /speedwrite alias in the above link. There's a big difference in speed of disk writes when you tell your Antivirus to avoid monitoring disk writes to the folder where mirc.ini is located. This also affects the time it takes mIRC to write other things, such as the occasional writes to disk of mirc.ini and the variables file.

Re: Starting many timers hangs mIRC [Re: maroon] #263899 07/10/18 12:09 PM
Joined: Aug 2003
Posts: 232
P
Protopia Offline
Fjord artisan
Offline
Fjord artisan
P
Joined: Aug 2003
Posts: 232
My take on this is that the OP's approach is completely wrong, though much of the advice already given is correct.

1. You should use a single timer - and the alias you call should then issue the next timer.

2. If you need to refer to a list, you should store it in a hash table - use SLOTS = 1 if you need to preserve the sequence or SLOTS = Min(number of items,10000) if not. If you use SLOTS = 1 then you need to consider the performance of finding the n'th item (which will increase as n increases because it has to work its way down the linked list) and instead delete the first item in each iteration so that you are always referencing the first item.

Re: Starting many timers hangs mIRC [Re: Protopia] #263905 07/10/18 06:21 PM
Joined: Sep 2018
Posts: 4
S
skiironmask Offline OP
Self-satisified door
OP Offline
Self-satisified door
S
Joined: Sep 2018
Posts: 4
This advice is all very helpful, thank you all. I'm trying to implement this as a window instead, but I'm not sure how to preserve the contents of the window after closing mIRC. The list has ~10000 lines and is well over 4kb, and lines are constantly being written to the bottom and deleted from the top by mIRC.

Re: Starting many timers hangs mIRC [Re: skiironmask] #263906 07/10/18 06:48 PM
Joined: Jan 2004
Posts: 1,165
maroon Offline
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,165
check out the /filter command.

/filter -wfc @window filename.dat *
sends the entire @window to disk, and can be restored the next time with
/window -h @window | /filter -fwc filename.dat @window

If you're just needing to store the data, you'll be advised to try using hash tables, as mentioned above. https://en.wikichip.org/wiki/mirc/hash_tables
They're much faster than a @window because they don't need to waste time displaying the text too, thought that can be minimized by -h hiding your @window.