From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) by sourceware.org (Postfix) with ESMTPS id 437E7385700B for ; Mon, 5 Jul 2021 15:52:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 437E7385700B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f41.google.com with SMTP id i8so9739304wrp.12 for ; Mon, 05 Jul 2021 08:52:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=ZwbIG2W1XAXIPLLaVW+S724vjHJ1UY/hjRWgUnmI1Jk=; b=hEzMR4AnoUlLyAFkuf8qGe/jVQpujVQJ7Rf5+btSoealLSJAEwHbPZz46RjMB+ZOZy VM961dpIqO9527TfeFM1hwIuWdsCAdR0B8XvHloaTtmUI6BlxddtC6eU+h/UnESviP60 C9wvvsJCCSU6QSNvnlafr2WRN6V5XAxDRFHzZ4/i/D/wBtbsP4mOyjLSCrDuHI4MMNs8 XyGs16/UVqPGGXSRXGKVjTqMsjRyDwiW9uy3EmAmbJt3w3gEjXn+RZnyuMevjygyypA7 1AG462bulGRemZc3ATGaizQmiRDe6/WDF+6SWqgTGovGrSzej3Ky36moUGWnVoABvvxP lEBw== X-Gm-Message-State: AOAM533+6Nq2hZ3A0Xu71ExSkClRJnfXkTiI/wLS0984WxYxjgxKiMXG 6DeDjK6Z80NKTonT8nT3WgWPDAy3D1KjCw== X-Google-Smtp-Source: ABdhPJzg6n1hf6VMyV23XRB5Qdxi+T62RvcB2D5UKJwCYZ4LDeUr/rXA6w9ZERf8eKQj83STY9y4Zw== X-Received: by 2002:a05:6000:81:: with SMTP id m1mr16404971wrx.322.1625500324753; Mon, 05 Jul 2021 08:52:04 -0700 (PDT) Received: from ?IPv6:2001:8a0:f932:6a00:46bc:d03b:7b3a:2227? ([2001:8a0:f932:6a00:46bc:d03b:7b3a:2227]) by smtp.gmail.com with ESMTPSA id v15sm22866421wmj.39.2021.07.05.08.52.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 05 Jul 2021 08:52:03 -0700 (PDT) Subject: Re: [PATCH 10/11] gdb: maintain ptid -> thread map, optimize find_thread_ptid From: Pedro Alves To: Simon Marchi , gdb-patches@sourceware.org References: <20210622165704.2404007-1-simon.marchi@polymtl.ca> <20210622165704.2404007-11-simon.marchi@polymtl.ca> Message-ID: Date: Mon, 5 Jul 2021 16:52:02 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210622165704.2404007-11-simon.marchi@polymtl.ca> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org 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: , X-List-Received-Date: Mon, 05 Jul 2021 15:52:07 -0000 On 2021-06-22 5:57 p.m., Simon Marchi via Gdb-patches wrote: > When debugging a large number of threads (thousands), looking up a > thread by ptid_t using the inferior::thread_list linked list can add up. > > Add inferior::thread_map, an std::unordered_map indexed by ptid_t, and > change the find_thread_ptid function to look up a thread using > std::unordered_map::find, instead of iterating on all of the > inferior's threads. This should make it faster to look up a thread > from its ptid. > > gdb/ChangeLog: > yyyy-mm-dd Simon Marchi > Pedro Alves > > * gdbarch-selftests.c (register_to_value_test): Update the mock > inferior's thread map as well. > * inferior.c (inferior::clear_thread_list): Clear the thread map. > * inferior.h: Include . > (class inferior::thread_map): New field. > * regcache.c (cooked_read_test): Update the mock inferior's thread > map as well. > * thread.c (set_thread_exited): Remove the thread from the thread > map. > (new_thread): Insert the thread in the ptid map. > (find_thread_ptid): Lookup up the thread in the ptid map. > (thread_change_ptid): Update ptid map entry. > ( Should this have Co-Authored-By: ? ) OK. > Change-Id: I3a8da0a839e18dee5bb98b8b7dbeb7f3dfa8ae1c > ---