From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-io1-xd31.google.com (mail-io1-xd31.google.com [IPv6:2607:f8b0:4864:20::d31]) by sourceware.org (Postfix) with ESMTPS id D5AC43858D35 for ; Tue, 21 Nov 2023 21:09:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D5AC43858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D5AC43858D35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::d31 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700600969; cv=none; b=v/B9dHrEaeAG21ER4sDRvajAJ/6BJDZaQYpWtQ6JPJ/hEAMCh1YwennaoR6hIdXeXLUyW9Dn4ycHLWVnJetUaD1M1hYYRnJ9dwX+kO2VTBk2ofTGqCwdZ68pSapTq208JeyXhSV1WLH1VkdrWUBu20aoUUpGrIhAKRx05H9LV7k= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700600969; c=relaxed/simple; bh=w/LEVohNRH1j4ELJ5ZWDNmIG7nkiLP70sfdhUCeEBM4=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=AgtggC0H6Mg4v1v+Nd2ei6/PHZ7Iv7RaaTtuRiG4dkVhpxs5t2BlURLaC3i70ugu62hJdG5Nf8Xe8+H//lQFvW+K+Z6akTcZE9xkFeH5UjXPaIGdMaNAsi9JcL/HcKqSGx3LPXhbK8ZQJm3fhzxkUKLJtni4PF283sAfE/1FQ+c= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-io1-xd31.google.com with SMTP id ca18e2360f4ac-7b34ec3e44fso21665639f.3 for ; Tue, 21 Nov 2023 13:09:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1700600967; x=1701205767; darn=sourceware.org; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=BQQ1EqzVS9WEPR3J3P7+F1ffmBzdp8ymdx0fDwRjgjY=; b=JPbFB6DSpdHC54AV0Nkaml9TEGKxy7ltDxdTKJe8FEWXOyutQvGwLAHJaARjbi4n61 cW6V+VIPYiipIOtUJgPY4SbPb+VAczyTVS2kBcdsgFv1a9b7ZqpraVwSEdp1cVhJcicz A1VfIgb1JkwmIfWcDVflGEN+LfXBi2ICHWHHe8EN12LRGeaGtgoAbiaDgcHfRpcFFaDV 2UhxJqv6LwozVZYEWwp+bm2HiPWQWEkdjHa67NQYPSG0kvhvOdGtZ2+QWCqfue82gNGA C7Z3Y6ah7vivNcBac4sfvI5LcADj+VEP01JkKbjQiGEW2BYLxwDWR0l7Yda6S5huE6qr 6/bQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700600967; x=1701205767; h=to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BQQ1EqzVS9WEPR3J3P7+F1ffmBzdp8ymdx0fDwRjgjY=; b=qETDH7wtiOeURxY6KFAQCFGXPHTAkNIx7gpSXqtF8WhhHRu885meDuURGV38ZFEK29 C7o7rqfY8Fw6LgmXG53guqSQV7kmqOwovNT3K46tvlHdCKnh7XApe3MdjsdmCxKHDC1G xYJMVLz9dJvXM+Xr+gz3mDJ3ICfaLD4yKoQw1c5k1cXBlI/b2Lfo1SH32WUrTB97LB3d 4aruufNX1kvln1eaYfqBKoVoIbDYAxTssZH+ioIxFrUW20f3d1Zpv2gg5x8jAple4M3T Vl9LCnlZJ9mSXjtZ+CJmBvrOzf6Q0pFwFL8cnhGP0db/5g66lFmQDBrNWiaw41oGzzbD tQmw== X-Gm-Message-State: AOJu0YyvyTvhXu01v2eclTj05kUx0RnRpPH7Yg7psPhxWAJZXFgRfzO8 ngYwV5k3KCv1lwQYdtm8jyvhiLbHFohlr2VNx+DTWA== X-Google-Smtp-Source: AGHT+IERPM0VROAORuolG2OWYlcpJBMFImTnPtl7l1rHT4dz4GjyyxwUfAF5w/ZhOfIBwy6GpRzc6A== X-Received: by 2002:a5e:a616:0:b0:787:8fc:75d8 with SMTP id q22-20020a5ea616000000b0078708fc75d8mr116936ioi.9.1700600966784; Tue, 21 Nov 2023 13:09:26 -0800 (PST) Received: from localhost.localdomain (97-122-77-73.hlrn.qwest.net. [97.122.77.73]) by smtp.gmail.com with ESMTPSA id l14-20020a6b750e000000b0079f7734a77esm3050242ioh.35.2023.11.21.13.09.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 13:09:26 -0800 (PST) From: Tom Tromey Date: Tue, 21 Nov 2023 14:09:25 -0700 Subject: [PATCH 1/4] Improve performance of Ada name searches MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20231121-ada-lookup-perf-v1-1-1efd2d1dbf65@adacore.com> References: <20231121-ada-lookup-perf-v1-0-1efd2d1dbf65@adacore.com> In-Reply-To: <20231121-ada-lookup-perf-v1-0-1efd2d1dbf65@adacore.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.4 X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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: A user reported that certain operations -- like printing a large structure -- could be slow. I tracked this down to ada-lang.c:map_matching_symbols taking an inordinate amount of time. Specifically, calls like the one to look for a parallel "__XVZ" variable, in ada_to_fixed_type_1, could result in gdb walking over all the entries in the cooked index over and over. Looking into this reveals that cooked_index_functions::expand_matching_symbols is not written efficiently -- it ignores its "ordered_compare" parameter. While fixing this would be good, it turns out that this entire method isn't needed; so this series removes it. However, the deletion is not done in this patch. This one, instead, fixes the immediate cause of the slowdown, by using objfile::expand_symtabs_matching when possible. This approach is faster because it is more selective about which index entries to examine. --- gdb/ada-lang.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index ff7222c7eed..8c5ab93f3ca 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -5572,8 +5572,16 @@ map_matching_symbols (struct objfile *objfile, match_data &data) { data.objfile = objfile; - objfile->expand_matching_symbols (lookup_name, domain, global, - is_wild_match ? nullptr : compare_names); + if (is_wild_match || lookup_name.ada ().standard_p ()) + objfile->expand_matching_symbols (lookup_name, domain, global, + is_wild_match ? nullptr : compare_names); + else + objfile->expand_symtabs_matching (nullptr, &lookup_name, + nullptr, nullptr, + global + ? SEARCH_GLOBAL_BLOCK + : SEARCH_STATIC_BLOCK, + domain, ALL_DOMAIN); const int block_kind = global ? GLOBAL_BLOCK : STATIC_BLOCK; for (compunit_symtab *symtab : objfile->compunits ()) -- 2.41.0