aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils
diff options
context:
space:
mode:
authorDavid Rowley <drowley@postgresql.org>2024-04-17 10:40:31 +1200
committerDavid Rowley <drowley@postgresql.org>2024-04-17 10:40:31 +1200
commit6d2fd66b9908d1557d7e49b1bdb4c597192f3729 (patch)
tree37a7811500896042b4353f97b1284a1618a3dcd3 /src/backend/utils
parent2ea5d8bece85518b4b8c052ff134c294c21543e0 (diff)
downloadpostgresql-6d2fd66b9908d1557d7e49b1bdb4c597192f3729.tar.gz
postgresql-6d2fd66b9908d1557d7e49b1bdb4c597192f3729.zip
Push dedicated BumpBlocks to the tail of the blocks list
BumpContext relies on using the head block from its 'blocks' field to use as the current block to allocate new chunks to. When we receive an allocation request larger than allocChunkLimit, we place these chunks on a new dedicated block and, until now, we pushed the block onto the *head* of the 'blocks' list. This behavior caused the previous bump block to no longer be available for new normal-sized (non-large) allocations and would result in blocks only being partially filled if a large allocation request arrived before the block became full. Here adjust the code to push these dedicated blocks onto the *tail* of the blocks list so that the head block remains intact and available to be used by normal allocation request sizes until it becomes full. In passing, make the elog(ERROR) calls for the unsupported callbacks consistent. Likewise for the header comments for those functions. Discussion: https://postgr.es/m/CAApHDvp9___r-ayJj0nZ6GD3MeCGwGZ0_6ZptWpwj+zqHtmwCw@mail.gmail.com Discussion: https://postgr.es/m/CAApHDvqerXpzUnuDQfUEi3DZA+9=Ud9WSt3ruxN5b6PcOosx2g@mail.gmail.com
Diffstat (limited to 'src/backend/utils')
-rw-r--r--src/backend/utils/mmgr/bump.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/backend/utils/mmgr/bump.c b/src/backend/utils/mmgr/bump.c
index 449bd293448..a98bafbcc03 100644
--- a/src/backend/utils/mmgr/bump.c
+++ b/src/backend/utils/mmgr/bump.c
@@ -342,8 +342,12 @@ BumpAllocLarge(MemoryContext context, Size size, int flags)
randomize_mem((char *) MemoryChunkGetPointer(chunk), size);
#endif
- /* add the block to the list of allocated blocks */
- dlist_push_head(&set->blocks, &block->node);
+ /*
+ * Add the block to the tail of allocated blocks list. The current block
+ * is left at the head of the list as it may still have space for
+ * non-large allocations.
+ */
+ dlist_push_tail(&set->blocks, &block->node);
#ifdef MEMORY_CONTEXT_CHECKING
/* Ensure any padding bytes are marked NOACCESS. */
@@ -612,7 +616,7 @@ BumpBlockFree(BumpContext *set, BumpBlock *block)
void
BumpFree(void *pointer)
{
- elog(ERROR, "pfree is not supported by the bump memory allocator");
+ elog(ERROR, "%s is not supported by the bump memory allocator", "pfree");
}
/*
@@ -638,10 +642,9 @@ BumpGetChunkContext(void *pointer)
}
/*
-* BumpGetChunkSpace
-* Given a currently-allocated chunk, determine the total space
-* it occupies (including all memory-allocation overhead).
-*/
+ * BumpGetChunkSpace
+ * Unsupported.
+ */
Size
BumpGetChunkSpace(void *pointer)
{