Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp10314572rwd; Wed, 21 Jun 2023 20:56:37 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6y7CeWd9bASYxnXeCmlG3BWmof2DR+Ja2lFz7gNryHEa8BsVxGL9l1ZpD3y2Ws//+BngaB X-Received: by 2002:a17:902:6ac5:b0:1ae:3991:e4f9 with SMTP id i5-20020a1709026ac500b001ae3991e4f9mr15407470plt.61.1687406197335; Wed, 21 Jun 2023 20:56:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687406197; cv=none; d=google.com; s=arc-20160816; b=mY8RQnopFe62AMlTH8oLdRDOuX/6QMrior4m+UksVPWfanwMIHtrS9fL7K8/gv+Q1Q VgcdMP/4U29WX2xXaNzdb/3l13sHPzijGfh4v2LSGl5CAYHFceSgEBoSXl3Kl9TlyPl9 RgblWZ7Ifwa4kDGjIvaVh1EvAPMGb0DLltCfne82M7G0I99dsassiKoYePSp6gdDWXPH OGZJBoqJxreurSSCM9srRn1oH6rRAREQGgjI+UVRDQZ8Xvp54v8+Nb4dh0s6b2sKu2at VX5iq7BnzY0dMJiROiMrhh+COH46WB0lgzW23pGyjO/GUGo5WVTEi7z5e69XxLMe2mKK sixg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=MblmjndIFpvdofSIBo9uFU0wU1pf7yydBIVj6+XQ874=; b=OvScauEXHUYlZuvHUeqFSbiaOXpBTLnNUjEOvK8Z8qNpnUd2dHvNBYUN+ckrzl8pyh Pyo+as68fTO7wE3ENQHkx74n3OcLfbesu+Bl4EVC7xEDHXXpj6EvpWm+HkAiQpuTPqqv FUXPlNzAEqd6FiMxr+tG2qNu6QIiAy7afcDbFZfDCdOZb+8WuiAEMe2PuF2eCyxq9MDa bgcP66KOSWTV+OxQoTyg3d3SJNwxpPuMbJe7OVU8bbvSuFPg7XMayXNm5ZLAR3W6YV4n F93BL+bVFHIdCk5J19nA72+GmesB5EzZXmfYGccL2mcwLaUNr99XhvRaupffm0KdKaZR 8kHA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z16-20020a170903019000b001b679ec31ccsi6115352plg.70.2023.06.21.20.56.24; Wed, 21 Jun 2023 20:56:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229953AbjFVDvP convert rfc822-to-8bit (ORCPT + 99 others); Wed, 21 Jun 2023 23:51:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229935AbjFVDvN (ORCPT ); Wed, 21 Jun 2023 23:51:13 -0400 Received: from mail-yb1-f182.google.com (mail-yb1-f182.google.com [209.85.219.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BABF91BD4; Wed, 21 Jun 2023 20:51:12 -0700 (PDT) Received: by mail-yb1-f182.google.com with SMTP id 3f1490d57ef6-c01e1c0402cso198611276.0; Wed, 21 Jun 2023 20:51:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687405872; x=1689997872; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=m/MofGdlyCWHDpo+tEjRP5NVRsAoqM1bdJmP0dhp050=; b=FX6AguW3nhUdwfgjYT10BHJMOtzmQmiyeLXnZVvHEb1Jy7jamDTApPGF5tc7Wgmg4h 49v7VLOUflVOSWes/S10ghd8pAYXQlmUpHFBZRCqKwj8jSfiMG52HK8Q9dIp6RYMqkPW aJqlQPnjvRAus87AIQf8TMVWOMreetCAXH9/UP6UaF6+gJqC/QEx/55VJKZ8SEllQqby E/4DpiV7WxswHR9QHqmhOrHI5a9NWSVJLetp3XzpbG4Q//ymnyy9AUBYLJhTNE7XpNVs O0WQiySd8BY93meIynAZWvZcG2CK1ZJorAuS6zgP6fsuyMTTqhJXpgVhE+aytoNgiZhv 53zQ== X-Gm-Message-State: AC+VfDwHTpCWsUUYViWBUsqpvjfYQkddua2yybS8x6L9ml4nalQSK5+W POHEJ96jITjLY/h6ITSWL5HHUuh6GVCJXNiH0gg= X-Received: by 2002:a25:838a:0:b0:bfe:e65b:7f with SMTP id t10-20020a25838a000000b00bfee65b007fmr3616507ybk.50.1687405871696; Wed, 21 Jun 2023 20:51:11 -0700 (PDT) MIME-Version: 1.0 References: <20230621063749.3358430-1-irogers@google.com> In-Reply-To: <20230621063749.3358430-1-irogers@google.com> From: Namhyung Kim Date: Wed, 21 Jun 2023 20:51:00 -0700 Message-ID: Subject: Re: [PATCH v2 1/2] perf symbol: Remove symbol_name_rb_node To: Ian Rogers Cc: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , Yang Jihong , Carsten Haitzler , Changbin Du , Athira Rajeev , Christophe JAILLET , Jason Wang , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Ian, On Tue, Jun 20, 2023 at 11:37 PM Ian Rogers wrote: > > Most perf commands want to sort symbols by name and this is done via > an invasive rbtree that on 64-bit systems costs 24 bytes. Sorting the > symbols in a DSO by name is optional and not done by default, however, > if sorting is requested the 24 bytes is allocated for every > symbol. > > This change removes the rbtree and uses a sorted array of symbol > pointers instead (costing 8 bytes per symbol). As the array is created > on demand then there are further memory savings. The complexity of > sorting the array and using the rbtree are the same. > > To support going to the next symbol, the index of the current symbol > needs to be passed around as a pair with the current symbol. This > requires some API changes. > > Signed-off-by: Ian Rogers > > v2. map__find_symbol_by_name_idx so that map__find_symbol_by_name > doesn't need an optional parameter. Separate out > symbol_conf.sort_by_name removal. > --- [SNIP] > void dso__sort_by_name(struct dso *dso) > { > - dso__set_sorted_by_name(dso); > - return symbols__sort_by_name(&dso->symbol_names, &dso->symbols); > + mutex_lock(&dso->lock); > + if (!dso__sorted_by_name(dso)) { > + size_t len; > + > + dso->symbol_names = symbols__sort_by_name(&dso->symbols, &len); > + if (dso->symbol_names) { > + dso->symbol_names_len = len; > + dso__set_sorted_by_name(dso); > + } > + } > + mutex_unlock(&dso->lock); I think this part deserves a separate commit. Thanks, Namhyung