From: Simon Marchi <simark@simark.ca>
To: Simon Marchi <simon.marchi@polymtl.ca>,
Tom Tromey <tom@tromey.com>,
Simon Marchi <simon.marchi@efficios.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 3/6] gdbsupport: use dynamic partitioning in gdb::parallel_for_each
Date: Thu, 26 Jun 2025 15:27:49 -0400 [thread overview]
Message-ID: <3a7fcb84-773c-4c08-ac59-23bd6e5a508e@simark.ca> (raw)
In-Reply-To: <2047e4f3-49d3-4dde-991a-8e22bd80c6ef@polymtl.ca>
On 2025-06-13 16:12, Simon Marchi wrote:
> On 6/13/25 3:56 PM, Simon Marchi wrote:
>> On 6/13/25 3:22 PM, Simon Marchi wrote:
>>> Another idea I had (but didn't try) was to make lambdas receive a
>>> "magic" range object, like athis:
>>>
>>> [&] (gdb::dynamic_range<dwarf2_per_cu *> range)
>>> {
>>> for (dwarf2_per_cu *cu : range)
>>> process_unit (cu);
>>> }
>>>
>>> "range" would get work items from the work queue in batches, but yield
>>> one at a time. It would reach its end when the work queue is empty.
>>> It will be a bit of work to implement, but it would have the advantage
>>> that any per-worker state could be right there in the lambda, like we
>>> have today.
>>
>> Ah, I remembered why I didn't do this. It wouldn't play well with how
>> minimal_symbol_reader::install() currently uses gdb::parallel_for_each.
>> Currently, it receives one contiguous range [start,end). After having
>> computed the demangled names and hashes for the whole range, each worker
>> locks a mutex and installs the names in a shared hash table.
>>
>> In my patch, it's similar, but each worker installs the names in the
>> share hash table at the end of each small range it receives.
>>
>> With my "magic" iterator idea, it wouldn't be clear when and how to
>> install the names in the shared hash table.
>
> One way to make this work would be to make the iterator yield batches,
> so you would have two levels of iteration:
>
> [&] (gdb::dynamic_range<minimal_symbol *, 1000> range)
> {
> for (gdb::batch<minimal_symbol *> batch : range)
> {
> for (minimal_symbol *msym : batch)
> {
> // compute demangled name and hash
> }
>
> // lock mutex
>
> for (minimal_symbol *msym : batch)
> {
> // install msym in the shared hash table
> }
> }
> }
>
> Let me know if you see an easier solution to this.
I have thought about this problem some more, and I discussed this with
my team. I still think that the functor approach is the only one that
relatively cleanly meets the various requirements:
- be able to run a per-worker initialize step
- be able to keep some per-worker data for the duration of the for-each
- be able to run a per-worker finalize step
Simon
next prev parent reply other threads:[~2025-06-26 19:28 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-05 20:15 [PATCH 1/6] gdb: re-work parallel-for-selftests.c Simon Marchi
2025-05-05 20:15 ` [PATCH 2/6] gdbsupport: make gdb::parallel_for_each's n parameter a template parameter Simon Marchi
2025-06-13 17:55 ` Tom Tromey
2025-06-13 18:43 ` Simon Marchi
2025-05-05 20:15 ` [PATCH 3/6] gdbsupport: use dynamic partitioning in gdb::parallel_for_each Simon Marchi
2025-06-13 18:29 ` Tom Tromey
2025-06-13 19:22 ` Simon Marchi
2025-06-13 19:56 ` Simon Marchi
2025-06-13 20:12 ` Simon Marchi
2025-06-26 19:27 ` Simon Marchi [this message]
2025-07-03 19:23 ` Tom Tromey
2025-07-03 19:36 ` Simon Marchi
2025-05-05 20:15 ` [PATCH 4/6] gdbsupport: factor out work queue from parallel-for.h Simon Marchi
2025-06-13 18:33 ` Tom Tromey
2025-06-13 19:24 ` Simon Marchi
2025-05-05 20:15 ` [PATCH 5/6] gdbsupport: add async parallel_for_each version Simon Marchi
2025-06-13 18:39 ` Tom Tromey
2025-06-13 19:29 ` Simon Marchi
2025-05-05 20:15 ` [PATCH 6/6] gdb/dwarf: use dynamic partitioning for DWARF CU indexing Simon Marchi
2025-05-27 14:44 ` [PATCH 1/6] gdb: re-work parallel-for-selftests.c Simon Marchi
2025-06-13 17:48 ` Tom Tromey
2025-06-13 18:38 ` Simon Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3a7fcb84-773c-4c08-ac59-23bd6e5a508e@simark.ca \
--to=simark@simark.ca \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@efficios.com \
--cc=simon.marchi@polymtl.ca \
--cc=tom@tromey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox