On Thu, Jan 8, 2009 at 1:07 PM, Manlio Perillo <span dir="ltr">&lt;<a href="mailto:manlio_perillo@libero.it">manlio_perillo@libero.it</a>&gt;</span> wrote:<br><div class="gmail_quote"><div>&nbsp;</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Another example is the multipart parser:<br>
<br>
-- | Read a multi-part message from a &#39;Handle&#39;.<br>
-- &nbsp; Fails on parse errors.<br>
hGetMultipartBody :: String -- ^ Boundary<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-&gt; Handle<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;-&gt; IO MultiPart<br>
hGetMultipartBody b h =<br>
 &nbsp; &nbsp;do<br>
 &nbsp; &nbsp;s &lt;- BS.hGetContents h<br>
 &nbsp; &nbsp;case parseMultipartBody b s of<br>
 &nbsp; &nbsp; &nbsp; &nbsp;Nothing -&gt; fail &quot;Error parsing multi-part message&quot;<br>
 &nbsp; &nbsp; &nbsp; &nbsp;Just m &nbsp;-&gt; return m<br>
</blockquote><div><br>Yes, that&#39;s definitely on the scary side of things.<br><br>However, you don&#39;t have to go all the way to drinking the Iteratee Kool-Aid in order to write safer networking code that is still performant. Here are a few projects I&#39;m actively working on in this area:<br>
<ul><li>I&#39;m adding epoll support to the threaded RTS. This is a necessity for server performance.</li><li>I&#39;ve added support for sending and receiving lazy ByteStrings to Johan Tibbell&#39;s network-bytestring library. A quick benchmark with a toy HTTP server has shown this to be about 2x faster than writing ByteStrings to a Handle (i.e. 14,000 requests per second, vs 7,000).</li>
<li>I&#39;ve got a continuation-based resumable parser combinator module for attoparsec in progress, which uses lazy ByteStrings for blazing performance. You can use this to write protocol parsers in a completely clean way, decoupled from the underlying network receive operations.<br>
</li></ul>While much of this isn&#39;t quite ready for use yet, this just represents one person&#39;s work, and there are lots of people beavering away actively at corners of the problem space that interest them.<br><br>I actually think that we&#39;re very close to being in fantastic shape here. I&#39;m working on a memcached client library that uses the above libraries, and it&#39;s faster than the absolute best C memcached client (libmemcached), while also far smaller and elegantly layered. As a community, we are developing many proofs that you can have beautiful code without sacrificing performance.<br>
</div></div>