On Thu, Dec 20, 2012 at 04:26:48AM -0500, Jean-Philippe Ouellet wrote:
> On 12/20/12 4:20 AM, Otto Moerbeek wrote:
> > On Thu, Dec 20, 2012 at 04:06:52AM -0500, Jean-Philippe Ouellet wrote:
> > 
> >> On 12/20/12 3:53 AM, Jean-Philippe Ouellet wrote:
> >>> and madvise() them to not be swapped out?
> >>
> >> Oops, I think I might have misinterpreted the meaning of MADV_WILLNEED.
> >> I think I meant mlock().
> > 
> > Why trying to be smarter than the kernel? Mlocking pages will kill you
> > if there's memory shortage.
> > 
> > The kernel will try to keep much used pages in mem anyway.
> > 
> >     -Otto
> > 
> 
> Okay, yeah. That's a terrible idea. But still, the question of direct
> file-to-socket sending vs. keeping copies in my address space and
> write()ing those to the socket still remains.

The file will be in the buffer cache. While it still takes a few
in-memory copies (which is what sendfile saves you), this should be fast
enough for most cases.

If you keep the data in your address space, you save one m-to-m copy,
but ignore all the benefits that the bc has compared to you (namely
knowing how much free memory really is available at runtime, not forcing
buffers into swap and more). You will probably end up shooting yourself
in the leg for a speed gain that probably can't be realized because the
network is the real bottleneck

Taking memory away from the kernel to duplicate functionality in
user-space is almost never a good idea.

> 
> Normally I would just write both and profile them, but I can't figure
> out how to do the first on OpenBSD.

Reply via email to