From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id BD2073858D1E for ; Tue, 20 Feb 2024 04:20:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BD2073858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BD2073858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708402835; cv=none; b=yERCk8mOJ0cl6x7KUeEk6usL5kQK3seSfQCSvnPIUNcZC+xWM/Gv3FNkPotukliQK2jxMZ/yAxRd32GrIMZLS/bFEYS6RwS+G8URid2005xZwRXnb0lhyXki4Dmj/gEWRNPH81/nDj+nn5zWnumyaTHG/eRx5NLbzJZB5R7eXYg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708402835; c=relaxed/simple; bh=Ldki5VY5d+P1gw9ZWUpXkgrekO5n+8t5qEhtTkxST6M=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=ZRU0pH8lvWpJN4Ef6CuuI2WzN861V39fg6gqw1evrxrwCY6dACKrHxISgcrn9PWWp5B7lSaKzhoe1CzKZRb9RNS/hxV+3tgia0JVAo4yBvn7Rd3OpaPzwkugNIzrP2TU7YMWBxJnSrl8fMZqKQeVv9iykSt1FdPNoHQ/jQPTGuU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1708402833; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cRiiBfAA8rsp43U6UEM4LxQAzArFNma3qC5IThFlslM=; b=Zk6G3GOZ72SYJuLBjJJhtcXAR8d3VYgm4OfwW8873UtpoTtGkSX8wcwSydpMo8bMZ6QYem KcgoKPl6wnuZfGooel9PGOgNv7uJitXd2GhSAnaVpRi4M7BxhOT1HkXsGdbC4SLFX92KXE LC1alfCeSL3QEYNL8Ass7nO/vjQA6m0= Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-486-mGBAI76uNFOobtJFd20_zw-1; Mon, 19 Feb 2024 23:20:31 -0500 X-MC-Unique: mGBAI76uNFOobtJFd20_zw-1 Received: by mail-pl1-f200.google.com with SMTP id d9443c01a7336-1dbc6ff68ffso36273365ad.1 for ; Mon, 19 Feb 2024 20:20:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708402830; x=1709007630; 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=cRiiBfAA8rsp43U6UEM4LxQAzArFNma3qC5IThFlslM=; b=MqXqQi80u0+tXp3/jND7Ex2G2/cbrXyRTqU3DLmsuO3L8We29AMuzieK0X7eFNfJCw B4kTX3aMVJHPA5AVN5uIAtvuCWE2S9mwChi65XG3B5YN/8CCY/L1ze/eBYPcs3ZOqjRj j+dcS19GkH3hAxhVxz9oX556nw7iVmU1OFmmu2saCNl25Pl8jgjwj7E2SFv8pqp/3Hys oJiwqQ6Z7bmWaR5ipA4dFQAEBAHidNSVcKtz9N7HgRaR+jGxVm4sUAznV/lJEMvKAaoS HZ/PfWxjAc/LPGLbTMZuddHyZrebxoKlMtlz1zoCiyrxCeBFj14XtnOpnQLYSSmFmmbx ztKw== X-Gm-Message-State: AOJu0Yzxcw12cUgMz9apDIXhJ6N1GcmVBliKtBWnQ4SO99yupmVtFAdS PrxxUg2kKOpqChJoMhCa9PIljaZETwi9Bk42Goh+O+ByfoqTahclbfzsurf8BCRcRyd8NBte8l1 GOmIJ3v/ohCRe8VPYOMym1uANcct54hfQrIUm7yUztRlgXsDF4antqC/teAI5dPy9krH0biheX0 QCU4P3pzAV6KWFJDFTOQ3nfCf0L6ou8my1CRwBwyxFTCpm4/0= X-Received: by 2002:a17:90a:bf82:b0:299:ecba:cc6a with SMTP id d2-20020a17090abf8200b00299ecbacc6amr58974pjs.40.1708402830067; Mon, 19 Feb 2024 20:20:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IHSNSq4ktip7a4Megr+SmrN/BvJqHekfw+qlysROTtIOfnlegpxAkFjTpnNG2/zVzd/DkPp6KKTWHa2pdyqBlg= X-Received: by 2002:a17:90a:bf82:b0:299:ecba:cc6a with SMTP id d2-20020a17090abf8200b00299ecbacc6amr58876pjs.40.1708402824860; Mon, 19 Feb 2024 20:20:24 -0800 (PST) MIME-Version: 1.0 References: <20231207013504.40300-3-amerey@redhat.com> <20231211231853.116254-1-amerey@redhat.com> In-Reply-To: From: Aaron Merey Date: Mon, 19 Feb 2024 23:20:13 -0500 Message-ID: Subject: Re: [PATCH v2] dwarf_getaranges: Build aranges list from CUs instead of .debug_aranges To: Mark Wielaard Cc: elfutils-devel@sourceware.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi Mark, On Tue, Feb 13, 2024 at 8:28=E2=80=AFAM Mark Wielaard wrot= e: > > > This patch's method of building the aranges list is slower than simply > > reading .debug_aranges. On my machine, running eu-stack on a 2.9G > > firefox core file takes about 8.7 seconds with this patch applied, > > compared to about 3.3 seconds without this patch. > > That is significant. 2.5 times slower. > Did you check with perf or some other profiler where exactly the extra > time goes. Does the new method find more aranges (and so produces > "better" backtraces)? I took another look at the performance and realized I made a silly mistake when I originally tested this. My build that was 2.5x slower was compiled with -O0 but I tested it against an -O2 build. Oops! With the optimization level set to -O2 in all cases, the runtime of 'eu-stack -s' on the original 2.9G firefox core file is only about 9% slower: 3.6 seconds with the patch applied compared to 3.3 seconds without the patch. As for the number of aranges found, there is a difference for libxul.so: 250435 with the patch compared to 254832 without. So 4397 fewer aranges are found when using the new CU iteration method. I'll dig into this and see if there is a problem or if it's just due to some redundancy in libxul's .debug_aranges. FWIW there was no change to the aranges counts for the other modules searched during this eu-stack firefox corefile test. > > > Ideally we could assume that .debug_aranges is complete if it is presen= t > > and build the aranges list via CU iteration only when .debug_aranges > > is absent. This would let us save time on gcc-compiled binaries, which > > include complete .debug_aranges by default. > > Right. This why the question is if the firefox case sees more/less > aranges. If I remember correctly it is build with gcc and rustc, and > rustc might not produce .debug_aranges. > > > However the DWARF spec appears to permit partially complete > > .debug_aranges [1]. We could improve performance by starting with a > > potentially incomplete list built from .debug_aranges. If a lookup > > fails then search the CUs for missing aranges and add to the list > > when found. > > > > This approach would complicate the dwarf_get_aranges interface. The > > list it initially provides could no longer be assumed to be complete. > > The number of elements in the list could change during calls to > > dwarf_getarange{info, _addr}. This would invalidate the naranges value > > set by dwarf_getaranges. The current API doesn't include a way to > > communicate to the caller when narages changes and by how much. > > > > Due to these complications I think it's better to simply ignore > > .debug_aranges altogether and build the aranges table via CU iteration, > > as is done in this patch. > > Might it be an idea to leave dwarf_getaranges as it is and introduce a > new (internal) function to get "dynamic" ranges? It looks like what > programs (like eu-stack and eu-addr2line) really use is dwarf_addrdie > and dwfl_module_addrdie. These are currently build on dwarf_getaranges, > but could maybe use a new interface? IMO this depends on what users expect from dwarf_getaranges. Do they want the exact contents of .debug_aranges (whether or not it's complete) or should dwarf_getaranges go beyond .debug_aranges to ensure the most complete results? The comment for dwarf_getaranges in libdw.h simply reads "Return list address ranges". Since there's no mention of .debug_aranges specifically, I think it's fair if dwarf_getaranges does whatever it can to ensure comprehensive results. In which case dwarf_getaranges should probably dynamically generate aranges. Aaron