Some shared memory chunks are allocated even if related processes won't start

Поиск
Список
Период
Сортировка
От Hayato Kuroda (Fujitsu)
Тема Some shared memory chunks are allocated even if related processes won't start
Дата
Msg-id TYCPR01MB12077BFDFBC142086D424FDFEF5232@TYCPR01MB12077.jpnprd01.prod.outlook.com
обсуждение исходный текст
Ответы Re: Some shared memory chunks are allocated even if related processes won't start  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: Some shared memory chunks are allocated even if related processes won't start  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
Список pgsql-hackers
Dear hackers,

While reading codes, I found that ApplyLauncherShmemInit() and AutoVacuumShmemInit()
are always called even if they would not be launched.
It may be able to reduce the start time to avoid the unnecessary allocation.
However, I know this improvement would be quite small because the allocated chunks are
quite small.

Anyway, there are several ways to fix:

1)
Skip calling ShmemInitStruct() if the related process would not be launched.
I think this approach is the easiest way. E.g.,

```
--- a/src/backend/replication/logical/launcher.c
+++ b/src/backend/replication/logical/launcher.c
@@ -962,6 +962,9 @@ ApplyLauncherShmemInit(void)
 {
     bool        found;

+    if (max_logical_replication_workers == 0 || IsBinaryUpgrade)
+        return;
+
```

2)
Dynamically allocate the shared memory. This was allowed by recent commit [1].
I made a small PoC only for logical launcher to show what I meant. PSA diff file.
Since some processes (backend, apply worker, parallel apply worker, and tablesync worker)
refers the chunk, codes for attachment must be added on the several places.

If you agree it should be fixed, I will create a patch. Thought?

[1]: https://github.com/postgres/postgres/commit/8b2bcf3f287c79eaebf724cba57e5ff664b01e06

Best Regards,
Hayato Kuroda
FUJITSU LIMITED
https://www.fujitsu.com/


Вложения

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

Предыдущее
От: Amul Sul
Дата:
Сообщение: Re: PostgreSQL Contributors Updates
Следующее
От: Michael Paquier
Дата:
Сообщение: Re: Injection points: some tools to wait and wake