From owner-freebsd-performance@FreeBSD.ORG Wed Aug 13 09:59:00 2014 Return-Path: Delivered-To: performance@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 9C4D21DC; Wed, 13 Aug 2014 09:59:00 +0000 (UTC) Received: from theravensnest.org (theraven.freebsd.your.org [216.14.102.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "cloud.theravensnest.org", Issuer "StartCom Class 1 Primary Intermediate Server CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 61D1F2D5B; Wed, 13 Aug 2014 09:58:59 +0000 (UTC) Received: from [192.168.0.7] (cpc14-cmbg15-2-0-cust307.5-4.cable.virginm.net [82.26.1.52]) (authenticated bits=0) by theravensnest.org (8.14.7/8.14.7) with ESMTP id s7D9wliD006016 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Wed, 13 Aug 2014 09:58:49 GMT (envelope-from theraven@FreeBSD.org) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) Subject: Re: PostgreSQL performance on FreeBSD From: David Chisnall In-Reply-To: <201408121409.40653.jhb@freebsd.org> Date: Wed, 13 Aug 2014 10:58:42 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: References: <20140627125613.GT93733@kib.kiev.ua> <20140716132938.GB93733@kib.kiev.ua> <201408121409.40653.jhb@freebsd.org> To: John Baldwin X-Mailer: Apple Mail (2.1878.6) X-Mailman-Approved-At: Wed, 13 Aug 2014 11:33:26 +0000 Cc: Konstantin Belousov , Adrian Chadd , freebsd-current@freebsd.org, performance@freebsd.org, "current@freebsd.org" X-BeenThere: freebsd-performance@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Performance/tuning List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Aug 2014 09:59:00 -0000 On 12 Aug 2014, at 19:09, John Baldwin wrote: > OTOH, I have actually seen junk profiling _improve_ performance in = certain=20 > cases as it forces promotion of allocated pages to superpages since = all pages=20 > are dirtied. (I have a local hack that adds a new malloc option to = explicitly=20 > memset() new pages allocated via mmap() that gives the same benefit = without=20 > the junking overheadon each malloc() / free(), but it does increase = physical=20 > RAM usage.) Do you get the same effect by adding MAP_ALIGNED_SUPER | = MAP_PREFAULT_READ to the mmap() call in jemalloc? I've been meaning to = try the latter on BERI, as we spend a lot of time bouncing back and = forth between user code and the TLB miss handlers. Given that jemalloc = asks for memory in 8MB chunks (I think via a single mmap call, although = I'm not 100% certain), MAP_ALIGNED_SUPER should have little impact on = any platform. MAP_PREFAULT_READ may cause problems on machines with = limited RAM and no swap (I don't know if the VM subsystem knows that it = can safely discard a zero'd page that has been read but not written - = I'd hope so, but it's been a while since I read that code). It might be that we can make jemalloc autotune whether to use = MAP_PREFAULT_READ depending on some heuristic. I wonder if something as = simple as 'turn it on after the first mmap call' would be enough: = programs that don't use more than 8MB of RAM won't prefault, but after = that the wasted physical memory becomes an increasingly small = percentage. David