On Wed, 19 Apr 2006, John Stanton wrote: >Chris, Thanks for the very pertinent comments on segment linking. > >I am not sending an Sqlite database. It is the output from my program, >principally assembled HTML/PDF/PostScript and similar. > >I want to avoid buffer shadowing on the content my program creates. If >I use a malloc'd buffer it gets copied several times before arriving at >the network interface. If I use the zero copy mechanism with a sendfile >or TransmitFile on an open file descriptor/handle in conjunction with a >modern network adapter then the transfer is optimal.
Compared to the general work in generating the buffer, is the time to send it to the socket actually significant? Compared to the throughput of your network, is the bandwidth of a memory->memory copy going to be a bottleneck? sendfile is an optimisation for web servers to serve static content. The benefits of server dynamic content would be suspect at best. I can't find any pages recommending it's usage for dynamic content. > >It has always been my experience that if you get the underlying >mechanisms used by your application to be optimal, then you have no >scaling problems and no walls to hit in the future. As an analogy, you could hand code the most efficient data swapping algorithm possible, but it won't make a bubble sort more efficient. Get the solution working simply, then profile before putting in a hack like this, especially if run on a platform where sendfile is not available or implemented using read()/write(). Of course, I'd be interested in whether using sendfile() for dynamic content is indeed useful in increasing performance. > >JS > Christian -- /"\ \ / ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL X - AGAINST MS ATTACHMENTS / \