NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Linux compat and swap



At Fri, 24 Apr 2020 12:23:14 +1000, Paul Ripke <stix%stix.id.au@localhost> wrote:
Subject: Re: Linux compat and swap
>
> To the best of my knowledge, vm.execmax just defines the maximum amount
> of memory for mapped executable pages, and won't cause processes to be
> killed. Since mapped executable pages are generally read-only, they can
> just be dropped from RAM and paged in again from the executables as
> needed.

Well I think more accurately the vm.*max values are better described as
the maximum percentage of pages that the VM system will attempt to
reclaim from other uses for the named use.  I.e. if you want to start a
fairly big and long-running program (i.e. one that has a lot of text
pages in terms of percent of the whole system's capacity, and which uses
many of its text pages frequently) then you want the system to be able
to push out other pages (e.g. especially file cache pages) and keep them
for the busy executable text pages while the program runs, so you want
to set vm.execmax large enough to accommodate the full compliment of
necessary text pages for that big program (or a set of simultaneously
running but different programs).

If executable pages are pushed out (i.e. down to vm.execmin) due to
other memory pressure (e.g. your running programs start to do a lot of
filesystem I/O or they allocate a lot of heap and start using it while
at the same time allowing the majority of their active text pages to go
idle), then the idle text pages are indeed simply dropped (down to
vm.execmin) to make room for the other uses; then, as you say, they will
be simply paged in from the program files on disk as needed again.
However page faults on exec pages are is still very expensive for a
running program, especially if it is CPU bound.

Depending on where your real-world workload's memory pressure is, it may
make sense to have vm.execmin relatively high to accommodate really
large programs or very large numbers of _different_ programs
simultaneously (many instances of the same program all share the same
text pages), but for many use cases, especially on larger-memory
systems, the number of average executable pages in use will be quite a
small percentage of total pages.  I rarely see my systems go above 1-2%
exec pages (even on my systems where every program is static-linked),
but I still keep vm.execmax fairly high as these are, along with
anonymous pages, far more important than file cache pages for many kinds
of running programs to actually be able to make progress without hitting
page faults during pure computation.

On the other hand the vm.*max percentages are just limits to how many
pages will be reclaimed from other uses when a given category faces
pressure from extensive and immediate use -- they do not set the maximum
use for a given category.  On my rsync backup host I normally see 85% of
pages allocated to file cache even though vm.filemax is just 50.

One should keep an eye on the percentages shown by a "systat vm" running
in another window during normal workloads to see how memory is being
used.

--
					Greg A. Woods <gwoods%acm.org@localhost>

Kelowna, BC     +1 250 762-7675           RoboHack <woods%robohack.ca@localhost>
Planix, Inc. <woods%planix.com@localhost>     Avoncote Farms <woods%avoncote.ca@localhost>

Attachment: pgpcn3mtKzqec.pgp
Description: OpenPGP Digital Signature



Home | Main Index | Thread Index | Old Index