47#define PROFILE_NONE (uint)0
48#define PROFILE_CPU (uint)(1 << 0)
49#define PROFILE_MEMORY (uint)(1 << 1)
50#define PROFILE_BLOCK_IO (uint)(1 << 2)
51#define PROFILE_CONTEXT (uint)(1 << 3)
52#define PROFILE_PAGE_FAULTS (uint)(1 << 4)
53#define PROFILE_IPC (uint)(1 << 5)
54#define PROFILE_SWAPS (uint)(1 << 6)
55#define PROFILE_SOURCE (uint)(1 << 16)
56#define PROFILE_ALL (uint)(~0)
58#if defined(ENABLED_PROFILING)
60#ifdef HAVE_SYS_RESOURCE_H
61#include <sys/resource.h>
111 if (
last !=
nullptr) {
116 new_item->
next =
nullptr;
126 if (
first ==
nullptr) {
127 DBUG_PRINT(
"warning", (
"tried to pop nonexistent item from Queue"));
157 return ((
struct queue_item *)current)->payload;
174 FILETIME ftKernel, ftUser;
177 const char *
function;
185 void set_label(
const char *status_arg,
const char *function_arg,
186 const char *file_arg,
unsigned int line_arg);
189 const char *function_arg,
const char *file_arg,
190 unsigned int line_arg);
216 void set_query_source(
const char *query_source_arg,
size_t query_length_arg);
219 void new_status(
const char *status_arg,
const char *function_arg,
220 const char *file_arg,
unsigned int line_arg);
248 void set_query_source(
const char *query_source_arg,
size_t query_length_arg);
256 void status_change(
const char *status_arg,
const char *function_arg,
257 const char *file_arg,
unsigned int line_arg);
int64 query_id_t
Definition: binlog.h:72
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:853
Profiling state for a single THD; contains multiple QUERY_PROFILE objects.
Definition: sql_profile.h:226
void discard_current_query()
Throw away the current profile, because it's useless or unwanted or corrupted.
Definition: sql_profile.cc:392
void set_thd(THD *thd_arg)
Definition: sql_profile.h:259
void status_change(const char *status_arg, const char *function_arg, const char *file_arg, unsigned int line_arg)
A new state is given, and that signals the profiler to start a new timed step for the current query's...
Definition: sql_profile.cc:349
void cleanup()
Clear all the profiling information.
Definition: sql_profile.cc:697
bool enabled
Definition: sql_profile.h:237
bool show_profiles()
Definition: sql_profile.cc:431
bool keeping
Definition: sql_profile.h:236
query_id_t profile_id_counter
Definition: sql_profile.h:234
THD * thd
Definition: sql_profile.h:235
void finish_current_query()
Try to save the current profile entry, clean up the data if it shouldn't be saved,...
Definition: sql_profile.cc:404
int fill_statistics_info(THD *thd, Table_ref *tables)
Fill the information schema table, "query_profile", as defined in show.cc .
Definition: sql_profile.cc:501
Queue< QUERY_PROFILE > history
Definition: sql_profile.h:241
~PROFILING()
Definition: sql_profile.cc:334
QUERY_PROFILE * current
Definition: sql_profile.h:239
void set_query_source(const char *query_source_arg, size_t query_length_arg)
At a point in execution where we know the query source, save the text of it in the query profile.
Definition: sql_profile.cc:484
PROFILING()
Definition: sql_profile.cc:331
void start_new_query(const char *initial_state="starting")
Prepare to start processing a new query.
Definition: sql_profile.cc:369
QUERY_PROFILE * last
Definition: sql_profile.h:240
query_id_t next_profile_id()
Definition: sql_profile.h:243
A single entry in a single profile.
Definition: sql_profile.h:164
PROF_MEASUREMENT(QUERY_PROFILE *profile_arg, const char *status_arg)
Definition: sql_profile.cc:190
double time_usecs
Definition: sql_profile.h:182
void collect()
This updates the statistics for this moment of time.
Definition: sql_profile.cc:263
~PROF_MEASUREMENT()
Definition: sql_profile.cc:206
struct rusage rusage
Definition: sql_profile.h:172
ulong m_seq
Definition: sql_profile.h:181
void set_label(const char *status_arg, const char *function_arg, const char *file_arg, unsigned int line_arg)
Definition: sql_profile.cc:211
const char * file
Definition: sql_profile.h:178
QUERY_PROFILE * profile
Definition: sql_profile.h:169
char * allocated_status_memory
Definition: sql_profile.h:183
const char * status
Definition: sql_profile.h:170
unsigned int line
Definition: sql_profile.h:179
The full profile for a single query, and includes multiple PROF_MEASUREMENT objects.
Definition: sql_profile.h:199
void set_query_source(const char *query_source_arg, size_t query_length_arg)
Definition: sql_profile.cc:297
double m_start_time_usecs
Definition: sql_profile.h:208
~QUERY_PROFILE()
Definition: sql_profile.cc:288
query_id_t profiling_query_id
Definition: sql_profile.h:205
QUERY_PROFILE(PROFILING *profiling_arg, const char *status_arg)
Definition: sql_profile.cc:276
LEX_STRING m_query_source
Definition: sql_profile.h:206
void new_status(const char *status_arg, const char *function_arg, const char *file_arg, unsigned int line_arg)
Definition: sql_profile.cc:310
Queue< PROF_MEASUREMENT > entries
Definition: sql_profile.h:211
ulong m_seq_counter
Definition: sql_profile.h:210
PROFILING * profiling
Definition: sql_profile.h:203
double m_end_time_usecs
Definition: sql_profile.h:209
Implements a persistent FIFO using server List method names.
Definition: sql_profile.h:76
void * iterator_next(void *current)
Definition: sql_profile.h:152
struct queue_item * first
Definition: sql_profile.h:83
ulong elements
Definition: sql_profile.h:100
bool is_empty()
Definition: sql_profile.h:144
void push_back(T *payload)
Definition: sql_profile.h:102
struct queue_item * last
Definition: sql_profile.h:83
void empty()
Definition: sql_profile.h:91
T * iterator_value(void *current)
Definition: sql_profile.h:156
Queue()
Definition: sql_profile.h:86
void * new_iterator()
Definition: sql_profile.h:150
T * pop()
Definition: sql_profile.h:122
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:34
unsigned int PSI_memory_key
Instrumented memory key.
Definition: psi_memory_bits.h:49
#define DBUG_PRINT(keyword, arglist)
Definition: my_dbug.h:181
Some integer typedefs for easier portability.
int64_t int64
Definition: my_inttypes.h:68
#define MYF(v)
Definition: my_inttypes.h:97
void * my_malloc(PSI_memory_key key, size_t size, int flags)
Allocates size bytes of memory.
Definition: my_memory.cc:57
void my_free(void *ptr)
Frees the memory pointed by the ptr.
Definition: my_memory.cc:81
int64 query_id_t
Definition: sql_profile.h:39
PSI_memory_key key_memory_queue_item
Definition: psi_memory_key.cc:126
int make_profile_table_for_show(THD *thd, ST_SCHEMA_TABLE *schema_table)
Definition: sql_profile.cc:126
ST_FIELD_INFO query_profile_statistics_info[]
Definition: sql_profile.cc:100
int fill_query_profile_statistics_info(THD *thd, Table_ref *tables, Item *)
Connects Information_Schema and Profiling.
Definition: sql_profile.cc:82
Definition: mysql_lex_string.h:35
Definition: sql_profile.h:78
struct queue_item * previous
Definition: sql_profile.h:80
T * payload
Definition: sql_profile.h:79
struct queue_item * next
Definition: sql_profile.h:80
#define NULL
Definition: types.h:55