Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5CA58C433E0 for ; Wed, 27 May 2020 13:55:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 42D25208C3 for ; Wed, 27 May 2020 13:55:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388988AbgE0NzD (ORCPT ); Wed, 27 May 2020 09:55:03 -0400 Received: from mx2.suse.de ([195.135.220.15]:39988 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388984AbgE0NzB (ORCPT ); Wed, 27 May 2020 09:55:01 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 93A40B03C; Wed, 27 May 2020 13:55:03 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id 4F499DA72D; Wed, 27 May 2020 15:54:03 +0200 (CEST) Date: Wed, 27 May 2020 15:54:03 +0200 From: David Sterba To: Nikolay Borisov Cc: linux-btrfs@vger.kernel.org Subject: Re: [PATCH] btrfs: Open code key_search Message-ID: <20200527135403.GF18421@twin.jikos.cz> Reply-To: dsterba@suse.cz Mail-Followup-To: dsterba@suse.cz, Nikolay Borisov , linux-btrfs@vger.kernel.org References: <20200527101053.7340-1-nborisov@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200527101053.7340-1-nborisov@suse.com> User-Agent: Mutt/1.5.23.1-rc1 (2014-03-12) Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org On Wed, May 27, 2020 at 01:10:53PM +0300, Nikolay Borisov wrote: > This function wraps the optimisation implemented by d7396f07358a, > however this optimisation is really used in only one place - > btrfs_search_slot. Just open code the optimisation and also add a > comment explaining how it works since it's not clear just by looking > at the code - the key point here is it depends on an internal invariant > that BTRFS' btree provides, namely intermediate pointers always contain > the key at slot0 at the child node. So in the case of exact match we > can safely assume that the given key will always be in slot 0 on lower > levels. > > Furthermore this results in a reduction of btrfs_search_slot's size: > > ./scripts/bloat-o-meter ctree.orig fs/btrfs/ctree.o > add/remove: 0/0 grow/shrink: 0/1 up/down: 0/-75 (-75) > Function old new delta > btrfs_search_slot 2783 2708 -75 > Total: Before=50423, After=50348, chg -0.15% > > Signed-off-by: Nikolay Borisov Added to misc-next, thanks.