From owner-freebsd-fs@freebsd.org Wed Dec 28 09:30:25 2016 Return-Path: Delivered-To: freebsd-fs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0AD1EC94C58; Wed, 28 Dec 2016 09:30:25 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from citapm.icyb.net.ua (citapm.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id 3266013D9; Wed, 28 Dec 2016 09:30:23 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from porto.starpoint.kiev.ua (porto-e.starpoint.kiev.ua [212.40.38.100]) by citapm.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id LAA05639; Wed, 28 Dec 2016 11:30:15 +0200 (EET) (envelope-from avg@FreeBSD.org) Received: from localhost ([127.0.0.1]) by porto.starpoint.kiev.ua with esmtp (Exim 4.34 (FreeBSD)) id 1cMAYp-000LnF-F1; Wed, 28 Dec 2016 11:30:15 +0200 To: "freebsd-arch@freebsd.org" , freebsd-fs From: Andriy Gapon Subject: INVARIANTS vs DIAGNOSTIC % lf_advlockasync Message-ID: <2225968a-7bce-b100-f3fa-a5e2eb8b9f47@FreeBSD.org> Date: Wed, 28 Dec 2016 11:28:54 +0200 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Dec 2016 09:30:25 -0000 I wonder if there are any guidelines on when to use INVARIANTS vs DIAGNOSTIC vs something else. Should the amount of output be taken into account? Or the performance impact? Or just the common sense? What I really mean is that if some sanity check could be rather expensive (e.g. it needs to iterate over a potentially long list), what option should be used to enabled it? I ask this question with one particular case in mind. lf_advlockasync() has a block of code under INVARIANTS with a loop over a list that has a nested loop over the same list for pair-wise checks. What's worse is that that code is executed with a lock held and that lock can potentially be highly contended (ls_lock). In our test environment we can observe the lock being held for as much as 125 milliseconds resulting in a huge backlog on the lock. (Even though the requested advisory locks are all shared locks and unlocks.) So, we would like to reduce the performance hit in that code, but still have the benefits of INVARIANTS enabled over all. Any suggestions are welcome. Thank you. -- Andriy Gapon