Re: Increase of maintenance_work_mem limit in 64-bit Windows - Mailing list pgsql-hackers

From David Rowley
Subject Re: Increase of maintenance_work_mem limit in 64-bit Windows
Date
Msg-id CAApHDvrQPz_Dsm=k=6Zo044FtKNS6_CagPkWJwS1Lw7Lqm57_w@mail.gmail.com
Whole thread Raw
Responses Re: Increase of maintenance_work_mem limit in 64-bit Windows
List pgsql-hackers
On Fri, 20 Sept 2024 at 01:55, Пополитов Владлен
<v.popolitov@postgrespro.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



pgsql-hackers by date:

Previous
From: David Rowley
Date:
Subject: Re: [PATCH] Add min/max aggregate functions to BYTEA
Next
From: jian he
Date:
Subject: Re: Relcache refactoring