| 1 | /* |
| 2 | * This Source Code Form is subject to the terms of the Mozilla Public |
| 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 5 | * |
| 6 | * Copyright 1997 - July 2008 CWI, August 2008 - 2019 MonetDB B.V. |
| 7 | */ |
| 8 | |
| 9 | #ifndef _MAL_RUNTIME_H |
| 10 | #define _MAL_RUNTIME_H |
| 11 | |
| 12 | #include "mal.h" |
| 13 | #include "mal_client.h" |
| 14 | #include "mal_instruction.h" |
| 15 | |
| 16 | /* During MAL interpretation we collect performance event data. |
| 17 | * Their management is orchestrated from here. |
| 18 | * We need to maintain some state from ProfileBegin |
| 19 | */ |
| 20 | typedef struct{ |
| 21 | lng ticks; /* at start of this profile interval */ |
| 22 | } *RuntimeProfile, RuntimeProfileRecord; |
| 23 | |
| 24 | /* The actual running queries are assembled in a queue |
| 25 | * for external inspection and manipulation |
| 26 | */ |
| 27 | typedef struct QRYQUEUE{ |
| 28 | Client cntxt; |
| 29 | MalBlkPtr mb; |
| 30 | MalStkPtr stk; |
| 31 | oid tag; |
| 32 | str query; |
| 33 | str status; |
| 34 | time_t start; |
| 35 | int progress; /* percentage of MAL instructions handled */ |
| 36 | lng runtime; |
| 37 | } *QueryQueue; |
| 38 | mal_export lng qtop; |
| 39 | |
| 40 | typedef struct WORKINGSET{ |
| 41 | Client cntxt; |
| 42 | MalBlkPtr mb; |
| 43 | MalStkPtr stk; |
| 44 | InstrPtr pci; |
| 45 | } Workingset; |
| 46 | |
| 47 | mal_export Workingset workingset[THREADS]; |
| 48 | |
| 49 | mal_export void runtimeProfileInit(Client cntxt, MalBlkPtr mb, MalStkPtr stk); |
| 50 | mal_export void runtimeProfileFinish(Client cntxt, MalBlkPtr mb, MalStkPtr stk); |
| 51 | mal_export void runtimeProfileBegin(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci, RuntimeProfile prof); |
| 52 | mal_export void runtimeProfileExit(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci, RuntimeProfile prof); |
| 53 | mal_export void finishSessionProfiler(Client cntxt); |
| 54 | mal_export lng getVolume(MalStkPtr stk, InstrPtr pci, int rd); |
| 55 | mal_export lng getBatSpace(BAT *b); |
| 56 | |
| 57 | mal_export QueryQueue QRYqueue; |
| 58 | #endif |
| 59 | |