pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Recompute allocChunkLimit when reusing an AllocSet context
7+ messages / 1 participants
[nested] [flat]

* pgsql: Recompute allocChunkLimit when reusing an AllocSet context
@ 2026-10-19 06:42 David Rowley <drowley@postgresql.org>
  0 siblings, 0 replies; 7+ messages in thread

From: David Rowley @ 2026-10-19 06:42 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Recompute allocChunkLimit when reusing an AllocSet context

AllocSet contexts with different maxBlockSize values can have the same
freeListIndex.  When reusing a context from one of the context_freelists,
we updated maxBlockSize, but we failed to adjust allocChunkLimit, even
though that ordinarily depends on maxBlockSize.  This could result in
some allocations being put on an external block when they shouldn't have
been, resulting in excessive malloc() calls, or if the allocChunkLimit was
left set higher than it should be, allocations could have resulted in
memory not being free()'d after pfree() due to the chunk having been put
on a multi-chunk block (these would still later be cleaned up when the
context is reset, so no memory leaks).

The repercussions of this are only inefficient use of memory and perhaps
some performance instability depending on which context happened to be
top of the freelist when a new AllocSet context was created.

To fix, we move the allocChunkLimit calculation code into a helper
function and call that to reset the allocChunkLimit when reusing a
context.

Author: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Donghang Lin <donghanglin@gmail.com>
Reviewed-by: David Rowley <dgrowleyml@gmail.com>
Discussion: https://postgr.es/m/1D54961E-6BEF-411A-BFAD-610C3B18D7E7@gmail.com
Backpatch-through: 14

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/7b84cf8cfc7935d9ef275ea425c7bbd6e40b8c90

Modified Files
--------------
src/backend/utils/mmgr/aset.c | 75 +++++++++++++++++++++++++++++--------------
1 file changed, 51 insertions(+), 24 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Recompute allocChunkLimit when reusing an AllocSet context
@ 2026-10-19 06:43 David Rowley <drowley@postgresql.org>
  0 siblings, 0 replies; 7+ messages in thread

From: David Rowley @ 2026-10-19 06:43 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Recompute allocChunkLimit when reusing an AllocSet context

AllocSet contexts with different maxBlockSize values can have the same
freeListIndex.  When reusing a context from one of the context_freelists,
we updated maxBlockSize, but we failed to adjust allocChunkLimit, even
though that ordinarily depends on maxBlockSize.  This could result in
some allocations being put on an external block when they shouldn't have
been, resulting in excessive malloc() calls, or if the allocChunkLimit was
left set higher than it should be, allocations could have resulted in
memory not being free()'d after pfree() due to the chunk having been put
on a multi-chunk block (these would still later be cleaned up when the
context is reset, so no memory leaks).

The repercussions of this are only inefficient use of memory and perhaps
some performance instability depending on which context happened to be
top of the freelist when a new AllocSet context was created.

To fix, we move the allocChunkLimit calculation code into a helper
function and call that to reset the allocChunkLimit when reusing a
context.

Author: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Donghang Lin <donghanglin@gmail.com>
Reviewed-by: David Rowley <dgrowleyml@gmail.com>
Discussion: https://postgr.es/m/1D54961E-6BEF-411A-BFAD-610C3B18D7E7@gmail.com
Backpatch-through: 14

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/16dd90902366c0404616dc43b170c94b064d0caf

Modified Files
--------------
src/backend/utils/mmgr/aset.c | 75 +++++++++++++++++++++++++++++--------------
1 file changed, 51 insertions(+), 24 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Recompute allocChunkLimit when reusing an AllocSet context
@ 2026-10-19 06:43 David Rowley <drowley@postgresql.org>
  0 siblings, 0 replies; 7+ messages in thread

From: David Rowley @ 2026-10-19 06:43 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Recompute allocChunkLimit when reusing an AllocSet context

AllocSet contexts with different maxBlockSize values can have the same
freeListIndex.  When reusing a context from one of the context_freelists,
we updated maxBlockSize, but we failed to adjust allocChunkLimit, even
though that ordinarily depends on maxBlockSize.  This could result in
some allocations being put on an external block when they shouldn't have
been, resulting in excessive malloc() calls, or if the allocChunkLimit was
left set higher than it should be, allocations could have resulted in
memory not being free()'d after pfree() due to the chunk having been put
on a multi-chunk block (these would still later be cleaned up when the
context is reset, so no memory leaks).

