提交 37f13596 编写于 作者: H Heikki Linnakangas

Remove incomplete memory tracking code from htfifo.

It was dead code, and we have no plans to resurrect it.
Reviewed-by: NPengzhou Tang <ptang@pivotal.io>
Reviewed-by: NGang Xiong <gxiong@pivotal.io>
上级 fbd50c90
......@@ -303,7 +303,7 @@ InitMotionLayerNode(MotionLayerState *mlStates, int16 motNodeID)
* This function is called from: ExecInitMotion()
*/
void
UpdateMotionLayerNode(MotionLayerState *mlStates, int16 motNodeID, bool preserveOrder, TupleDesc tupDesc, uint64 operatorMemKB)
UpdateMotionLayerNode(MotionLayerState *mlStates, int16 motNodeID, bool preserveOrder, TupleDesc tupDesc)
{
MemoryContext oldCtxt;
MotionNodeEntry *pEntry;
......@@ -342,14 +342,10 @@ UpdateMotionLayerNode(MotionLayerState *mlStates, int16 motNodeID, bool preserve
pEntry->tuple_desc = CreateTupleDescCopy(tupDesc);
InitSerTupInfo(pEntry->tuple_desc, &pEntry->ser_tup_info);
pEntry->memKB = operatorMemKB;
if (!preserveOrder)
{
Assert(pEntry->memKB > 0);
/* Create a tuple-store for the motion node's incoming tuples. */
pEntry->ready_tuples = htfifo_create(pEntry->memKB);
pEntry->ready_tuples = htfifo_create();
}
else
pEntry->ready_tuples = NULL;
......@@ -1042,8 +1038,7 @@ getChunkSorterEntry(MotionLayerState *mlStates,
*/
if (motNodeEntry->preserve_order)
{
Assert(motNodeEntry->memKB > 0);
chunkSorterEntry->ready_tuples = htfifo_create(motNodeEntry->memKB);
chunkSorterEntry->ready_tuples = htfifo_create();
#ifdef AMS_VERBOSE_LOGGING
elog(DEBUG5, "Motion node %d is order-preserving. Creating tuple-store for entry [src=%d,mn=%d].",
......
......@@ -26,64 +26,22 @@ static void htfifo_cleanup(htup_fifo htf);
/*
* Create and initialize a HeapTuple FIFO. The FIFO state is allocated
* by this function, then initialized and returned.
*
* The HeapTuple FIFO must be given at least MIN_HTUPFIFO_KB bytes of
* space to work with. Anything less will be trapped as an
* assert-failure.
*
* Parameters:
* max_mem_kb - The maximum memory size the FIFO can grow to, in
* kilobytes. If the FIFO grows larger than this, an error is
* logged.
*
* XXX: THIS MEMORY PARAMETER IS COMPLETELY IGNORED!
*/
htup_fifo
htfifo_create(int max_mem_kb)
htfifo_create(void)
{
htup_fifo htf;
htf = (htup_fifo) palloc(sizeof(htup_fifo_state));
htfifo_init(htf, max_mem_kb);
return htf;
}
/*
* Initialize a HeapTuple FIFO. The FIFO state is already allocated before
* this function is called, but it is assumed that its contents are
* uninitialized.
*
* The HeapTuple FIFO must be given at least MIN_HTUPFIFO_KB bytes of space
* to work with. Anything less will be trapped as an assert-failure.
*
* Parameters:
*
* htf - An uninitialized pointer to a htup_fifo_state structure.
*
* XXX: THIS MEMORY PARAMETER IS COMPLETELY IGNORED!
* max_mem_kb - The maximum memory size the FIFO can grow to, in
* kilobytes. If the FIFO grows larger than this, an error is logged.
*/
void
htfifo_init(htup_fifo htf, int max_mem_kb)
{
AssertArg(htf != NULL);
AssertArg(max_mem_kb > MIN_HTUPFIFO_KB);
htf->p_first = NULL;
htf->p_last = NULL;
htf->freelist = NULL;
htf->freelist_count = 0;
htf->tup_count = 0;
htf->curr_mem_size = 0;
htf->max_mem_size = max_mem_kb * 1024;
return htf;
}
/*
* Clean up a HeapTuple FIFO. This frees all dynamically-allocated
* contents of the FIFO, but not the FIFO state itself.
......@@ -111,9 +69,6 @@ htfifo_cleanup(htup_fifo htf)
htf->p_first = NULL;
htf->p_last = NULL;
htf->tup_count = 0;
htf->curr_mem_size = 0;
htf->max_mem_size = 0;
}
/*
......@@ -178,11 +133,6 @@ htfifo_addtuple(htup_fifo htf, GenericTuple tup)
htf->p_first = p_ent;
}
htf->p_last = p_ent;
/* Update the FIFO state. */
htf->tup_count++;
htf->curr_mem_size += GetMemoryChunkSpace(p_ent) + GetMemoryChunkSpace(tup);
}
......@@ -214,18 +164,6 @@ htfifo_gettuple(htup_fifo htf)
tup = p_ent->tup;
AssertState(tup != NULL);
/* Update the FIFO state. */
AssertState(htf->tup_count > 0);
AssertState(htf->curr_mem_size > 0);
htf->tup_count--;
htf->curr_mem_size -=
(GetMemoryChunkSpace(p_ent) + GetMemoryChunkSpace(tup));
AssertState(htf->tup_count >= 0);
AssertState(htf->curr_mem_size >= 0);
/* Free the FIFO entry. */
if (htf->freelist_count > HTF_FREELIST_MAX_LEN)
{
......@@ -240,12 +178,7 @@ htfifo_gettuple(htup_fifo htf)
}
else
{
/*
* No entries in FIFO. Just do some sanity checks, but NULL is the
* result.
*/
AssertState(htf->tup_count == 0);
AssertState(htf->curr_mem_size == 0);
/* No entries in FIFO. */
tup = NULL;
}
......
......@@ -202,8 +202,9 @@ RecvTupleChunk(MotionConn *conn, ChunkTransportState *transportStates)
* We store the data inplace, and handle any necessary copying later
* on
*/
tcItem = (TupleChunkListItem) palloc0(sizeof(TupleChunkListItemData));
tcItem = (TupleChunkListItem) palloc(sizeof(TupleChunkListItemData));
tcItem->p_next = NULL;
tcItem->chunk_length = tcSize;
tcItem->inplace = (char *) (conn->msgPos + bytesProcessed);
......
......@@ -1082,8 +1082,7 @@ ExecInitMotion(Motion * node, EState *estate, int eflags)
UpdateMotionLayerNode(motionstate->ps.state->motionlayer_context,
node->motionID,
node->sendSorted,
tupDesc,
PlanStateOperatorMemKB((PlanState *) motionstate));
tupDesc);
#ifdef CDB_MOTION_DEBUG
......@@ -1312,7 +1311,6 @@ CdbMergeComparator_CreateContext(TupleDesc tupDesc,
ctx->numSortCols = numSortCols;
ctx->sortColIdx = sortColIdx;
ctx->tupDesc = tupDesc;
ctx->mt_bind = create_memtuple_binding(tupDesc);
/* Allocate the sort function arrays. */
......
......@@ -475,8 +475,6 @@ typedef struct MotionNodeEntry
* value. */
uint64 sel_rd_wait; /* Total time (usec) spent in select wait trying to read */
uint64 sel_wr_wait; /* Total time spent (usec) in select wait trying to write */
uint64 memKB; /* How much memory should this motion node use? */
} MotionNodeEntry;
......
......@@ -65,7 +65,7 @@ extern void InitMotionLayerNode(MotionLayerState *mlStates, int16 motNodeID);
/* Initialization of each motion node in execution plan. */
extern void UpdateMotionLayerNode(MotionLayerState *mlStates, int16 motNodeID, bool preserveOrder,
TupleDesc tupDesc, uint64 operatorMemKB);
TupleDesc tupDesc);
/* Cleanup of each motion node in execution plan (normal termination). */
extern void EndMotionLayerNode(MotionLayerState *mlStates, int16 motNodeID, bool flushCommLayer);
......
......@@ -46,29 +46,9 @@ typedef struct htup_fifo_state
htf_entry freelist;
int freelist_count;
/* A count of HeapTuples in the FIFO. */
int tup_count;
/*
* An estimate of the current in-memory size of the FIFO's contents, in
* bytes.
*/
int curr_mem_size;
/*
* The maximum size that the FIFO is allowed to grow to, in bytes, before
* it will cause an error to be reported.
*/
uint32 max_mem_size;
} htup_fifo_state, *htup_fifo;
#define MIN_HTUPFIFO_KB 8
extern htup_fifo htfifo_create(int max_mem_kb);
extern void htfifo_init(htup_fifo htf, int max_mem_kb);
extern htup_fifo htfifo_create(void);
extern void htfifo_destroy(htup_fifo htf);
extern void htfifo_addtuple(htup_fifo htf, GenericTuple htup);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册