From 7bae3bbf62d63cdd49ae4ca4a851cef0cdbe6ab5 Mon Sep 17 00:00:00 2001 From: Thomas Munro Date: Thu, 14 Jul 2022 22:52:13 +1200 Subject: [PATCH] Create a distinct wait event for POSIX DSM allocation. Previously we displayed "DSMFillZeroWrite" while in posix_fallocate(), because we shared the same wait event for "mmap" and "posix" DSM types. Let's introduce a new wait event "DSMAllocate", to be more accurate. Reported-by: Andres Freund Discussion: https://postgr.es/m/20220711174518.yldckniicknsxgzl%40awork3.anarazel.de --- doc/src/sgml/monitoring.sgml | 5 +++++ src/backend/storage/ipc/dsm_impl.c | 2 +- src/backend/utils/activity/wait_event.c | 3 +++ src/include/utils/wait_event.h | 1 + 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/monitoring.sgml b/doc/src/sgml/monitoring.sgml index 4549c2560e..f2066e5f0f 100644 --- a/doc/src/sgml/monitoring.sgml +++ b/doc/src/sgml/monitoring.sgml @@ -1296,6 +1296,11 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser CopyFileWrite Waiting for a write during a file copy operation. + + DSMAllocate + Waiting for a dynamic shared memory segment to be + allocated. + DSMFillZeroWrite Waiting to fill a dynamic shared memory backing file with diff --git a/src/backend/storage/ipc/dsm_impl.c b/src/backend/storage/ipc/dsm_impl.c index 6f21a75775..258d47bcfa 100644 --- a/src/backend/storage/ipc/dsm_impl.c +++ b/src/backend/storage/ipc/dsm_impl.c @@ -364,7 +364,7 @@ dsm_impl_posix_resize(int fd, off_t size) */ PG_SETMASK(&BlockSig); - pgstat_report_wait_start(WAIT_EVENT_DSM_FILL_ZERO_WRITE); + pgstat_report_wait_start(WAIT_EVENT_DSM_ALLOCATE); #if defined(HAVE_POSIX_FALLOCATE) && defined(__linux__) /* * On Linux, a shm_open fd is backed by a tmpfs file. If we were to use diff --git a/src/backend/utils/activity/wait_event.c b/src/backend/utils/activity/wait_event.c index 87c15b9c6f..da57a93034 100644 --- a/src/backend/utils/activity/wait_event.c +++ b/src/backend/utils/activity/wait_event.c @@ -585,6 +585,9 @@ pgstat_get_wait_io(WaitEventIO w) case WAIT_EVENT_DATA_FILE_WRITE: event_name = "DataFileWrite"; break; + case WAIT_EVENT_DSM_ALLOCATE: + event_name = "DSMAllocate"; + break; case WAIT_EVENT_DSM_FILL_ZERO_WRITE: event_name = "DSMFillZeroWrite"; break; diff --git a/src/include/utils/wait_event.h b/src/include/utils/wait_event.h index b578e2ec75..c3ade01120 100644 --- a/src/include/utils/wait_event.h +++ b/src/include/utils/wait_event.h @@ -178,6 +178,7 @@ typedef enum WAIT_EVENT_DATA_FILE_SYNC, WAIT_EVENT_DATA_FILE_TRUNCATE, WAIT_EVENT_DATA_FILE_WRITE, + WAIT_EVENT_DSM_ALLOCATE, WAIT_EVENT_DSM_FILL_ZERO_WRITE, WAIT_EVENT_LOCK_FILE_ADDTODATADIR_READ, WAIT_EVENT_LOCK_FILE_ADDTODATADIR_SYNC,