From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 0C84OxxuTGjN0wwAWB0awg (envelope-from ) for ; Fri, 13 Jun 2025 14:29:48 -0400 Authentication-Results: simark.ca; dkim=fail reason="signature verification failed" (768-bit key; unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=LNUsvK1K; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id EE5F51E102; Fri, 13 Jun 2025 14:29:48 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-8.8 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE autolearn=unavailable autolearn_force=no version=4.0.1 Received: from server2.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 ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 7FD491E0C2 for ; Fri, 13 Jun 2025 14:29:48 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 22B0C39067A9 for ; Fri, 13 Jun 2025 18:29:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 22B0C39067A9 Authentication-Results: sourceware.org; dkim=fail reason="signature verification failed" (768-bit key, unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=LNUsvK1K Received: from omta34.uswest2.a.cloudfilter.net (omta34.uswest2.a.cloudfilter.net [35.89.44.33]) by sourceware.org (Postfix) with ESMTPS id 14C6339067A0 for ; Fri, 13 Jun 2025 18:29:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 14C6339067A0 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 14C6339067A0 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1749839357; cv=none; b=vUB9TkUj/fLr2bZovadmGUGehrfX6WcCS+KDGxbXgyxsQwkOxVp/5KaDtHC+sTOwDz1sB5SJ9FqjTbf+m9qwOuPESm2BFGQ6LWToZzL9MWZb9QVHxmBNUudtlkE53rBa/shkSz00NPt+BlR7zbaN7Q0AwzhfegK8zlf0BrCLt9Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1749839357; c=relaxed/simple; bh=+a6HzDh/U9YEZO+TULxasXD6iE1pIxuNlv3bSJsBP8g=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=N5D/N3hB4z0Fts+dbTaz9bCPi22y/KQIWw0b4Szxho2RBcSrma4lbiuDIIYpGZ4iBitS2IpdZ3x5jD05IsNcL9pJi5YRc9wVOZT4E6oB8OJTLpM2MOqu21dFU4/4n1fBBlFEeu/s3gd/zKIn3XsM0sHVV2cTESrUTQL8SSyColU= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 14C6339067A0 Received: from eig-obgw-6007a.ext.cloudfilter.net ([10.0.30.247]) by cmsmtp with ESMTPS id Q7RVuGTswWuHKQ99QuVyZO; Fri, 13 Jun 2025 18:29:16 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id Q99PuGixi3IrfQ99PusUA9; Fri, 13 Jun 2025 18:29:15 +0000 X-Authority-Analysis: v=2.4 cv=PL4J++qC c=1 sm=1 tr=0 ts=684c6dfb a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=6IFa9wvqVegA:10 a=ItBw4LHWJt0A:10 a=7d_E57ReAAAA:8 a=tYtU9xVxv1HQjLXF3EYA:9 a=jhqOcbufqs7Y1TYCrUUU:22 a=VS4QxaUSPT0UtbFnIvSC:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:Date:References:In-Reply-To :Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=34RJS5u0py2ZoQoRfivMTz/GPYeZldKhR7M5YNUUhOc=; b=LNUsvK1K6LfFPzYk/trTuLaZ1e ja+ra7rYcGEjiGieEJvRlq8woCcPLaYGBE9LqBCMImJHWG5gZB37KQ9p6Sd9A49saI6JRTNA1wEbc j8poBRnUF7qYd1ekFkwOwSLrA; Received: from 75-166-228-225.hlrn.qwest.net ([75.166.228.225]:40536 helo=bapiya) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.1) (envelope-from ) id 1uQ99O-000000014xT-2M7e; Fri, 13 Jun 2025 12:29:14 -0600 From: Tom Tromey To: Simon Marchi Cc: gdb-patches@sourceware.org, Simon Marchi Subject: Re: [PATCH 3/6] gdbsupport: use dynamic partitioning in gdb::parallel_for_each In-Reply-To: <20250505201548.184917-3-simon.marchi@efficios.com> (Simon Marchi's message of "Mon, 5 May 2025 16:15:27 -0400") References: <20250505201548.184917-1-simon.marchi@efficios.com> <20250505201548.184917-3-simon.marchi@efficios.com> X-Attribution: Tom Date: Fri, 13 Jun 2025 12:29:12 -0600 Message-ID: <87tt4jjy13.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 75.166.228.225 X-Source-L: No X-Exim-ID: 1uQ99O-000000014xT-2M7e X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-228-225.hlrn.qwest.net (bapiya) [75.166.228.225]:40536 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfBiRI4YtQgwVPt0B7Xwhj5bTvsa7rj478RQcGzD5l0P5rhaIXfJlukvdBlsLp5t5EEklm2mcbBzgyBNXNZVIjq8L5wYQD9saVgrPTQMeNjH43ckrv7Yv b5tW9K6sK6boEi/AnJRGeJM5Y/NVK7sDNYXSvGz8ydLfB16udlTKj0JUvUVF5f/xFfKCHx+ocHthNf57gB8z9boIThKr+lluRlU= X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org >>>>> "Simon" == Simon Marchi writes: Simon> - I want to still be able to use scoped_time_it to measure the time Simon> that each worker thread spent working on the task. I find it really Simon> handy when measuring the performance impact of changes. Simon> Unfortunately, the current interface of gdb::parallel_for_each, which Simon> receives a simple callback, is not well-suited for that, once I Simon> introduce the dynamic partitioning. The callback would get called Simon> once for each work item batch (multiple time for each worker thread), Simon> so it's not possible to maintain a per-worker thread object for the Simon> duration of the parallel for. Simon> To allow this, I changed gdb::parallel_for_each to receive a worker Simon> type as a template parameter. Each worker thread creates one local Simon> instance of that type, and calls operator() on it for each work item Simon> batch. By having a scoped_time_it object as a field of that worker, Simon> we can get the timings per worker thread. Simon> The drawbacks of this approach is that we must now define the Simon> parallel task in a separate class and manually capture any context we Simon> need as fields of that class. This seems like a real step backward to me. It's basically replicating lambdas by hand. Why can't parallel_for_each just do this itself? It could take an argument naming the task to pass to the scoped_time_it constructor. The 'task' lambda could instantiate the timer. Simon> + /* The next item to hand out. */ Simon> + std::atomic next = first; This is maybe a bit worrying since IIUC std::atomic only works for trivially copyable types. But this doesn't have to be a general purpose facility, it only has to work for gdb's needs. Tom