From owner-freebsd-questions@freebsd.org Sat May 12 16:46:15 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 98CFFFB4CF0 for ; Sat, 12 May 2018 16:46:15 +0000 (UTC) (envelope-from johnl@iecc.com) Received: from gal.iecc.com (gal.iecc.com [IPv6:2001:470:1f07:1126:0:43:6f73:7461]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "gal.iecc.com", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 19AC574AB2 for ; Sat, 12 May 2018 16:46:15 +0000 (UTC) (envelope-from johnl@iecc.com) Received: (qmail 57878 invoked from network); 12 May 2018 16:46:14 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple; d=iecc.com; h=date:message-id:from:to:cc:subject:in-reply-to:mime-version:content-type:content-transfer-encoding; s=e214.5af71a56.k1805; bh=XSEHseeLw/WB/bln3RlLfCRPUKSMqzOuHTkGgDbIcYs=; b=m45LKUNPlzWqPoxBvKN6v21IFm3Z+U5y01xMNuKU8IswllhKeocy4F9qitRxJSV+n+tNxenxwCP/l02Sb6KQrhxzvjK12/zxwY+bzLm0uQQjTvcySNu7biE3AgxBO5jeU/QWZFNcZ3cfVVhaYSISYsSX62sU0FSoyzJpKTszEER/58l/WqJjA7JIvrjih1B8hM6KPRT9B2xc6jUjxfgb6moeJqcmJXJybSA7wok5KyHTRKq5jLosyFkscnnkf7m4 Received: from ary.qy ([IPv6:2001:470:1f07:1126::78:696d:6170]) by imap.iecc.com ([IPv6:2001:470:1f07:1126::78:696d:6170]) with ESMTP via TCP6; 12 May 2018 16:46:13 -0000 Received: by ary.qy (Postfix, from userid 501) id AD3372675650; Sat, 12 May 2018 12:46:13 -0400 (EDT) Date: 12 May 2018 12:46:13 -0400 Message-Id: <20180512164613.AD3372675650@ary.qy> From: "John Levine" To: freebsd-questions@freebsd.org Cc: gobble.wa@gmail.com Subject: Re: swapfile question In-Reply-To: Organization: Taughannock Networks X-Headerized: yes Mime-Version: 1.0 Content-type: text/plain; charset=utf-8 Content-transfer-encoding: 8bit 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: Sat, 12 May 2018 16:46:15 -0000 In article you write: >On Sat, May 12, 2018 at 6:51 AM, tech-lists wrote: >> Hi, >> >> In a SSD/amd64/ufs2/freebsd-11 context, which is faster: >> >> 1. swap as a partition on the ssd >> 2. swap as a file on the ssd >> >> If one is faster than the other, why? To what extent? A partition is faster since using a swap file requires looking up block numbers using inodes and indirect blocks. In the worst case the difference could be 2:1, a block number lookup for every page, typically not that bad but it's always slower. I agree that in general it's better to set up your system so it doesn't need to swap but you always want enough swap to avoid strange program failures when malloc() calls fail. (They're supposed to recover but I can assure you, they often don't.) I have an application that answers network queries from a mysql database. The database is largish, several hundred megabytes, but only changes a few times a day. I rewrote my application so it slurps the whole database into a perl table and answers queries from that. The perl table is bigger than the VM's physical memory so it's mostly swapped out, but using the VM system for disk I/O is faster in this application than calling out to mysql. -- Regards, John Levine, johnl@iecc.com, Primary Perpetrator of "The Internet for Dummies", Please consider the environment before reading this e-mail. https://jl.ly