powerman has asked for the wisdom of the Perl Monks concerning the following question:
I need something faster. Any ideas?sub FD_used { local *FD; opendir FD, "/proc/self/fd"; return @{[readdir FD]} - 2; };
Background: this script is a very quick "spider", which use non-blocking sockets to reach speed > 200 urls per second. So i open many simultaneous connections. Some of them is UDP sockets to DNS server, other is TCP sockets to HTTP servers. And more connections mean more urls per second. So, now I open ~ 200 sockets in a second. And I need to test how many sockets opened before trying to open new socket. But 200 calls of my FD_used() take too many time (0.05 sec on Celeron 333) and slow other code! Errr!!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: resource control: FD
by derby (Abbot) on Apr 24, 2002 at 17:01 UTC | |
|
Re: resource control: FD
by ferrency (Deacon) on Apr 24, 2002 at 16:49 UTC | |
|
Re: resource control: FD
by belg4mit (Prior) on Apr 24, 2002 at 20:04 UTC | |
|
Re: resource control: FD
by Fletch (Bishop) on Apr 24, 2002 at 16:57 UTC | |
| |
|
Re: resource control: FD
by perlplexer (Hermit) on Apr 24, 2002 at 16:34 UTC | |
by powerman (Friar) on Apr 24, 2002 at 18:40 UTC | |
by derby (Abbot) on Apr 24, 2002 at 20:24 UTC | |
|
SOLUTION
by powerman (Friar) on Apr 24, 2002 at 21:13 UTC | |
|
Re: resource control: FD
by powerman (Friar) on Apr 24, 2002 at 16:18 UTC |