A few aspects of your code bother me. I could investigate the details, but I apologize that I'm feeling lazy. But, maybe just asking these questions would send you on the right path to discovery?

Your code is expecting to read and write entire 16K chunks, and even throws an error if it doesn't get a full 16K chunk. This goes against the normal API of sysread, though of course in this case it is virtual. Does SSL protocol or this particular implementation guarantee whole frames like this? Is 16K a magic SSL number that you can rely on, or will it sometimes give you smaller chunks? Or does it guarantee that you receive the whole chunks of whatever the other side sent?

Packets have to be smaller than 1.5K for ethernet, so many physical receives will happen before you reach 16K, as you noticed in your subsequent post. Might your choice of 16K be the actual problem that causes lots of looping? You mention configuring the "low water mark" on the socket, but that seems wrong. Your application packets are 16K, but the underlying TCP packets could be a variety of sizes, so insisting at the OS level that it not return data until 16K is available seems likely to break things (even if it didn't this time).

Using Time::HiRes, have you tried measuring the actual overhead of an "unproductive" sysread on IO::Socket::SSL which reads the underlying socket but delivers nothing? How does this compare to the time spent on a productive sysread? It seems to me that an unproductive sysread shouldn't take much longer than a sysread on the underlying socket. If you call ->sysread as a class method instead of a tied-IO global function, is there any performance difference?

Have you verified that the code really does wait on select()? If fileno() didn't work as expected and the select() always returned immediately, it would result in really high CPU usage with no other hints that something was wrong.


In reply to Re: IO::Socket::SSL / Net::SSLeay inefficient in non-blocking mode ? by NERDVANA
in thread IO::Socket::SSL / Net::SSLeay inefficient in non-blocking mode ? by Yaribz

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.