Hi, Does anyone remember why 4096 was chosen for MAXNUMMESSAGES? Are there reasons to keep this particular size today?
I traced 4096 back to the 1999 rewrite, which changed the capacity from 4000 to 4096 [1]. The code explains the benefit of a power of two for ring indexing. Tom's 2008 rewrite kept the capacity and changed how backends catch up and when their caches are reset [2]. Robert later explained how catchup signals and forced resets work [3]. In 2020, Tom was skeptical about making the queue size a GUC [4] and separately mentioned that he had considered increasing it [5]. In the 2023 postgres_fdw investigation, Andres still saw resets with a substantially larger queue [6]. In 2025, Yura Sokolov at Postgres Professional reported that increasing the capacity to 16384 helped avoid full cache resets on a client workload [7]. The recent switch to atomics kept the capacity at 4096 in master [8, 9]. I came across this while investigating workloads that repeatedly create and drop temporary tables. Tantor's release notes document an increase from 16384 to 32768 for that workload [10]. Postgres Professional also mentions enlarging the queue in its 1C:ERP case study [11]. A recent PostgreSQL 18.6 case study measured substantial SInvalWrite contention under similar load [12]. Are there workloads where a larger fixed queue has been shown to hurt performance? Since the catchup and cleanup thresholds are derived from MAXNUMMESSAGES, I'm particularly interested in any comparisons that held those thresholds constant. Thanks, [1] https://github.com/postgres/postgres/commit/22fe3d4b0425fee1af0147a57e05aad70c3badd7 [2] https://postgr.es/m/[email protected] [3] https://www.postgresql.org/message-id/CA%2BTgmoaGzZL8P_CNO%2BUPpuOzeq8RHihXmRynrjAu72eFAoX40Q%40mail.gmail.com [4] https://postgr.es/m/[email protected] [5] https://postgr.es/m/[email protected] [6] https://postgr.es/m/[email protected] [7] https://www.postgresql.org/message-id/7f312548-23b3-4893-a34a-f904a0f3a674%40postgrespro.ru [8] https://commitfest.postgresql.org/patch/7001/ [9] https://github.com/postgres/postgres/blob/master/src/backend/storage/ipc/sinvaladt.c#L95-L123 [10] https://docs.tantorlabs.ru/tdb/en/17_12/se/release_17_6_0.html [11] https://habr.com/ru/companies/postgrespro/articles/1093472/ (in Russian) [12] https://postgres.ai/blog/20261118-hidden-costs-of-create-temp-table -- Ilya Staroverov
