This is an automated email from the ASF dual-hosted git repository.
maxyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git
The following commit(s) were added to refs/heads/main by this push:
new 27d18ddc6d Remove dead code MPool (#15511)
27d18ddc6d is described below
commit 27d18ddc6dd2df3906a6af08e2516272d3b62791
Author: Yongtao Huang <[email protected]>
AuthorDate: Wed May 10 14:40:58 2023 +0800
Remove dead code MPool (#15511)
Long log:
Since execHHashagg.c and execHHashagg.h were removed
at [commit 19cd1cf4](https://github.com/greenplum-db/gpdb/commit/19cd1cf4)
MPool becomes useless in GPDB.
So mpool.c is dead code now and can be deleted totally.
Co-authored-by: Yongtao Huang <[email protected]>
Co-authored-by: Adam Lee <[email protected]>
---
src/backend/optimizer/prep/prepunion.c | 11 ---
src/backend/utils/mmgr/Makefile | 2 +-
src/backend/utils/mmgr/mpool.c | 162 ---------------------------------
src/include/optimizer/cost.h | 1 -
src/include/optimizer/pathnode.h | 1 -
src/include/utils/memutils.h | 13 ---
6 files changed, 1 insertion(+), 189 deletions(-)
diff --git a/src/backend/optimizer/prep/prepunion.c
b/src/backend/optimizer/prep/prepunion.c
index a31dd14183..5656e4dbcd 100644
--- a/src/backend/optimizer/prep/prepunion.c
+++ b/src/backend/optimizer/prep/prepunion.c
@@ -1180,17 +1180,6 @@ choose_hashed_setop(PlannerInfo *root, List
*groupClauses,
/*
* Don't do it if it doesn't look like the hashtable will fit into
* hash_mem.
- *
- * GPDB: In other places where we are building a Hash Aggregate, we use
- * calcHashAggTableSizes(), which takes into account that in GPDB, a
Hash
- * Aggregate can spill to disk. We must *not* do that here, because we
- * might be building a Hashed SetOp, not a Hash Aggregate. A Hashed
SetOp
- * uses the upstream hash table implementation unmodified, and cannot
- * spill.
- * FIXME: It's a bit lame that Hashed SetOp cannot spill to disk. And
it's
- * even more lame that we don't account the spilling correctly, if we
are
- * in fact constructing a Hash Aggregate. A UNION is implemented with a
- * Hash Aggregate, only INTERSECT and EXCEPT use Hashed SetOp.
*/
hashentrysize = MAXALIGN(input_path->pathtarget->width) +
MAXALIGN(SizeofMinimalTupleHeader);
diff --git a/src/backend/utils/mmgr/Makefile b/src/backend/utils/mmgr/Makefile
index 6b84b8db26..79f116ebdf 100644
--- a/src/backend/utils/mmgr/Makefile
+++ b/src/backend/utils/mmgr/Makefile
@@ -22,6 +22,6 @@ OBJS = \
portalmem.o \
slab.o
-OBJS += mpool.o memprot.o vmem_tracker.o redzone_handler.o runaway_cleaner.o
idle_tracker.o event_version.o
+OBJS += memprot.o vmem_tracker.o redzone_handler.o runaway_cleaner.o
idle_tracker.o event_version.o
include $(top_srcdir)/src/backend/common.mk
diff --git a/src/backend/utils/mmgr/mpool.c b/src/backend/utils/mmgr/mpool.c
deleted file mode 100644
index 3732d59ba0..0000000000
--- a/src/backend/utils/mmgr/mpool.c
+++ /dev/null
@@ -1,162 +0,0 @@
-/*-------------------------------------------------------------------------
- *
- * mpool.c
- * Fast memory pool to manage lots of variable sizes of objects. This
pool
- * does not support free individual objects, but you can release all
- * objects as a whole.
- *
- *-------------------------------------------------------------------------
- */
-
-#include "postgres.h"
-
-#include "utils/memutils.h"
-
-#define PRINT(x) elog x
-#undef PRINT
-#define PRINT(x)
-
-#define MPOOL_BLOCK_SIZE (64 * 1024)
-
-struct MPool
-{
- MemoryContextData *parent;
- MemoryContextData *context;
-
- /*
- * Total number of bytes are allocated through the memory
- * context.
- */
- uint64 total_bytes_allocated;
-
- /* How many bytes are used by the caller. */
- uint64 bytes_used;
-
- /*
- * When a new allocation request arrives, and the current block
- * does not have enough space for this request, we waste those
- * several bytes at the end of the block. This variable stores
- * total number of these wasted bytes.
- */
- uint64 bytes_wasted;
-
- /* The latest allocated block of available space. */
- void *start;
- void *end;
-};
-
-static void
-mpool_init(MPool *mpool)
-{
- Assert(mpool != NULL);
- mpool->total_bytes_allocated = 0;
- mpool->bytes_used = 0;
- mpool->bytes_wasted = 0;
- mpool->start = NULL;
- mpool->end = NULL;
-}
-
-/*
- * Create a MPool object and initialize its variables.
- */
-MPool *
-mpool_create_with_context(MemoryContext parent, MemoryContext context)
-{
- MPool *mpool = MemoryContextAlloc(parent, sizeof(MPool));
- Assert(parent != NULL);
- mpool->parent = parent;
- mpool->context = context;
- mpool_init(mpool);
-
- return mpool;
-}
-
-/*
- * Return a pointer to a space with the given 'size'.
- */
-void *
-mpool_alloc(MPool *mpool, Size size)
-{
- void *alloc_space;
-
- size = MAXALIGN(size);
-
- if (mpool->start == NULL ||
- (char *)mpool->end - (char *)mpool->start < size)
- {
- Size alloc_size;
-
- if (mpool->start != NULL)
- {
- Assert(mpool->end != NULL);
- mpool->bytes_wasted = (char *)mpool->end - (char
*)mpool->start;
- }
-
- alloc_size = MPOOL_BLOCK_SIZE;
-
- if (size > MPOOL_BLOCK_SIZE)
- alloc_size = size;
-
- mpool->start = MemoryContextAlloc(mpool->context, alloc_size);
- mpool->end = (char *)mpool->start + alloc_size;
-
- mpool->total_bytes_allocated += alloc_size;
- }
-
-
- Assert(mpool->start != NULL && mpool->end != NULL &&
- (char *)mpool->end - (char *)mpool->start >= size);
-
- alloc_space = mpool->start;
- mpool->start = (char *)mpool->start + size;
- Assert(mpool->start <= mpool->end);
-
- mpool->bytes_used += size;
-
- return alloc_space;
-}
-
-/*
- * Release all objects in the pool, and reset the memory context.
- */
-void
-mpool_reset(MPool *mpool)
-{
- Assert(mpool != NULL && mpool->context != NULL);
- Assert(MemoryContextIsValid(mpool->context));
-
- elog(DEBUG2, "MPool: total_bytes_allocated=" INT64_FORMAT
- ", bytes_used=" INT64_FORMAT ", bytes_wasted=" INT64_FORMAT,
- mpool->total_bytes_allocated, mpool->bytes_used,
- mpool->bytes_wasted);
-
- MemoryContextReset(mpool->context);
- mpool_init(mpool);
-}
-
-/*
- * Delete the MPool object and its related space.
- */
-void
-mpool_delete(MPool *mpool)
-{
- Assert(mpool != NULL && mpool->context != NULL);
- Assert(MemoryContextIsValid(mpool->context));
-
- mpool_reset(mpool);
- MemoryContextDelete(mpool->context);
- pfree(mpool);
-}
-
-
-uint64 mpool_total_bytes_allocated(MPool *mpool)
-{
- Assert(mpool != NULL);
- return mpool->total_bytes_allocated;
-}
-
-uint64 mpool_bytes_used(MPool *mpool)
-{
- Assert(mpool != NULL);
- return mpool->bytes_used;
-}
diff --git a/src/include/optimizer/cost.h b/src/include/optimizer/cost.h
index c68d57c830..88f07fd5fb 100644
--- a/src/include/optimizer/cost.h
+++ b/src/include/optimizer/cost.h
@@ -152,7 +152,6 @@ extern void cost_tup_split(Path *path, PlannerInfo *root,
int numDQAs,
Cost input_startup_cost,
Cost input_total_cost,
double input_tuples);
-struct HashAggTableSizes; /* defined in execHHashagg.h */
extern void cost_agg(Path *path, PlannerInfo *root,
AggStrategy aggstrategy, const
AggClauseCosts *aggcosts,
int numGroupCols, double numGroups,
diff --git a/src/include/optimizer/pathnode.h b/src/include/optimizer/pathnode.h
index c4d50754c0..daf932c071 100644
--- a/src/include/optimizer/pathnode.h
+++ b/src/include/optimizer/pathnode.h
@@ -258,7 +258,6 @@ extern UpperUniquePath
*create_upper_unique_path(PlannerInfo *root,
Path *subpath,
int numCols,
double numGroups);
-struct HashAggTableSizes; /* defined in execHHashagg.h */
extern AggPath *create_agg_path(PlannerInfo *root,
RelOptInfo *rel,
Path *subpath,
diff --git a/src/include/utils/memutils.h b/src/include/utils/memutils.h
index 88538afa14..a73f2f742f 100644
--- a/src/include/utils/memutils.h
+++ b/src/include/utils/memutils.h
@@ -240,19 +240,6 @@ extern MemoryContext GenerationContextCreate(MemoryContext
parent,
extern void AllocSetTransferAccounting(MemoryContext context,
MemoryContext new_parent);
-/* mpool.c */
-typedef struct MPool MPool;
-extern MPool *mpool_create_with_context(MemoryContext parent, MemoryContext
context);
-
-#define mpool_create(parent, name) \
- (mpool_create_with_context((parent), AllocSetContextCreate((parent),
(name), ALLOCSET_DEFAULT_SIZES)))
-
-extern void *mpool_alloc(MPool *mpool, Size size);
-extern void mpool_reset(MPool *mpool);
-extern void mpool_delete(MPool *mpool);
-extern uint64 mpool_total_bytes_allocated(MPool *mpool);
-extern uint64 mpool_bytes_used(MPool *mpool);
-
/*
* Recommended default alloc parameters, suitable for "ordinary" contexts
* that might hold quite a lot of data.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]