From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id qMYnD3wX0mAtYAAAWB0awg (envelope-from ) for ; Tue, 22 Jun 2021 13:01:48 -0400 Received: by simark.ca (Postfix, from userid 112) id 3C3471F1F2; Tue, 22 Jun 2021 13:01:48 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id E7B451E54D for ; Tue, 22 Jun 2021 13:01:47 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A50DC3943423 for ; Tue, 22 Jun 2021 17:01:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A50DC3943423 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1624381307; bh=EFL4uZgzKktOvUUm2hNc7b919C/RaKZEsDJ9EgUobBk=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=P2E1vdHZ27dpIN4a7TqPY4QpLe8oNJ+RxdGOl2kvK6qywgvJ4LJ40YnXq6UoQX76u evlytBH/Il+YvNcjqaffdXY7ZoJCqoK+kmEiGtkm6tp8+4UX3MDoxDpT43XjoHfp66 s7LSdSjPrkZ1XLLR7EqEVl3oa8N1ZWE+ROPK1P1Q= Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id D34AC393AC35 for ; Tue, 22 Jun 2021 16:59:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D34AC393AC35 X-ASG-Debug-ID: 1624381146-0c856e67e2169e600001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id RHUM7i8EdZA7Heu9 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 22 Jun 2021 12:59:07 -0400 (EDT) X-Barracuda-Envelope-From: simon.marchi@polymtl.ca X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from simark.localdomain (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) by smtp.ebox.ca (Postfix) with ESMTP id DBAD7441B21; Tue, 22 Jun 2021 12:59:06 -0400 (EDT) X-Barracuda-RBL-IP: 192.222.157.6 X-Barracuda-Effective-Source-IP: 192-222-157-6.qc.cable.ebox.net[192.222.157.6] X-Barracuda-Apparent-Source-IP: 192.222.157.6 To: gdb-patches@sourceware.org Subject: [PATCH 08/11] gdb: optimize check for resumed threads with pending wait status in maybe_set_commit_resumed_all_targets Date: Tue, 22 Jun 2021 12:57:01 -0400 X-ASG-Orig-Subj: [PATCH 08/11] gdb: optimize check for resumed threads with pending wait status in maybe_set_commit_resumed_all_targets Message-Id: <20210622165704.2404007-9-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210622165704.2404007-1-simon.marchi@polymtl.ca> References: <20210622165704.2404007-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1624381147 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Barracuda-BRTS-Status: 1 X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 2913 X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=8.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.90826 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" Consider a test case where many threads (thousands) keep hitting a breakpoint whose condition evaluates to false. maybe_set_commit_resumed_all_targets is called at each handled event, when the scoped_disable_commit_resumed object in fetch_inferior_event is reset_and_commit-ed. One particularly expensive check in there is whether the target has at least one resumed thread with a pending wait status (in which case, we don't want to commit the resumed threads, as we want to consume this status first). It is currently implemented as walking all threads of the target. Since we now maintain a per-target list of resumed threads with pending status, we can do this check efficiently, by checking whether that list is empty or not. Add the process_stratum_target::has_resumed_with_pending_wait_status method for this, and use it in maybe_set_commit_resumed_all_targets. gdb/ChangeLog: * process-stratum-target.h (class process_stratum_target) : New. * infrun.c (maybe_set_commit_resumed_all_targets): Use has_resumed_with_pending_wait_status. Change-Id: Ia1595baa1b358338f94fc3cb3af7f27092dad5b6 --- gdb/infrun.c | 10 +--------- gdb/process-stratum-target.h | 5 +++++ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/gdb/infrun.c b/gdb/infrun.c index c973b34fa1d6..657f97e23fbb 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -2801,15 +2801,7 @@ maybe_set_commit_resumed_all_targets () status to report, handle it before requiring the target to commit its resumed threads: handling the status might lead to resuming more threads. */ - bool has_thread_with_pending_status = false; - for (thread_info *thread : all_non_exited_threads (proc_target)) - if (thread->resumed () && thread->has_pending_waitstatus ()) - { - has_thread_with_pending_status = true; - break; - } - - if (has_thread_with_pending_status) + if (proc_target->has_resumed_with_pending_wait_status ()) { infrun_debug_printf ("not requesting commit-resumed for target %s, a" " thread has a pending waitstatus", diff --git a/gdb/process-stratum-target.h b/gdb/process-stratum-target.h index d79efbee8f2c..c73207e0531e 100644 --- a/gdb/process-stratum-target.h +++ b/gdb/process-stratum-target.h @@ -88,6 +88,11 @@ class process_stratum_target : public target_ops target's "resumed with pending wait status" list. */ void maybe_remove_resumed_with_pending_wait_status (thread_info *thread); + /* Return true if this target has at least one resumed thread with a pending + wait status. */ + bool has_resumed_with_pending_wait_status () const + { return !m_resumed_with_pending_wait_status.empty (); } + /* The connection number. Visible in "info connections". */ int connection_number = 0; -- 2.32.0