The repercussions of this are only inefficient use of memory and perhaps
some performance instability depending on which context happened to be
top of the freelist when a new AllocSet context was created.

To fix, we move the allocChunkLimit calculation code into a helper
function and call that to reset the allocChunkLimit when reusing a
context.

Author: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Donghang Lin <donghanglin@gmail.com>
Reviewed-by: David Rowley <dgrowleyml@gmail.com>
Discussion: https://postgr.es/m/1D54961E-6BEF-411A-BFAD-610C3B18D7E7@gmail.com
Backpatch-through: 14

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/9ba69ffcc4bc3e4cd7dd215f42e3a887c77d0b27

Modified Files
--------------
src/backend/utils/mmgr/aset.c | 88 ++++++++++++++++++++++++++++---------------
1 file changed, 57 insertions(+), 31 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Recompute allocChunkLimit when reusing an AllocSet context
@ 2026-10-19 06:44 David Rowley <drowley@postgresql.org>
  0 siblings, 0 replies; 7+ messages in thread

From: David Rowley @ 2026-10-19 06:44 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Recompute allocChunkLimit when reusing an AllocSet context

AllocSet contexts with different maxBlockSize values can have the same
freeListIndex.  When reusing a context from one of the context_freelists,
we updated maxBlockSize, but we failed to adjust allocChunkLimit, even
though that ordinarily depends on maxBlockSize.  This could result in
some allocations being put on an external block when they shouldn't have
been, resulting in excessive malloc() calls, or if the allocChunkLimit was
left set higher than it should be, allocations could have resulted in
memory not being free()'d after pfree() due to the chunk having been put
on a multi-chunk block (these would still later be cleaned up when the
context is reset, so no memory leaks).

The repercussions of this are only inefficient use of memory and perhaps
some performance instability depending on which context happened to be
top of the freelist when a new AllocSet context was created.

To fix, we move the allocChunkLimit calculation code into a helper
function and call that to reset the allocChunkLimit when reusing a
context.

Author: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Donghang Lin <donghanglin@gmail.com>
Reviewed-by: David Rowley <dgrowleyml@gmail.com>
Discussion: https://postgr.es/m/1D54961E-6BEF-411A-BFAD-610C3B18D7E7@gmail.com
Backpatch-through: 14

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/63de1f8fa42060e10326d2d9a0d48e559594ab86

Modified Files
--------------
src/backend/utils/mmgr/aset.c | 88 ++++++++++++++++++++++++++++---------------
1 file changed, 57 insertions(+), 31 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Recompute allocChunkLimit when reusing an AllocSet context
@ 2026-10-19 06:44 David Rowley <drowley@postgresql.org>
  0 siblings, 0 replies; 7+ messages in thread

From: David Rowley @ 2026-10-19 06:44 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Recompute allocChunkLimit when reusing an AllocSet context

AllocSet contexts with different maxBlockSize values can have the same
freeListIndex.  When reusing a context from one of the context_freelists,
we updated maxBlockSize, but we failed to adjust allocChunkLimit, even
though that ordinarily depends on maxBlockSize.  This could result in
some allocations being put on an external block when they shouldn't have
been, resulting in excessive malloc() calls, or if the allocChunkLimit was
left set higher than it should be, allocations could have resulted in
memory not being free()'d after pfree() due to the chunk having been put
on a multi-chunk block (these would still later be cleaned up when the
context is reset, so no memory leaks).

The repercussions of this are only inefficient use of memory and perhaps
some performance instability depending on which context happened to be
top of the freelist when a new AllocSet context was created.

To fix, we move the allocChunkLimit calculation code into a helper
function and call that to reset the allocChunkLimit when reusing a
context.

Author: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Donghang Lin <donghanglin@gmail.com>
Reviewed-by: David Rowley <dgrowleyml@gmail.com>
Discussion: https://postgr.es/m/1D54961E-6BEF-411A-BFAD-610C3B18D7E7@gmail.com
Backpatch-through: 14

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/2b26e3622142d5693fd6bc8525dadfbd54367547

Modified Files
--------------
src/backend/utils/mmgr/aset.c | 88 ++++++++++++++++++++++++++++---------------
1 file changed, 57 insertions(+), 31 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Recompute allocChunkLimit when reusing an AllocSet context
@ 2026-10-19 06:44 David Rowley <drowley@postgresql.org>
  0 siblings, 0 replies; 7+ messages in thread

