Received: by 10.223.176.5 with SMTP id f5csp2986011wra; Mon, 29 Jan 2018 07:11:32 -0800 (PST) X-Google-Smtp-Source: AH8x226HVMUM87bP1xuAeWRDcA3FTnj9BsUM7TT69gsOQIb1Gl6xvX7OBotjg/nRiaEGPhAY91Nu X-Received: by 2002:a17:902:2845:: with SMTP id e63-v6mr21581915plb.438.1517238692597; Mon, 29 Jan 2018 07:11:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517238692; cv=none; d=google.com; s=arc-20160816; b=WUW5F2U5pJLZn/K5TVawoqoS71uIkimURbZI81IaoN1Lutg8dygLe8y/xnZQGGVrle BR+xHkRzgcx1FONjy3ik+AiRmg7CdeTUHACeoTIPHCrnExuKLM9SoFiIqOrs+YD6jTCU Tg0o+ClzGYSVVv3k6aYGw9UyVNngWcylAqdIxD+6e5iix5RANcjHL1MBWeFPduXqgK7O cSxr7+e5lPCHEVMSmyv83VEPDLs/0htvGoxeR8THKIKmkoH1b8bYObK8yzC0NtDU0QPR L13UcfNq0Bm9Rqu66dVq49UR86IDVGm4xF4yN93JoD0LSLfBzLynySXXNBf7pXnYFRG0 c7mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dmarc-filter :arc-authentication-results; bh=31nngn8bzeqfBn+hP4ygycgtQOcRtaJsXqv8BSJ6UhA=; b=Z6aL3FI3qYt9rHNqHqTwlrPo/p3rr/M8OaWvf19YDnxziSR9nW2HOXG6Qyd6IkipGi xU+SNMxN5u4ezJHDwFcAvnGBR9qkvvlaLYv2C2tv4Wt3CGwZJFD6tyAYHb+P+tq+5wql qFJJcsL7SEcAeLNQ5AANjY5qZUYQU0EY9RvCLe5WzhD/d2Ofx+EHol9f+oaVo8QoKRDd O5iN9qPzvvSF9AdldSsn5i4xmTNts8dy88fzpogTWEVNcOFO+tmOVv3aX0L+c4bqVyxA Kz+/DIZqyMMSQSVmuNKkq6Snv25QGipa5oPwz0wakIiI0PlP3+bSsUZMEDTXW8zlP2lE L6hQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t20si857175pfi.42.2018.01.29.07.11.17; Mon, 29 Jan 2018 07:11:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752052AbeA2PKy (ORCPT + 99 others); Mon, 29 Jan 2018 10:10:54 -0500 Received: from mail.kernel.org ([198.145.29.99]:37790 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751599AbeA2PKw (ORCPT ); Mon, 29 Jan 2018 10:10:52 -0500 Received: from mail-qt0-f177.google.com (mail-qt0-f177.google.com [209.85.216.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 18E9E2175D; Mon, 29 Jan 2018 15:10:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 18E9E2175D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=robh@kernel.org Received: by mail-qt0-f177.google.com with SMTP id d8so13076071qtm.0; Mon, 29 Jan 2018 07:10:52 -0800 (PST) X-Gm-Message-State: AKwxytf/Ad27WYjPr5nqQ++P6VdiY9cJl1NtcvbY5JLFdGwCfCclbiuG nEVhTqalVn62aovzg532DBx7t8Dltb5M4G4h5A== X-Received: by 10.237.58.226 with SMTP id o89mr40134722qte.207.1517238651270; Mon, 29 Jan 2018 07:10:51 -0800 (PST) MIME-Version: 1.0 Received: by 10.12.147.20 with HTTP; Mon, 29 Jan 2018 07:10:30 -0800 (PST) In-Reply-To: References: <1516955496-17236-1-git-send-email-cpandya@codeaurora.org> <20180126213943.7zwijanlbrq3y666@rob-hp-laptop> From: Rob Herring Date: Mon, 29 Jan 2018 09:10:30 -0600 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2] of: use hash based search in of_find_node_by_phandle To: Chintan Pandya Cc: Rasmus Villemoes , Frank Rowand , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , "linux-kernel@vger.kernel.org" , linux-arm-msm Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 29, 2018 at 1:34 AM, Chintan Pandya wrote: > >> I was curious, so I implemented it. It ends up being similar to Rasmus's >> 1st suggestion. The difference is we don't try to store all entries, but >> rather implement a hash table that doesn't handle collisions. Relying on >> the fact that phandles are just linearly allocated from 0, we just mask >> the high bits of the phandle to get the index. > > I think this is most resourceful way. >> >> Can you try out on your setup and try different >> array sizes. > > Here are my test results. However, I simply considered overall boot time to > compare different scenarios because profiling of_find_node_by_phandle() in > early boot fails. > > Scenarios: > [1] Cache size 1024 + early cache build up [Small change in your cache > patch, > see the patch below] > [2] Hash 64 approach[my original v2 patch] > [3] Cache size 64 > [4] Cache size 128 > [5] Cache size 256 > [6] Base build > > Result (boot to shell in sec): > [1] 14.292498 14.370994 14.313537 --> 850ms avg gain > [2] 14.340981 14.395900 14.398149 --> 800ms avg gain > [3] 14.546429 14.488783 14.468694 --> 680ms avg gain > [4] 14.506007 14.497487 14.523062 --> 670ms avg gain > [5] 14.671100 14.643344 14.731853 --> 500ms avg gain It's strange that bigger sizes are slower. Based on this data, I'd pick [3]. How many phandles do you have? I thought it was hundreds, so 1024 entries would be more than enough and you should see some curve to a max gain as cache size approaches # of phandles. Rob