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.

informative queston about flush and fconfigure

Old posts that have not been replied to for several years.
Locked
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

informative queston about flush and fconfigure

Post by Ofloo »

hmm why is it that

"fconfigure $s -blocking 0 -buffering line" takes 97% cpu

and

"flush $s" only 0.1%
XplaiN but think of me as stupid
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

flush does about nothing when the buffer is empty. fconfigure will change alot of internal values no matter what.
how did you measure this percentage? it doesn't make sense...commands don't take a percentage of cpu, the interpreter does. try "time" instead and don't try to compare commands that do entirely different things. :wink:
Have you ever read "The Manual"?
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

well i made socket based service written in tcl (link with hybrid)

and when i change the fconfigures into flushes then its that result ..

ive been using it for a while but i am rewriting it
so first time i wrot it with flush.. second "now" rewrote it and used fconfigure

i couldn't figur out why the cpu had increased so mutch first i tought that it was the while loop but then it suddenly hit me .. that it must be the fconfigur so i started testing and indeed fconfigure used 97% to 100% cpu while flush only used 0 to 0.1 cpu

i used top in linux opend 2 shells ran script with fconfigure then with flush difference well i am not going for exact notations if u know what i mean difference between 100 and 0 is enough for me ;) in the asumtion that the cmd top works properly of course but from what i can say its pretty accurant..
XplaiN but think of me as stupid
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

you don't need to handle non-blocking sockets through TCL's built-in functions... eggdrop's [connect] and [control] procedures do exactly that for you, in more convenient manner

as example, see ircd.tcl: a hybrid-compatible ircd emulator
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

if you read closer u know i am not using a eggdrop but a shell script, also i am not asking how control and connect work i know that i know how to create socket bots and so on .. i just was asking how this is cause it is weird to me while it should use so mutch cpu :P
XplaiN but think of me as stupid
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

it's not [fconfigure] that's f*cked up

your stand-alone TCL app eats the whole CPU time most likely because you never gave it a chance to enter TCL's event processing loop (which you don't have to do if you run it as eggdrop script, because the eggdrop does that for you)

you need to use [vwait]
Last edited by demond on Sun Oct 24, 2004 3:19 pm, edited 1 time in total.
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

dude i don't use async sockets .. and i don't know but 3 days of waiting should be plenty of time for it to go into any mode..

but i could be wrong so .. maybe give me a sample its not a async socket its an active normal tcp socket .. it isn't supposed to wait for anything..

also i don't wana run an eggdrop this is meanth to be a server not a client i use eggdrops for channel maintaining what they where meanth for .. not as a network service.
XplaiN but think of me as stupid
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

dude, [vwait] has nothing to do with async sockets, and it's the exact solution of your problem - which you can easily find out yourself, if you bother to RTFM and do a simple google search for "tcl non-blocking"
Locked