From: David Rowley @ 2026-10-19 06:44 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Recompute allocChunkLimit when reusing an AllocSet context

AllocSet contexts with different maxBlockSize values can have the same
freeListIndex.  When reusing a context from one of the context_freelists,
we updated maxBlockSize, but we failed to adjust allocChunkLimit, even
though that ordinarily depends on maxBlockSize.  This could result in
some allocations being put on an external block when they shouldn't have
been, resulting in excessive malloc() calls, or if the allocChunkLimit was
left set higher than it should be, allocations could have resulted in
memory not being free()'d after pfree() due to the chunk having been put
on a multi-chunk block (these would still later be cleaned up when the
context is reset, so no memory leaks).

The repercussions of this are only inefficient use of memory and perhaps
some performance instability depending on which context happened to be
top of the freelist when a new AllocSet context was created.

To fix, we move the allocChunkLimit calculation code into a helper
function and call that to reset the allocChunkLimit when reusing a
context.

Author: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Donghang Lin <donghanglin@gmail.com>
Reviewed-by: David Rowley <dgrowleyml@gmail.com>
Discussion: https://postgr.es/m/1D54961E-6BEF-411A-BFAD-610C3B18D7E7@gmail.com
Backpatch-through: 14

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/440ee5bb1ddc8b23794200720efba17b8a4a44d1

Modified Files
--------------
src/backend/utils/mmgr/aset.c | 77 +++++++++++++++++++++++++++++--------------
1 file changed, 52 insertions(+), 25 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* pgsql: Recompute allocChunkLimit when reusing an AllocSet context
@ 2026-10-19 08:03 David Rowley <drowley@postgresql.org>
  0 siblings, 0 replies; 7+ messages in thread

From: David Rowley @ 2026-10-19 08:03 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Recompute allocChunkLimit when reusing an AllocSet context

AllocSet contexts with different maxBlockSize values can have the same
freeListIndex.  When reusing a context from one of the context_freelists,
we updated maxBlockSize, but we failed to adjust allocChunkLimit, even
though that ordinarily depends on maxBlockSize.  This could result in
some allocations being put on an external block when they shouldn't have
been, resulting in excessive malloc() calls, or if the allocChunkLimit was
left set higher than it should be, allocations could have resulted in
memory not being free()'d after pfree() due to the chunk having been put
on a multi-chunk block (these would still later be cleaned up when the
context is reset, so no memory leaks).

The repercussions of this are only inefficient use of memory and perhaps
some performance instability depending on which context happened to be
top of the freelist when a new AllocSet context was created.

To fix, we move the allocChunkLimit calculation code into a helper
function and call that to reset the allocChunkLimit when reusing a
context.

Author: Chao Li <li.evan.chao@gmail.com>
Reviewed-by: Donghang Lin <donghanglin@gmail.com>
Reviewed-by: David Rowley <dgrowleyml@gmail.com>
Discussion: https://postgr.es/m/1D54961E-6BEF-411A-BFAD-610C3B18D7E7@gmail.com
Backpatch-through: 14

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/b1abfa33649ccd2d6dff20be94752097532862bb

Modified Files
--------------
src/backend/utils/mmgr/aset.c | 77 +++++++++++++++++++++++++++++--------------
1 file changed, 52 insertions(+), 25 deletions(-)



^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2026-10-19 08:03 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-10-19 06:42 pgsql: Recompute allocChunkLimit when reusing an AllocSet context David Rowley <drowley@postgresql.org>
2026-10-19 06:43 pgsql: Recompute allocChunkLimit when reusing an AllocSet context David Rowley <drowley@postgresql.org>
2026-10-19 06:43 pgsql: Recompute allocChunkLimit when reusing an AllocSet context David Rowley <drowley@postgresql.org>
2026-10-19 06:44 pgsql: Recompute allocChunkLimit when reusing an AllocSet context David Rowley <drowley@postgresql.org>
2026-10-19 06:44 pgsql: Recompute allocChunkLimit when reusing an AllocSet context David Rowley <drowley@postgresql.org>
2026-10-19 06:44 pgsql: Recompute allocChunkLimit when reusing an AllocSet context David Rowley <drowley@postgresql.org>
2026-10-19 08:03 pgsql: Recompute allocChunkLimit when reusing an AllocSet context David Rowley <drowley@postgresql.org>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox