Re: Parallel threads in query

Поиск
Список
Период
Сортировка
От Tomas Vondra
Тема Re: Parallel threads in query
Дата
Msg-id d12fea78-87db-4951-e880-44851fedfd13@2ndquadrant.com
обсуждение исходный текст
Ответ на Re: Parallel threads in query  (Darafei "Komяpa" Praliaskouski <me@komzpa.net>)
Список pgsql-hackers
On 11/01/2018 07:43 PM, Darafei "Komяpa" Praliaskouski wrote:
>     In theory, simulating such global limit should be possible using a bit
>     of shared memory for the current total, per-process counter and probably
>     some simple abort handling (say, just like contrib/openssl does using
>     ResourceOwner).
> 
> 
> I would expect that this limit is already available and it's parallel
> worker limit. Basically, when start a new thread I would like to somehow
> consume a part of parallel worker limit - a thread is a kind of parallel
> worker, from user's perspective. If I have 4 cores and Postgres already
> started 4 parallel workers, I don't really want to start 4 threads for
> each of them, or 4 for one of them and 1 for each of the rest, if I
> manage that separately from parallel worker limit.
> 

Well, PostgreSQL does that, but only for the process-based parallelism.
It has no idea about threads, so it can't work out of the box. Also, the
max_worker_processes limit determines various shared memory we need to
manage those processes, so it's really not about threads.

If you need something like that for threads, feel free to do that, but
I'd strongly suggest using a separate counter (perhaps using a m_w_p as
an initial value).

> IPC and co - that's another question and out of scope for this one.
> Since OpenMP allows to write multithreaded code by just adding more
> #pragma around loops, I don't want to reinvent that part of infrastructure.

Maybe. I don't know OpenMP that well, so I can't really safe if that's a
good idea or not.

regards

-- 
Tomas Vondra                  http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tomas Vondra
Дата:
Сообщение: Re: Parallel threads in query
Следующее
От: Andres Freund
Дата:
Сообщение: Re: Parallel threads in query