Christian Smith wrote:
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

Chris,

Q How do programs get to be slow and bloated?
A One small inefficiency at a time.

It is just as inefficient to send dynamically created content through a series of buffers as it is to send a static file, and just as unecessary when the machine and OS has a mechanism embedded to avoid it.

If you half the overhead of a program which hits its limit at 1,000 users, you get the potential to service 2,000 or the ability to add features and still service the 1,000.
JS

Reply via email to