I seams that the time is taken by checkintg to see if there are ready sockets...

There is no way to know from the information you are supplying. Ie. a profile; and either entirely non-representative code or no code at all; and no indication of how much cpu your application is typically using.

You say that you are doing lots of "other stuff" when no input is available, but what if there is none of that 'other stuff' to do either?

In that case, you'll check for input and find nothing and wait no time. You'll check for 'other stuff' and find nothing to do, so you'll go back and check for input again and find nothing, so you'll check for...

It's a tight loop with most of the work (polling 1000 sockets) occuring inside can_read(). So that what profiling shows you.

Again, unless you are using an abnormal amount of cpu when there is little or no socket traffic, the profiles you are posting are not necessarily indicative of a problem.

If you are using a large amount of cpu when there is little or no socket traffic, then it would probably benefit your application to insert a small sleep somewhere.

Eg. if( @ready = can_read( .01 ) ){. That would reduce the 'busy loop' effect when there is nothing to do, and so reduce your cpu usage, but it would probably increase the proportion of time spent in can_read().

But really, without more information, it's just speculation.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

In reply to Re^3: Socket IO with large (>1000) numbers of open sockets by BrowserUk
in thread Socket IO with large (>1000) numbers of open sockets by Ray Smith

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.