Re: simple patch for discussion

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Greg Hennessy <greg(dot)hennessy(at)gmail(dot)com>
Cc: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: simple patch for discussion
Date: 2025-07-23 00:48:54
Message-ID: CAApHDvpBg83A-=+QycCE_B4Jjoiz+A1UmSos-W-FmpFE_uQ5Zw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, 21 Jul 2025 at 06:27, Greg Hennessy <greg(dot)hennessy(at)gmail(dot)com> wrote:
> test=# show parallel_worker_algorithm ;
> parallel_worker_algorithm
> ---------------------------
> log3
> (1 row)

I don't think having a GUC which allows exactly two settings is
anywhere near as flexible as you could make this. You're complaining
that the current calculation isn't ideal for you and are proposing a
new one which seemingly is more to your liking, but who's to say that
someone else would find either useful? With this method, if someone
else comes along complaining, do we give them what they want by adding
a new enum? That does not sound great :(

One thought I had was that you could adjust the "divide by 3" to be
"divide by <some_new_GUC>" and make that calculation floating point.
For people who want really aggressive scaling, that could set it to
something a little over 1.0. The problem with that is numbers really
close to 1.0 would cause that loop to iterate an excessive number of
times and that would be bad for performance.

On rethink, maybe you can use the log() function to get something
close to what's being generated today. The fact that the
heap_parallel_threshold is taken into account makes that a little
tricky as it's not a simple log3. I experimented with the attached .c
file. When I set the GUC to 3.0, it's pretty close to what we get
today. If I drop it to 1.01, I get something closer to your version.

Do you want to play around with the code in the attached .c file and
add a GUC like the parallel_worker_scaling_logarithm I have in the .c
file? Feel free to tweak the algorithm. I won't pretend it's the best
it can be. I didn't spend much time on it. There might be a better way
to get numbers closer to what we have today that takes into account
the (heap|index)_parallel_threshold and doesn't need a while loop.

David

Attachment Content-Type Size
parallel_workers.c text/plain 1.3 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2025-07-23 00:50:04 Re: index prefetching
Previous Message Peter Geoghegan 2025-07-23 00:39:35 Re: index prefetching