From owner-freebsd-fs@freebsd.org Wed Aug 29 21:22:13 2018 Return-Path: Delivered-To: freebsd-fs@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 DEB131096CF9 for ; Wed, 29 Aug 2018 21:22:12 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6C17582A91 for ; Wed, 29 Aug 2018 21:22:12 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: by mail-pl1-x643.google.com with SMTP id b12-v6so2846124plr.8 for ; Wed, 29 Aug 2018 14:22:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=reTQoFlYVhrTC2Ga2IUfoy/mDBXmpfIu5DeaKjWZdnI=; b=HVYKrdJBsgt34/RtVhP7rPLSy6nNne8/9jOk6RJum4WXkNwSj9Dc6uta+8lDG8Prba XjdvWg0CKL6K0t/wEGzdto+K1M5ZoTmJVs5gMpK/DPv0CyvceIc/nFjzA3rdfzEClOH1 fCASJ+lfvToGCfwStP11R0VJWCe6EM28LQfnMxGJPQY5M2zzmDub9rj+41WxXLdw1q5L +v+9LDyYA0zZ0d95t+/21I/61HYC0NhcqEB1BFvnXLRHK1j2u9blCuDrRZ+ADO3LYM47 AArFFesLZj18hNYYGpYPX7EMAv5jl7luBW/3+aLAxhxUmvKtb4ejLt+o1lxqFusDpMfw VTRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=reTQoFlYVhrTC2Ga2IUfoy/mDBXmpfIu5DeaKjWZdnI=; b=nLxhSoccwg+RxxOrJKAyy67UJH4ShknFq/UMoDqSFCDu1/mXGyOe3RocaililrPOHT j103+XNDr/8JjW4k4api4tGyH68KSAXDvS/stsndUx3BuwVyuyN7XTPcqGaYKZ9omEHl IUwsP9Ti0wEYDA8r609geArYFvKWdocVDhgJEPTFT3FciyKH8NYCHUaknD7Z6hmk2lbf 5vr8EqD1MtvxPvhmNcUDKPn0lCaAAZ9xzSaeG7Ktrcnlf/YumkqVgC8g7MIc1Q3Zlmq0 TABKGo3LPtZx9Z0LICFqh65WVbWn63dPiJIE4Da9R2xnX7wkHaKTdUzF4GZV5ryusiXR eo8w== X-Gm-Message-State: APzg51Bbf1ZBWPasvuSXD7VXlnrX0k14hJfd8yYjOxwu77tDsAGi5GUX tpdCK44hNTIZ+zey06SC8M8= X-Google-Smtp-Source: ANB0VdbQVr8KfExd3MsDhp5unsxZwCC861y8gyt2kuHn2Qj2MBAtz2SYPFmOXVjw1OovCYrtZxcRug== X-Received: by 2002:a17:902:b688:: with SMTP id c8-v6mr7488879pls.114.1535577731425; Wed, 29 Aug 2018 14:22:11 -0700 (PDT) Received: from raichu (toroon0560w-lp130-09-70-52-224-239.dsl.bell.ca. [70.52.224.239]) by smtp.gmail.com with ESMTPSA id v19-v6sm8481426pgn.94.2018.08.29.14.22.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Aug 2018 14:22:10 -0700 (PDT) Sender: Mark Johnston Date: Wed, 29 Aug 2018 17:22:07 -0400 From: Mark Johnston To: Paul Cc: freebsd-fs@freebsd.org, developer@open-zfs.org Subject: Re: Potential bug recently introduced in arc_adjust() that leads to unintended pressure on MFU eventually leading to dramatic reduction in its size Message-ID: <20180829212207.GF2709@raichu> References: <1535534257.46692673.obgqw5dr@frv33.fwdcdn.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1535534257.46692673.obgqw5dr@frv33.fwdcdn.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Aug 2018 21:22:13 -0000 On Wed, Aug 29, 2018 at 12:42:33PM +0300, Paul wrote: > Hello team, > > > It seems like a commit on Mar 23 introduced a bug: if during execution of arc_adjust() > target is reached after MRU is evicted current code continues evicting MFU. Before said > commit, on the step prior to MFU eviction, target value was recalculated as: > > target = arc_size - arc_c; > > arc_size here is a global variable that was being updated accordingly, during MRU eviction, > hence this expression, resulted in zero or negative target if MRU eviction was enough > to reach the original goal. > > Modern version uses cached value of arc_size, called asize: > > target = asize - arc_c; > > Because asize stays constant during execution of whole body of arc_adjust() it means that > above expression will always be evaluated to value > 0, causing MFU to be evicted every > time, even if MRU eviction has reached the goal already. Because of the difference in > nature of MFU and MRU, globally it leads to eventual reduction of amount of MFU in ARC > to dramatic numbers. Hi Paul, Your analysis does seem right to me. I cc'ed the openzfs mailing list so that an actual ZFS expert can chime in; it looks like this behaviour is consistent between FreeBSD, illumos and ZoL. Have you already tried the obvious "fix" of subtracting total_evicted from the MFU target? > Servers that run the version of FreeBSD prior to the issue have this picture of ARC: > > ARC: 369G Total, 245G MFU, 97G MRU, 36M Anon, 3599M Header, 24G Other > > As you can see, MFU dominates. This is a nature of our workload: we have a considerably > small dataset that we use constantly and repeatedly; and a large dataset that we use > rarely. > > But on the modern version of FreeBSD picture is dramatically different: > > ARC: 360G Total, 50G MFU, 272G MRU, 211M Anon, 7108M Header, 30G Other > > This leads to a much heavier burden on the disk sub-system. > > > Commit that introduced a bug: > https://github.com/freebsd/freebsd/commit/555f9563c9dc217341d4bb5129f5d233cf1f92b8