From owner-freebsd-current@FreeBSD.ORG Wed Aug 13 16:23:45 2014 Return-Path: Delivered-To: freebsd-current@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 404B84E2; Wed, 13 Aug 2014 16:23:45 +0000 (UTC) Received: from mail-ig0-x22a.google.com (mail-ig0-x22a.google.com [IPv6:2607:f8b0:4001:c05::22a]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id D095D2CE7; Wed, 13 Aug 2014 16:23:44 +0000 (UTC) Received: by mail-ig0-f170.google.com with SMTP id h3so11740309igd.1 for ; Wed, 13 Aug 2014 09:23:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:reply-to:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=/LHRks6tSEzobWSKZkHFWORM4xAAJreA0l3Sw73vwxM=; b=t/cahxnlf03Hdk0gjdKYSvU75CBvUYRubYmSDSbZ0G27O3yzt1PvFuYpOL/a+aRjsf ztNttTTnDvXsCUafYKrkLFrvj1ZJgbPgpLG7FHqab/O/UMhuGFM9/wUu1D5WRNJvetSO v4f4+74pbJoQGtemvlshefx4O2YZzl3Y0VY0ULVY/IsRa4nDug0NTTWrHBy8wD/iaMUc e7eoQE4QcTYvef3FGl02Q3/cT/1u2AvTRZdNQtns7M7Jt3pDdoUxWEErv5nY2P85A4De JhjT3coeOCg4h2WVOIs4RrJ8r2m4XJMEOLI0bEaACznD13GfgKmGGfIqhxAY8HFPxpJW lwzQ== MIME-Version: 1.0 X-Received: by 10.50.66.197 with SMTP id h5mr51099519igt.34.1407947024349; Wed, 13 Aug 2014 09:23:44 -0700 (PDT) Received: by 10.43.17.196 with HTTP; Wed, 13 Aug 2014 09:23:44 -0700 (PDT) Reply-To: alc@freebsd.org In-Reply-To: References: <20140627125613.GT93733@kib.kiev.ua> <20140716132938.GB93733@kib.kiev.ua> <201408121409.40653.jhb@freebsd.org> Date: Wed, 13 Aug 2014 11:23:44 -0500 Message-ID: Subject: Re: PostgreSQL performance on FreeBSD From: Alan Cox To: David Chisnall Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.18-1 Cc: Adrian Chadd , performance@freebsd.org, "current@freebsd.org" , freebsd-current , Konstantin Belousov X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Aug 2014 16:23:45 -0000 On Wed, Aug 13, 2014 at 4:58 AM, David Chisnall wrote: > On 12 Aug 2014, at 19:09, John Baldwin wrote: > > > OTOH, I have actually seen junk profiling _improve_ performance in > certain > > cases as it forces promotion of allocated pages to superpages since all > pages > > are dirtied. (I have a local hack that adds a new malloc option to > explicitly > > memset() new pages allocated via mmap() that gives the same benefit > without > > the junking overheadon each malloc() / free(), but it does increase > physical > > RAM usage.) > > Do you get the same effect by adding MAP_ALIGNED_SUPER | MAP_PREFAULT_READ > to the mmap() call in jemalloc? No. MAP_PREFAULT_READ does not allocate physical pages. It establishes mappings to pages that are already allocated. > 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 > > _______________________________________________ > freebsd-current@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-current > To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org" >