git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6d2fd66)
Update mmgr's README to mention BumpContext
2024年4月16日 22:49:09 +0000 (10:49 +1200)
2024年4月16日 22:49:09 +0000 (10:49 +1200)
Oversight in 29f6a959c.

In passing, since we now have 4 memory context types to choose from,
provide a brief overview of the specialities of each memory context
type.

Reported-by: Amul Sul
Author: Amul Sul, David Rowley
Discussion: https://postgr.es/m/CAAJ_b94U2s9nHh--DEK=sPEZUQ+x7vQJ7529fF8UAH97QJ9NXg@mail.gmail.com


diff --git a/src/backend/utils/mmgr/README b/src/backend/utils/mmgr/README
index f484f7d6f5b233ce2f1b0fedd20b91fd2932a3eb..695088bb66daef1a55b4014b55ef03ac61f6c30d 100644 (file)
--- a/src/backend/utils/mmgr/README
+++ b/src/backend/utils/mmgr/README
@@ -471,25 +471,32 @@ thrashing.
Alternative Memory Context Implementations
------------------------------------------
-aset.c is our default general-purpose implementation, working fine
-in most situations. We also have two implementations optimized for
-special use cases, providing either better performance or lower memory
-usage compared to aset.c (or both).
-
-* slab.c (SlabContext) is designed for allocations of fixed-length
- chunks, and does not allow allocations of chunks with different size.
-
-* generation.c (GenerationContext) is designed for cases when chunks
- are allocated in groups with similar lifespan (generations), or
- roughly in FIFO order.
-
-Both memory contexts aim to free memory back to the operating system
-(unlike aset.c, which keeps the freed chunks in a freelist, and only
-returns the memory when reset/deleted).
-
-These memory contexts were initially developed for ReorderBuffer, but
-may be useful elsewhere as long as the allocation patterns match.
-
+aset.c (AllocSetContext) is our default general-purpose allocator. Three other
+allocator types also exist which are special-purpose:
+
+* slab.c (SlabContext) is designed for allocations of fixed-sized
+ chunks. The fixed chunk size must be specified when creating the context.
+ New chunks are allocated to the fullest block, keeping used chunks densely
+ packed together to avoid memory fragmentation. This also increases the
+ chances that pfree'ing a chunk will result in a block becoming empty of all
+ chunks and allow it to be free'd back to the operating system.
+
+* generation.c (GenerationContext) is best suited for cases when chunks are
+ allocated in groups with similar lifespan (generations), or roughly in FIFO
+ order. No attempt is made to reuse space left by pfree'd chunks. Blocks
+ are returned to the operating system when all chunks on them have been
+ pfree'd.
+
+* bump.c (BumpContext) is best suited for use cases that require densely
+ allocated chunks of memory that never need to be individually pfree'd or
+ repalloc'd. These operations are unsupported due to BumpContext chunks
+ having no chunk header. No chunk header means more densely packed chunks,
+ which is especially useful for workloads that perform lots of small
+ allocations. Blocks are only free'd back to the operating system when the
+ context is reset or deleted.
+
+For further details, please read the header comment in the corresponding .c
+file.
Memory Accounting
-----------------
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /