Re: [dev] stderr: unnecessary?

From: Kris Maglione <>
Date: Sat, 12 Jun 2010 07:06:37 -0400

On Sat, Jun 12, 2010 at 12:53:27PM +0200, pancake wrote:
> On Jun 12, 2010, at 9:27 AM, Connor Lane Smith <> wrote:
>> On 12 June 2010 08:00, Kris Maglione <> wrote:
>> Except it can actually fetch as much data as is addressable in memory
>> in a single call, if the kernel and library are tailored to.
> That's why mmap is for. Using read is just stupid.

mmap is silly. If you want that much data mapped, it's because
you want fast access to it. If you just want random access to
it, you read it as you need it. mmap doesn't offer any
performance advantage. When you touch a page that wasn't already
there, the kernel has to fault it in, which is already as
expensive as the read system call, and even more so because of
the coarse granularity. It needs to read in an entire page, even
if all you need is a byte. And if you need a dword across a
page boundary, you get two faults and two pages read in. There's
really just no point.

The only real advantage of mmap is if you're passing mmapped
addresses to kernel space without touching them in user space,
in which case the kernel can map them without having to fault
them in first. But even then it's tenuous.

Kris Maglione
When a religion is good, I conceive it will support itself; and when
it does not support itself, and God does not take care to support it
so that its professors are obliged to call for help of the civil
power, 'tis a sign, I apprehend, of its being a bad one.
	--Benjamin Franklin
Received on Sat Jun 12 2010 - 11:06:37 UTC

This archive was generated by hypermail 2.2.0 : Sat Jun 12 2010 - 11:12:02 UTC