🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nntp
Article #21674

Re: NNRPD resource consumption

#21674
From: Stephen R. van den Berg
Date: Thu, 18 Sep 1997 00:00
39 lines
2399 bytes

Rahul Dhesi <c.c.eiftj@16.usenet.us.com> wrote:
>In <5vmdsa$4pt$1@news0.xs4all.nl> johnpc@xs4all.nl (Jan-Pieter Cornet) writes:
>>My patches, instead, simple mmap the file and then perform a binary
>>search on the overview file to search the correct record.

>Note that a binary search can be done with seeks, without doing mmap.
>This might save you some memory.

Why is it that people always seem to think that doing it with seeks
instead of mmapping, will save memory?

When you lseek() to a spot, then read(), the kernel will read in that page
into a buffer in memory, then copy the results to userspace.
When you lseek() to the next spot, and read(), the kernel will read that
page into a *new* and most likely different buffer in memory (so as not
to thrash the buffer-cache), then copy it to userspace.
The buffers are marked as unmodified and will be discarded as soon as the
kernel thinks it needs more/new bufferspace.

When mmap()ping, the kernel copies the page that is being accessed
into buffer-space and maps that buffer directly into the process.
The buffers are marked as unmodified and will be discarded as soon as the
kernel thinks it needs more/new bufferspace.

In both cases the kernel buffers the data in memory, in the non-mmapped case,
there is an extra copy involved.  The amount of real memory used is the same
in both cases, since only those pages will be populated that are actually
being used.

What am I missing?
-- 
Sincerely,                                                          srb@cuci.nl
           Stephen R. van den Berg (AKA BuGless).
"Real Life?  I've played that game.  The plot stinks but the
 graphics are awesome."

Technical Details
Message-ID: <5vpp1b$38j$1@zeus.fw.cuci.nl>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail
References: <5unqlf$jfa@shell.monmouth.com> <5v12u9$qhd$1@earth.execpc.com> <5vmdsa$4pt$1@news0.xs4all.nl> <5vmmhr$8m5$1@samba.rahul.net>

Show Full Headers
Complete Article Headers
Message-ID: <5vpp1b$38j$1@zeus.fw.cuci.nl>
Subject: Re: NNRPD resource consumption
Date: Thu, 18 Sep 1997 00:00:00 +0000
From: srb@zeus.fw.cuci.nl (Stephen R. van den Berg)
References: <5unqlf$jfa@shell.monmouth.com> <5v12u9$qhd$1@earth.execpc.com> <5vmdsa$4pt$1@news0.xs4all.nl> <5vmmhr$8m5$1@samba.rahul.net>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.mbox.zip!not-for-mail
X-Deja-AN: 273450007
X-Trace: heracles.fw.cuci.nl 874538857 16618 (None) 10.0.0.3
Organization: Cubic Circle
Newsgroups: news.software.nntp