| Thread Previous • Date Previous • Date Next • Thread Next |
hi sergey all that i want is done now !! how! very very nice informations about qc =) just two flags that i don't understand how to show it : LC_TIME_NAMES and TIME_ZONE all others informations are displayed (32 columns now! maybe we could remove flags?) some fields maybe should be human readable but idon't know how to do it, like: COLUMN_FLAGS_CHARACTER_SET_CLIENT_NUM, COLUMN_FLAGS_CHARACTER_SET_RESULTS_NUM, COLUMN_FLAGS_COLLATION_CONNECTION_NUM, COLUMN_FLAGS_SQL_MODE, COLUMN_FLAGS_DEFAULT_WEEK_FORMAT maybe in future.. someone do it =) well, how could i put this code in launchpad, any fast howto? i know how to work with git / github, there's something similar? it's bazaar based?
Attachment:
diff_qc_info.cc
Description: Binary data
Attachment:
diff_sql_cache.cc
Description: Binary data
--- sql_cache.old.h 2013-05-25 16:45:40.080882118 -0300
+++ sql_cache.h 2013-05-25 19:56:04.952276314 -0300
@@ -34,37 +34,37 @@
if QUERY_CACHE_MIN_ALLOCATION_UNIT == 0 then
QUERY_CACHE_MIN_ALLOCATION_UNIT choosed automaticaly
*/
-#define QUERY_CACHE_MIN_ALLOCATION_UNIT 512
+#define QUERY_CACHE_MIN_ALLOCATION_UNIT 512
/* inittial size of hashes */
-#define QUERY_CACHE_DEF_QUERY_HASH_SIZE 1024
-#define QUERY_CACHE_DEF_TABLE_HASH_SIZE 1024
+#define QUERY_CACHE_DEF_QUERY_HASH_SIZE 1024
+#define QUERY_CACHE_DEF_TABLE_HASH_SIZE 1024
/* minimal result data size when data allocated */
-#define QUERY_CACHE_MIN_RESULT_DATA_SIZE (1024*4)
+#define QUERY_CACHE_MIN_RESULT_DATA_SIZE (1024*4)
-/*
+/*
start estimation of first result block size only when number of queries
- bigger then:
+ bigger then:
*/
#define QUERY_CACHE_MIN_ESTIMATED_QUERIES_NUMBER 3
/* memory bins size spacing (see at Query_cache::init_cache (sql_cache.cc)) */
-#define QUERY_CACHE_MEM_BIN_FIRST_STEP_PWR2 4
-#define QUERY_CACHE_MEM_BIN_STEP_PWR2 2
-#define QUERY_CACHE_MEM_BIN_PARTS_INC 1
-#define QUERY_CACHE_MEM_BIN_PARTS_MUL 1.2
-#define QUERY_CACHE_MEM_BIN_SPC_LIM_PWR2 3
+#define QUERY_CACHE_MEM_BIN_FIRST_STEP_PWR2 4
+#define QUERY_CACHE_MEM_BIN_STEP_PWR2 2
+#define QUERY_CACHE_MEM_BIN_PARTS_INC 1
+#define QUERY_CACHE_MEM_BIN_PARTS_MUL 1.2
+#define QUERY_CACHE_MEM_BIN_SPC_LIM_PWR2 3
/* how many free blocks check when finding most suitable before other 'end'
of list of free blocks */
#define QUERY_CACHE_MEM_BIN_TRY 5
/* packing parameters */
-#define QUERY_CACHE_PACK_ITERATION 2
-#define QUERY_CACHE_PACK_LIMIT (512*1024L)
+#define QUERY_CACHE_PACK_ITERATION 2
+#define QUERY_CACHE_PACK_LIMIT (512*1024L)
#define TABLE_COUNTER_TYPE uint
@@ -100,7 +100,7 @@
TABLE_COUNTER_TYPE n;
/**
- Pointers to the next and previous node, linking all queries with
+ Pointers to the next and previous node, linking all queries with
a common table.
*/
Query_cache_block_table *next, *prev;
@@ -113,7 +113,7 @@
/**
A method to calculate the address of the query cache block
- owning this node. The purpose of this calculation is to
+ owning this node. The purpose of this calculation is to
make it easier to move the query cache block without having
to modify all the pointer addresses.
*/
@@ -124,19 +124,19 @@
{
Query_cache_block() {} /* Remove gcc warning */
enum block_type {FREE, QUERY, RESULT, RES_CONT, RES_BEG,
- RES_INCOMPLETE, TABLE, INCOMPLETE};
+ RES_INCOMPLETE, TABLE, INCOMPLETE};
- ulong length; // length of all block
- ulong used; // length of data
+ ulong length; // length of all block
+ ulong used; // length of data
/*
Not used **pprev, **prev because really needed access to pervious block:
*pprev to join free blocks
*prev to access to opposite side of list in cyclic sorted list
*/
- Query_cache_block *pnext,*pprev, // physical next/previous block
- *next,*prev; // logical next/previous block
+ Query_cache_block *pnext,*pprev, // physical next/previous block
+ *next,*prev; // logical next/previous block
block_type type;
- TABLE_COUNTER_TYPE n_tables; // number of tables in query
+ TABLE_COUNTER_TYPE n_tables; // number of tables in query
inline bool is_free(void) { return type == FREE; }
void init(ulong length);
@@ -158,21 +158,33 @@
ulong len;
uint8 tbls_type;
unsigned int last_pkt_nr;
+ ulonglong query_hits_counter;
+ ulonglong cache_insert_time;
+ ulonglong select_expend_time;
+ ulonglong select_lock_time;
+ longlong select_rows_read;
+
Query_cache_query() {} /* Remove gcc warning */
inline void init_n_lock();
void unlock_n_destroy();
- inline ulonglong found_rows() { return limit_found_rows; }
+ inline ulonglong query_expend_time() { return select_expend_time; }
+ inline ulonglong query_lock_time() { return select_lock_time; }
+ inline longlong query_rows_read() { return select_rows_read; }
+ inline longlong query_insert_time() { return cache_insert_time; }
+ inline ulonglong query_hits() { return query_hits_counter; }
+ inline void query_hits_add() { query_hits_counter+=1; }
+ inline ulonglong found_rows() { return limit_found_rows; }
inline void found_rows(ulonglong rows) { limit_found_rows= rows; }
- inline Query_cache_block *result() { return res; }
+ inline Query_cache_block *result() { return res; }
inline void result(Query_cache_block *p) { res= p; }
- inline Query_cache_tls *writer() { return wri; }
+ inline Query_cache_tls *writer() { return wri; }
inline void writer(Query_cache_tls *p) { wri= p; }
inline uint8 tables_type() { return tbls_type; }
inline void tables_type(uint8 type) { tbls_type= type; }
- inline ulong length() { return len; }
- inline ulong add(ulong packet_len) { return(len+= packet_len); }
- inline void length(ulong length_arg) { len= length_arg; }
+ inline ulong length() { return len; }
+ inline ulong add(ulong packet_len) { return(len+= packet_len); }
+ inline void length(ulong length_arg) { len= length_arg; }
inline uchar* query()
{
return (((uchar*)this) + ALIGN_SIZE(sizeof(Query_cache_query)));
@@ -205,9 +217,9 @@
*/
my_bool hashed;
- inline char *db() { return (char *) data(); }
- inline char *table() { return tbl; }
- inline void table(char *table_arg) { tbl= table_arg; }
+ inline char *db() { return (char *) data(); }
+ inline char *table() { return tbl; }
+ inline void table(char *table_arg) { tbl= table_arg; }
inline uint32 key_length() { return key_len; }
inline void key_length(uint32 len) { key_len= len; }
inline uint8 type() { return table_type; }
@@ -221,7 +233,7 @@
inline uchar* data()
{
return (uchar*)(((uchar*)this)+
- ALIGN_SIZE(sizeof(Query_cache_table)));
+ ALIGN_SIZE(sizeof(Query_cache_table)));
}
};
@@ -233,11 +245,11 @@
inline uchar* data()
{
return (uchar*)(((uchar*) this)+
- ALIGN_SIZE(sizeof(Query_cache_result)));
+ ALIGN_SIZE(sizeof(Query_cache_result)));
}
/* data_continue (if not whole packet contained by this block) */
- inline Query_cache_block *parent() { return query; }
- inline void parent (Query_cache_block *p) { query=p; }
+ inline Query_cache_block *parent() { return query; }
+ inline void parent (Query_cache_block *p) { query=p; }
};
@@ -324,44 +336,44 @@
till the end of a flush operation.
*/
mysql_mutex_t structure_guard_mutex;
- uchar *cache; // cache memory
- Query_cache_block *first_block; // physical location block list
- Query_cache_block *queries_blocks; // query list (LIFO)
+ uchar *cache; // cache memory
+ Query_cache_block *first_block; // physical location block list
+ Query_cache_block *queries_blocks; // query list (LIFO)
Query_cache_block *tables_blocks;
- Query_cache_memory_bin *bins; // free block lists
- Query_cache_memory_bin_step *steps; // bins spacing info
+ Query_cache_memory_bin *bins; // free block lists
+ Query_cache_memory_bin_step *steps; // bins spacing info
HASH queries, tables;
/* options */
ulong min_allocation_unit, min_result_data_size;
uint def_query_hash_size, def_table_hash_size;
-
- uint mem_bin_num, mem_bin_steps; // See at init_cache & find_bin
+
+ uint mem_bin_num, mem_bin_steps; // See at init_cache & find_bin
bool initialized;
/* Exclude/include from cyclic double linked list */
static void double_linked_list_exclude(Query_cache_block *point,
- Query_cache_block **list_pointer);
+ Query_cache_block **list_pointer);
static void double_linked_list_simple_include(Query_cache_block *point,
- Query_cache_block **
- list_pointer);
+ Query_cache_block **
+ list_pointer);
static void double_linked_list_join(Query_cache_block *head_tail,
- Query_cache_block *tail_head);
+ Query_cache_block *tail_head);
/* The following functions require that structure_guard_mutex is locked */
void flush_cache();
my_bool free_old_query();
void free_query(Query_cache_block *point);
my_bool allocate_data_chain(Query_cache_block **result_block,
- ulong data_len,
- Query_cache_block *query_block,
- my_bool first_block);
+ ulong data_len,
+ Query_cache_block *query_block,
+ my_bool first_block);
void invalidate_table(THD *thd, TABLE_LIST *table);
void invalidate_table(THD *thd, TABLE *table);
void invalidate_table(THD *thd, uchar *key, uint32 key_length);
void invalidate_table(THD *thd, Query_cache_block *table_block);
- void invalidate_query_block_list(THD *thd,
+ void invalidate_query_block_list(THD *thd,
Query_cache_block_table *list_root);
TABLE_COUNTER_TYPE
@@ -369,32 +381,32 @@
TABLE_COUNTER_TYPE counter,
Query_cache_block_table **block_table);
my_bool register_all_tables(THD *thd, Query_cache_block *block,
- TABLE_LIST *tables_used,
- TABLE_COUNTER_TYPE tables);
+ TABLE_LIST *tables_used,
+ TABLE_COUNTER_TYPE tables);
void unlink_table(Query_cache_block_table *node);
Query_cache_block *get_free_block (ulong len, my_bool not_less,
- ulong min);
+ ulong min);
void free_memory_block(Query_cache_block *point);
void split_block(Query_cache_block *block, ulong len);
Query_cache_block *join_free_blocks(Query_cache_block *first_block,
- Query_cache_block *block_in_list);
+ Query_cache_block *block_in_list);
my_bool append_next_free_block(Query_cache_block *block,
- ulong add_size);
+ ulong add_size);
void exclude_from_free_memory_list(Query_cache_block *free_block);
void insert_into_free_memory_list(Query_cache_block *new_block);
my_bool move_by_type(uchar **border, Query_cache_block **before,
- ulong *gap, Query_cache_block *i);
+ ulong *gap, Query_cache_block *i);
uint find_bin(ulong size);
void move_to_query_list_end(Query_cache_block *block);
void insert_into_free_memory_sorted_list(Query_cache_block *new_block,
- Query_cache_block **list);
+ Query_cache_block **list);
void pack_cache();
void relink(Query_cache_block *oblock,
- Query_cache_block *nblock,
- Query_cache_block *next,
- Query_cache_block *prev,
- Query_cache_block *pnext,
- Query_cache_block *pprev);
+ Query_cache_block *nblock,
+ Query_cache_block *next,
+ Query_cache_block *prev,
+ Query_cache_block *pnext,
+ Query_cache_block *pprev);
my_bool join_results(ulong join_limit);
/*
@@ -405,21 +417,21 @@
void make_disabled();
void free_cache();
Query_cache_block *write_block_data(ulong data_len, uchar* data,
- ulong header_len,
- Query_cache_block::block_type type,
- TABLE_COUNTER_TYPE ntab = 0);
+ ulong header_len,
+ Query_cache_block::block_type type,
+ TABLE_COUNTER_TYPE ntab = 0);
my_bool append_result_data(Query_cache_block **result,
- ulong data_len, uchar* data,
- Query_cache_block *parent);
+ ulong data_len, uchar* data,
+ Query_cache_block *parent);
my_bool write_result_data(Query_cache_block **result,
- ulong data_len, uchar* data,
- Query_cache_block *parent,
- Query_cache_block::block_type
- type=Query_cache_block::RESULT);
+ ulong data_len, uchar* data,
+ Query_cache_block *parent,
+ Query_cache_block::block_type
+ type=Query_cache_block::RESULT);
inline ulong get_min_first_result_data_size();
inline ulong get_min_append_result_data_size();
Query_cache_block *allocate_block(ulong len, my_bool not_less,
- ulong min);
+ ulong min);
/*
If query is cacheable return number tables in query
(query without tables not cached)
@@ -435,10 +447,10 @@
public:
Query_cache(ulong query_cache_limit = ULONG_MAX,
- ulong min_allocation_unit = QUERY_CACHE_MIN_ALLOCATION_UNIT,
- ulong min_result_data_size = QUERY_CACHE_MIN_RESULT_DATA_SIZE,
- uint def_query_hash_size = QUERY_CACHE_DEF_QUERY_HASH_SIZE,
- uint def_table_hash_size = QUERY_CACHE_DEF_TABLE_HASH_SIZE);
+ ulong min_allocation_unit = QUERY_CACHE_MIN_ALLOCATION_UNIT,
+ ulong min_result_data_size = QUERY_CACHE_MIN_RESULT_DATA_SIZE,
+ uint def_query_hash_size = QUERY_CACHE_DEF_QUERY_HASH_SIZE,
+ uint def_table_hash_size = QUERY_CACHE_DEF_TABLE_HASH_SIZE);
inline bool is_disabled(void) { return m_cache_status != OK; }
inline bool is_disable_in_progress(void)
@@ -464,12 +476,12 @@
/* Remove all queries that uses any of the listed following tables */
void invalidate(THD *thd, TABLE_LIST *tables_used,
- my_bool using_transactions);
+ my_bool using_transactions);
void invalidate(THD *thd, CHANGED_TABLE_LIST *tables_used);
void invalidate_locked_for_write(THD *thd, TABLE_LIST *tables_used);
void invalidate(THD *thd, TABLE *table, my_bool using_transactions);
void invalidate(THD *thd, const char *key, uint32 key_length,
- my_bool using_transactions);
+ my_bool using_transactions);
/* Remove all queries that uses any of the tables in following database */
void invalidate(THD *thd, char *db);
@@ -480,7 +492,7 @@
void flush();
void pack(THD *thd,
ulong join_limit = QUERY_CACHE_PACK_LIMIT,
- uint iteration_limit = QUERY_CACHE_PACK_ITERATION);
+ uint iteration_limit = QUERY_CACHE_PACK_ITERATION);
void destroy();
@@ -489,10 +501,10 @@
ulong length,
unsigned pkt_nr);
my_bool insert_table(uint key_len, char *key,
- Query_cache_block_table *node,
- uint32 db_length, uint8 cache_type,
- qc_engine_callback callback,
- ulonglong engine_data,
+ Query_cache_block_table *node,
+ uint32 db_length, uint8 cache_type,
+ qc_engine_callback callback,
+ ulonglong engine_data,
my_bool hash);
void end_of_result(THD *thd);
@@ -510,15 +522,15 @@
void tables_dump();
my_bool check_integrity(bool not_locked);
my_bool in_list(Query_cache_block * root, Query_cache_block * point,
- const char *name);
+ const char *name);
my_bool in_table_list(Query_cache_block_table * root,
- Query_cache_block_table * point,
- const char *name);
+ Query_cache_block_table * point,
+ const char *name);
my_bool in_blocks(Query_cache_block * point);
/* Table key generation */
static uint filename_2_table_key (char *key, const char *filename,
- uint32 *db_langth);
+ uint32 *db_langth);
enum Cache_try_lock_mode {WAIT, TIMEOUT, TRY};
bool try_lock(THD *thd, Cache_try_lock_mode mode= WAIT);
| Thread Previous • Date Previous • Date Next • Thread Next |