At the risk of this turning into another argument between us...

On Thu, 20 Apr 2006, John Stanton wrote:

>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.



Assuming you spend x% of your time in function Y, then halving the
overhead of function Y will yield x/2% of run time. The lower x is, the
lower the savings.

Some overhead is just too small to be worth worrying about.

In your case, remember that you'll also have to create the file before use
(synchronous IO) and resize it to the correct size before sending it down
the pipe (sendfile sends the whole file) which will involve more
synchronous IO. You'll also have to re-mmap your file each time you
truncate it and re-write it, as mmap mappings are undefined for truncated
files etc. Invalidating mappings could also result in cross CPU interrupts
to flush TLB entries in SMP machines, which affects not only your process
but also processes on the CPU that got interrupted.

If the cross CPU interrupts haven't put you off yet, then the required
synchronous IO sure as hell should have.

Now, if you dynamic content is likely to be reused, then that is a
different matter. Write to a file as a cache entry, and sendfile the cache
entry. That I can see working.


>JS
>


Christian

-- 
    /"\
    \ /    ASCII RIBBON CAMPAIGN - AGAINST HTML MAIL
     X                           - AGAINST MS ATTACHMENTS
    / \

Reply via email to