#include "portability/instr_time.h"
Go to the source code of this file.
Data Structures | |
struct | BufferUsage |
struct | Instrumentation |
Typedefs | |
typedef struct BufferUsage | BufferUsage |
typedef enum InstrumentOption | InstrumentOption |
typedef struct Instrumentation | Instrumentation |
Enumerations | |
enum | InstrumentOption { INSTRUMENT_TIMER = 1 << 0, INSTRUMENT_BUFFERS = 1 << 1, INSTRUMENT_ROWS = 1 << 2, INSTRUMENT_ALL = 0x7FFFFFFF } |
Functions | |
Instrumentation * | InstrAlloc (int n, int instrument_options) |
void | InstrStartNode (Instrumentation *instr) |
void | InstrStopNode (Instrumentation *instr, double nTuples) |
void | InstrEndLoop (Instrumentation *instr) |
Variables | |
PGDLLIMPORT BufferUsage | pgBufferUsage |
typedef struct BufferUsage BufferUsage |
typedef struct Instrumentation Instrumentation |
typedef enum InstrumentOption InstrumentOption |
enum InstrumentOption |
Definition at line 36 of file instrument.h.
{ INSTRUMENT_TIMER = 1 << 0, /* needs timer (and row counts) */ INSTRUMENT_BUFFERS = 1 << 1, /* needs buffer usage */ INSTRUMENT_ROWS = 1 << 2, /* needs row count */ INSTRUMENT_ALL = 0x7FFFFFFF } InstrumentOption;
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); } }
PGDLLIMPORT BufferUsage pgBufferUsage |
Definition at line 20 of file instrument.c.
Referenced by BufFileDumpBuffer(), BufFileLoadBuffer(), FlushBuffer(), LocalBufferAlloc(), MarkBufferDirty(), MarkLocalBufferDirty(), pgss_ProcessUtility(), and ReadBuffer_common().