#include "postgres.h"
#include <unistd.h>
#include "executor/instrument.h"
Go to the source code of this file.
Functions | |
static void | BufferUsageAccumDiff (BufferUsage *dst, const BufferUsage *add, const BufferUsage *sub) |
Instrumentation * | InstrAlloc (int n, int instrument_options) |
void | InstrStartNode (Instrumentation *instr) |
void | InstrStopNode (Instrumentation *instr, double nTuples) |
void | InstrEndLoop (Instrumentation *instr) |
Variables | |
BufferUsage | pgBufferUsage |
static void BufferUsageAccumDiff | ( | BufferUsage * | dst, | |
const BufferUsage * | add, | |||
const BufferUsage * | sub | |||
) | [static] |
Definition at line 132 of file instrument.c.
References BufferUsage::blk_read_time, BufferUsage::blk_write_time, INSTR_TIME_ACCUM_DIFF, BufferUsage::local_blks_dirtied, BufferUsage::local_blks_hit, BufferUsage::local_blks_read, BufferUsage::local_blks_written, BufferUsage::shared_blks_dirtied, BufferUsage::shared_blks_hit, BufferUsage::shared_blks_read, BufferUsage::shared_blks_written, BufferUsage::temp_blks_read, and BufferUsage::temp_blks_written.
Referenced by InstrStopNode().
{ dst->shared_blks_hit += add->shared_blks_hit - sub->shared_blks_hit; dst->shared_blks_read += add->shared_blks_read - sub->shared_blks_read; dst->shared_blks_dirtied += add->shared_blks_dirtied - sub->shared_blks_dirtied; dst->shared_blks_written += add->shared_blks_written - sub->shared_blks_written; dst->local_blks_hit += add->local_blks_hit - sub->local_blks_hit; dst->local_blks_read += add->local_blks_read - sub->local_blks_read; dst->local_blks_dirtied += add->local_blks_dirtied - sub->local_blks_dirtied; dst->local_blks_written += add->local_blks_written - sub->local_blks_written; dst->temp_blks_read += add->temp_blks_read - sub->temp_blks_read; dst->temp_blks_written += add->temp_blks_written - sub->temp_blks_written; INSTR_TIME_ACCUM_DIFF(dst->blk_read_time, add->blk_read_time, sub->blk_read_time); INSTR_TIME_ACCUM_DIFF(dst->blk_write_time, add->blk_write_time, sub->blk_write_time); }
Instrumentation* InstrAlloc | ( | int | n, | |
int | instrument_options | |||
) |
Definition at line 28 of file instrument.c.
References i, INSTRUMENT_BUFFERS, INSTRUMENT_TIMER, Instrumentation::need_bufusage, Instrumentation::need_timer, and palloc0().
Referenced by ExecInitNode(), explain_ExecutorStart(), InitResultRelInfo(), and pgss_ExecutorStart().
{ Instrumentation *instr; /* initialize all fields to zeroes, then modify as needed */ instr = palloc0(n * sizeof(Instrumentation)); if (instrument_options & (INSTRUMENT_BUFFERS | INSTRUMENT_TIMER)) { bool need_buffers = (instrument_options & INSTRUMENT_BUFFERS) != 0; bool need_timer = (instrument_options & INSTRUMENT_TIMER) != 0; int i; for (i = 0; i < n; i++) { instr[i].need_bufusage = need_buffers; instr[i].need_timer = need_timer; } } return instr; }
void InstrEndLoop | ( | Instrumentation * | instr | ) |
Definition at line 103 of file instrument.c.
References Instrumentation::counter, elog, ERROR, Instrumentation::firsttuple, INSTR_TIME_GET_DOUBLE, INSTR_TIME_IS_ZERO, INSTR_TIME_SET_ZERO, Instrumentation::nloops, Instrumentation::ntuples, Instrumentation::running, Instrumentation::starttime, Instrumentation::startup, Instrumentation::total, and Instrumentation::tuplecount.
Referenced by ExecReScan(), explain_ExecutorEnd(), ExplainNode(), pgss_ExecutorEnd(), and report_triggers().
{ double totaltime; /* Skip if nothing has happened, or already shut down */ if (!instr->running) return; if (!INSTR_TIME_IS_ZERO(instr->starttime)) elog(ERROR, "InstrEndLoop called on running node"); /* Accumulate per-cycle statistics into totals */ totaltime = INSTR_TIME_GET_DOUBLE(instr->counter); instr->startup += instr->firsttuple; instr->total += totaltime; instr->ntuples += instr->tuplecount; instr->nloops += 1; /* Reset for next cycle (if any) */ instr->running = false; INSTR_TIME_SET_ZERO(instr->starttime); INSTR_TIME_SET_ZERO(instr->counter); instr->firsttuple = 0; instr->tuplecount = 0; }
void InstrStartNode | ( | Instrumentation * | instr | ) |
Definition at line 52 of file instrument.c.
References Instrumentation::bufusage_start, elog, ERROR, INSTR_TIME_IS_ZERO, INSTR_TIME_SET_CURRENT, Instrumentation::need_bufusage, Instrumentation::need_timer, and Instrumentation::starttime.
Referenced by AfterTriggerExecute(), ExecCallTriggerFunc(), ExecProcNode(), MultiExecBitmapAnd(), MultiExecBitmapIndexScan(), MultiExecBitmapOr(), MultiExecHash(), standard_ExecutorFinish(), and standard_ExecutorRun().
{ if (instr->need_timer) { if (INSTR_TIME_IS_ZERO(instr->starttime)) INSTR_TIME_SET_CURRENT(instr->starttime); else elog(ERROR, "InstrStartNode called twice in a row"); } /* save buffer usage totals at node entry, if needed */ if (instr->need_bufusage) instr->bufusage_start = pgBufferUsage; }
void InstrStopNode | ( | Instrumentation * | instr, | |
double | nTuples | |||
) |
Definition at line 69 of file instrument.c.
References BufferUsageAccumDiff(), Instrumentation::bufusage, Instrumentation::bufusage_start, Instrumentation::counter, elog, ERROR, Instrumentation::firsttuple, INSTR_TIME_ACCUM_DIFF, INSTR_TIME_GET_DOUBLE, INSTR_TIME_IS_ZERO, INSTR_TIME_SET_CURRENT, INSTR_TIME_SET_ZERO, Instrumentation::need_bufusage, Instrumentation::need_timer, Instrumentation::running, Instrumentation::starttime, and Instrumentation::tuplecount.
Referenced by AfterTriggerExecute(), ExecCallTriggerFunc(), ExecProcNode(), MultiExecBitmapAnd(), MultiExecBitmapIndexScan(), MultiExecBitmapOr(), MultiExecHash(), standard_ExecutorFinish(), and standard_ExecutorRun().
{ instr_time endtime; /* count the returned tuples */ instr->tuplecount += nTuples; /* let's update the time only if the timer was requested */ if (instr->need_timer) { if (INSTR_TIME_IS_ZERO(instr->starttime)) elog(ERROR, "InstrStopNode called without start"); INSTR_TIME_SET_CURRENT(endtime); INSTR_TIME_ACCUM_DIFF(instr->counter, endtime, instr->starttime); INSTR_TIME_SET_ZERO(instr->starttime); } /* Add delta of buffer usage since entry to node's totals */ if (instr->need_bufusage) BufferUsageAccumDiff(&instr->bufusage, &pgBufferUsage, &instr->bufusage_start); /* Is this the first tuple of this cycle? */ if (!instr->running) { instr->running = true; instr->firsttuple = INSTR_TIME_GET_DOUBLE(instr->counter); } }
Definition at line 20 of file instrument.c.
Referenced by BufFileDumpBuffer(), BufFileLoadBuffer(), FlushBuffer(), LocalBufferAlloc(), MarkBufferDirty(), MarkLocalBufferDirty(), pgss_ProcessUtility(), and ReadBuffer_common().