From owner-freebsd-questions@freebsd.org Wed Feb 7 15:18:25 2018 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4A9E8F0D8B9 for ; Wed, 7 Feb 2018 15:18:25 +0000 (UTC) (envelope-from frank2@fjl.co.uk) Received: from bs1.fjl.org.uk (bs1.fjl.org.uk [84.45.41.196]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "bs1.fjl.org.uk", Issuer "bs1.fjl.org.uk" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id D5D806DCDE for ; Wed, 7 Feb 2018 15:18:24 +0000 (UTC) (envelope-from frank2@fjl.co.uk) Received: from roundcube.fjl.org.uk (localhost [127.0.0.1]) by bs1.fjl.org.uk (8.14.4/8.14.4) with ESMTP id w17FIFuH011908 for ; Wed, 7 Feb 2018 15:18:15 GMT (envelope-from frank2@fjl.co.uk) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 07 Feb 2018 15:18:15 +0000 From: Frank Leonhardt To: freebsd-questions@freebsd.org Subject: Re: Swap on SSD Organization: FJL Microsystems In-Reply-To: References: Message-ID: X-Sender: frank2@fjl.co.uk User-Agent: Roundcube Webmail/0.9.2 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Feb 2018 15:18:25 -0000 On 2018-02-05 20:08, John R. Levine wrote: > In article <24BAEBB4-FAA7-47C8-A6FC-32839063666F@kreme.com>, LuKreme > wrote: >> On Feb 5, 2018, at 09:13, Frank Leonhardt wrote: >>> FreeBSD doesn't actually swap these days; uses demand paging. This >>> means that blocks of RAM that are hardly ever used can get >> copied to disk. This may include some stuff that's only accessed a few >> times a year, but would otherwise be occupying precious >> RAM that would be much more useful as a disk cache. That said, FreeBSD >> tends not to page out except as a last resort - probably a >> mistake but I can't prove it. > > On one of my BSD cloud virtual machines I have a server process that > slurps in about a gigabyte of stuff into a very large perl table, then > sits there and answers queries from that table. The system swaps like > crazy for a few seconds while it's loading up the table, then quiets > down and reads a few pages a second from the swap as the queries come > in. That's about the worst case, and only becasue I'm a cheapskate and > don't want to pay for a larger VM where everything would fit in RAM. On a VM you have no idea whether anything is on disk or in RAM - chances are in this case your swap partition is in the hypervisor's disk cache. --------------- There seems to be some confusion on this list about swapping and paging. Swapping is old hat. Basically when doing a context swap you wrote a non-running process to a swap area to free up RAM space. We don't do that anymore - we use demand paged virtual memory. All processes potentially remain resident, but some of their memory map may be paged out to disk to free up RAM. If the process tries to access such a page the MMU interrupts the kernel, which loads in the missing page and uses the MMU to put it back in the process space at the right location before returning control. I'm not being pedantic here - the difference between swapped and paged systems is very significant if you're optimising disk/RAM usage. Swap areas have been replaced by page areas on disk, but the name stuck. A bit like core store - I haven't used core store since the 1980's but we still have "core dumps". Youngsters in the office look at me oddly when I use terms like core and DASD...