From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22077 invoked by alias); 9 Apr 2019 17:58:34 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 22065 invoked by uid 89); 9 Apr 2019 17:58:34 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=noticed X-HELO: mail-wm1-f67.google.com Received: from mail-wm1-f67.google.com (HELO mail-wm1-f67.google.com) (209.85.128.67) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 09 Apr 2019 17:58:32 +0000 Received: by mail-wm1-f67.google.com with SMTP id 4so4629734wmf.1 for ; Tue, 09 Apr 2019 10:58:31 -0700 (PDT) Return-Path: Received: from ?IPv6:2001:8a0:f913:f700:56ee:75ff:fe8d:232b? ([2001:8a0:f913:f700:56ee:75ff:fe8d:232b]) by smtp.gmail.com with ESMTPSA id 10sm17917158wmd.23.2019.04.09.10.58.29 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Tue, 09 Apr 2019 10:58:29 -0700 (PDT) Subject: Re: [PATCH] Use find_thread_in_random in select_event_lwp To: Tom Tromey , gdb-patches@sourceware.org References: <20190409164600.29369-1-tromey@adacore.com> From: Pedro Alves Message-ID: <5c3a3a40-cd5a-a913-e99d-e56a91a988b0@redhat.com> Date: Tue, 09 Apr 2019 17:58:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20190409164600.29369-1-tromey@adacore.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2019-04/txt/msg00152.txt.bz2 On 4/9/19 5:46 PM, Tom Tromey wrote: > I noticed that find_thread_in_random duplicates the code in > find_thread_in_random, so this patch changes the latter to use the > former. > > There are two other spots in gdb that do this, but to unify all of > them would require switching some code from using the "iterate over" > idiom to using iterators. Plus I'm touching that code a lot in the multi-target work and adding more instances of "pick one at random". :-D > > Another possible improvement is that find_thread_in_random could be > made single-pass using reservoir sampling. > Or by simply keeping/maintaining a count of threads. > Tested by the buildbot. > > gdb/gdbserver/ChangeLog > 2019-04-09 Tom Tromey > > * linux-low.c (select_event_lwp): Use find_thread_in_random. OK. Thanks, Pedro Alves