<br><br><div class="gmail_quote">2009/2/20 Benny Amorsen <span dir="ltr"><<a href="mailto:benny%2Busenet@amorsen.dk">benny+usenet@amorsen.dk</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="Ih2E3d">Ian FREISLICH <<a href="mailto:ianf@clue.co.za">ianf@clue.co.za</a>> writes:<br>
<br>
> 80kpps is not that much. I have machines capable of handling just<br>
> shy of 1Mpps on 1 physical interface, the main problem is the<br>
> physical medium. My measured max rate on 100M ethernet is 148kpps<br>
> using UDP with a payload of 1 byte. You should be able to get that<br>
> packet rate in on gigE with a real-world payload.<br>
<br>
</div>The challenge is that the 80kpps have to go all the way to user space<br>
and back out to a different ethernet interface. The packets are spread<br>
across 1600 streams, making for lousy cache behaviour when threaded,<br>
and timing is worst-case (each stream gets a packet every 20ms).<br></blockquote></div><br><div><span class="Apple-style-span" style="color: rgb(136, 136, 136);"><br></span></div><div><span class="Apple-style-span" style="color: rgb(136, 136, 136);">So that suggests an optimisation in the path from kernel to user space and back again - which is some sort of super-recvfrom which can collect ALL the received data across all the RTP sockets in one big read. The kernel can queue all the data into a buffer as it arrives and that data can all be passed to Asterisk in one go.</span></div>
<div><span class="Apple-style-span" style="color: rgb(136, 136, 136);"><br></span></div><div><span class="Apple-style-span" style="color: rgb(136, 136, 136);">Perhaps on the Asterisk side a pool of RTP-router-threads can each use a system call like this to read data from a few hundred sockets, then process all those received RTP packets into corresponding output buffer which then passed back to the kernel via super-send.</span></div>
<div><span class="Apple-style-span" style="color: rgb(136, 136, 136);"><br></span></div><div><span class="Apple-style-span" style="color: rgb(136, 136, 136);">Add in any necessary processing for dsp etc and Bob's your uncle.</span></div>
<div><br></div><div><span class="Apple-style-span" style="color: rgb(136, 136, 136);">You'd use a pool of threads so that you had at least one RTP-router-thread for each CPU.</span></div><div><span class="Apple-style-span" style="color: rgb(136, 136, 136);"><br>
</span></div><div><span class="Apple-style-span" style="color: rgb(136, 136, 136);">You'd end up essentially doing 50 system calls per sec per CPU to get all the data from the kernel into Asterisk and 50 to write the outgoing data.</span></div>
<div><span class="Apple-style-span" style="color: rgb(136, 136, 136);"><br></span></div><div><span class="Apple-style-span" style="color: rgb(136, 136, 136);">Obviously there is lots of hand-waving here, and I've probably reinvented something that is already available in the kernel - in which case someone please enlighten me.</span></div>
<div><span class="Apple-style-span" style="color: rgb(136, 136, 136);"><br></span></div><div><span class="Apple-style-span" style="color: rgb(136, 136, 136);">For IAX it all arrives on one socket anyway - so its just a matter of being able to get it all out of the kernel in one big read.</span></div>
<div><span class="Apple-style-span" style="color: rgb(136, 136, 136);"><br></span></div><div><span class="Apple-style-span" style="color: rgb(136, 136, 136);">We're still going to and from userspace all the time, as opposed to efforts to do the whole job in the kernel, but I'm sure there is performance to be gained here, without losing the flexibility that Asterisk's multi-protocol architecture brings.</span></div>
<div><span class="Apple-style-span" style="color: rgb(136, 136, 136);"><br></span></div><div><span class="Apple-style-span" style="color: rgb(136, 136, 136); ">And /me waves at Ian.</span><br></div><div><span class="Apple-style-span" style="color: rgb(136, 136, 136);"><br>
</span></div><div><span class="Apple-style-span" style="color: rgb(136, 136, 136);">Regards,</span></div><div><span class="Apple-style-span" style="color: rgb(136, 136, 136);">Steve Davies</span></div><div><span class="Apple-style-span" style="color: rgb(136, 136, 136);"><br>
</span></div>