From owner-freebsd-fs@freebsd.org Wed Aug 29 09:42:43 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 3449F1083945 for ; Wed, 29 Aug 2018 09:42:43 +0000 (UTC) (envelope-from devgs@ukr.net) Received: from frv196.fwdcdn.com (frv196.fwdcdn.com [212.42.77.196]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.ukr.net", Issuer "Thawte RSA CA 2018" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id CAD8584B13 for ; Wed, 29 Aug 2018 09:42:42 +0000 (UTC) (envelope-from devgs@ukr.net) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=ukr.net; s=ffe; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-Id:To: Subject:From:Date:Sender:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=gQ0cCpy08VB5wPPYQ2OY1l3mbA+TFF2efbb4lCoQqq0=; b=J7yLZpmss2iHOM9Ct0HWbIVkra rVSpcGRELBeycnQTriaGOoUPeh51Ej+zOs6KjEgQTDYOP1zz4snBfRmFHMUu0qbzraiIxZXcAWqTB alD1FUHRfqroSXWuIWeDMHHkahUyuYhtnYqUFFFw0T23IaujD8iV4PZBjKbr1WbIVaWY=; Received: from [10.10.10.33] (helo=frv33.fwdcdn.com) by frv196.fwdcdn.com with smtp ID 1fuwzh-000I4O-Mi for freebsd-fs@freebsd.org; Wed, 29 Aug 2018 12:42:33 +0300 Date: Wed, 29 Aug 2018 12:42:33 +0300 From: Paul Subject: Potential bug recently introduced in arc_adjust() that leads to unintended pressure on MFU eventually leading to dramatic reduction in its size To: freebsd-fs@freebsd.org X-Mailer: mail.ukr.net 5.0 Message-Id: <1535534257.46692673.obgqw5dr@frv33.fwdcdn.com> Received: from devgs@ukr.net by frv33.fwdcdn.com; Wed, 29 Aug 2018 12:42:33 +0300 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: binary 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 09:42:43 -0000 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. 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 Best regards, Paul