Re: Increase of maintenance_work_mem limit in 64-bit Windows

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Пополитов Владлен <v(dot)popolitov(at)postgrespro(dot)ru>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Increase of maintenance_work_mem limit in 64-bit Windows
Date: 2024-09-23 01:28:47
Message-ID: CAApHDvrQPz_Dsm=k=6Zo044FtKNS6_CagPkWJwS1Lw7Lqm57_w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, 20 Sept 2024 at 01:55, Пополитов Владлен
<v(dot)popolitov(at)postgrespro(dot)ru> wrote:
> Currently PostgreSQL built on 64-bit Windows has 2Gb limit for
> GUC variables due to sizeof(long)==4 used by Windows compilers.
> Technically 64-bit addressing for maintenance_work_mem is possible,
> but code base historically uses variables and constants of type "long",
> when process maintenance_work_mem value.

I agree. Ideally, we shouldn't use longs for anything ever. We should
likely adopt trying to remove the usages of them when possible.

I'd like to suggest you go about this patch slightly differently with
the end goal of removing the limitation from maintenance_work_mem,
work_mem, autovacuum_work_mem and logical_decoding_work_mem.

Patch 0001: Add a macro named something like WORK_MEM_KB_TO_BYTES()
and adjust all places where we do <work_mem_var> * 1024L to use this
new macro. Make the macro do the * 1024L as is done today so that this
patch is a simple refactor.
Patch 0002: Convert all places that use long and use Size instead.
Adjust WORK_MEM_KB_TO_BYTES to use a Size type rather than 1024L.

It might be wise to break 0002 down into individual GUCs as the patch
might become large.

I suspect we might have quite a large number of subtle bugs in our
code today due to using longs. 7340d9362 is an example of one that was
fixed recently.

David

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message jian he 2024-09-23 01:39:00 Re: Relcache refactoring
Previous Message David Rowley 2024-09-23 01:05:37 Re: [PATCH] Add min/max aggregate functions to BYTEA