~ubuntu-branches/ubuntu/wily/mysql-5.6/wily

« back to all changes in this revision

Viewing changes to storage/perfschema/pfs_instr.cc

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2015-04-16 20:07:10 UTC
  • mto: (1.3.9 vivid-proposed)
  • mto: This revision was merged to the branch mainline in revision 11.
  • Revision ID: package-import@ubuntu.com-20150416200710-pcrsa022082zj46k
Tags: upstream-5.6.24
ImportĀ upstreamĀ versionĀ 5.6.24

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
 
1
/* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
2
2
 
3
3
  This program is free software; you can redistribute it and/or modify
4
4
  it under the terms of the GNU General Public License as published by
94
94
/** Number of EVENTS_STATEMENTS_HISTORY records per thread. */
95
95
ulong events_statements_history_per_thread;
96
96
uint statement_stack_max;
 
97
uint pfs_max_digest_length= 0;
97
98
/** Number of locker lost. @sa LOCKER_STACK_SIZE. */
98
99
ulong locker_lost= 0;
99
100
/** Number of statement lost. @sa STATEMENT_STACK_SIZE. */
176
177
static PFS_events_stages *thread_stages_history_array= NULL;
177
178
static PFS_events_statements *thread_statements_history_array= NULL;
178
179
static PFS_events_statements *thread_statements_stack_array= NULL;
 
180
static unsigned char *current_stmts_digest_token_array= NULL;
 
181
static unsigned char *history_stmts_digest_token_array= NULL;
179
182
static char *thread_session_connect_attrs_array= NULL;
180
183
 
181
184
/** Hash table for instrumented files. */
190
193
*/
191
194
int init_instruments(const PFS_global_param *param)
192
195
{
 
196
  PFS_events_statements *pfs_stmt;
 
197
  unsigned char *pfs_tokens;
 
198
 
193
199
  uint thread_waits_history_sizing;
194
200
  uint thread_stages_history_sizing;
195
201
  uint thread_statements_history_sizing;
215
221
  file_handle_max= param->m_file_handle_sizing;
216
222
  file_handle_full= false;
217
223
  file_handle_lost= 0;
 
224
 
 
225
  pfs_max_digest_length= param->m_max_digest_length;
 
226
 
218
227
  table_max= param->m_table_sizing;
219
228
  table_full= false;
220
229
  table_lost= 0;
254
263
    * session_connect_attrs_size_per_thread;
255
264
  session_connect_attrs_lost= 0;
256
265
 
 
266
  size_t current_digest_tokens_sizing= param->m_thread_sizing * pfs_max_digest_length * statement_stack_max;
 
267
  size_t history_digest_tokens_sizing= param->m_thread_sizing * pfs_max_digest_length * events_statements_history_per_thread;
 
268
 
257
269
  mutex_array= NULL;
258
270
  rwlock_array= NULL;
259
271
  cond_array= NULL;
266
278
  thread_stages_history_array= NULL;
267
279
  thread_statements_history_array= NULL;
268
280
  thread_statements_stack_array= NULL;
 
281
  current_stmts_digest_token_array= NULL;
 
282
  history_stmts_digest_token_array= NULL;
269
283
  thread_instr_class_waits_array= NULL;
270
284
  thread_instr_class_stages_array= NULL;
271
285
  thread_instr_class_statements_array= NULL;
407
421
      return 1;
408
422
  }
409
423
 
 
424
  if (current_digest_tokens_sizing > 0)
 
425
  {
 
426
    current_stmts_digest_token_array=
 
427
      (unsigned char *)pfs_malloc(current_digest_tokens_sizing, MYF(MY_ZEROFILL));
 
428
    if (unlikely(current_stmts_digest_token_array == NULL))
 
429
      return 1;
 
430
  }
 
431
 
 
432
  if (history_digest_tokens_sizing > 0)
 
433
  {
 
434
    history_stmts_digest_token_array=
 
435
      (unsigned char *)pfs_malloc(history_digest_tokens_sizing, MYF(MY_ZEROFILL));
 
436
    if (unlikely(history_stmts_digest_token_array == NULL))
 
437
      return 1;
 
438
  }
 
439
 
410
440
  for (index= 0; index < thread_max; index++)
411
441
  {
412
442
    thread_array[index].m_waits_history=
427
457
      &thread_session_connect_attrs_array[index * session_connect_attrs_size_per_thread];
428
458
  }
429
459
 
 
460
  for (index= 0; index < thread_statements_stack_sizing; index++)
 
461
  {
 
462
    pfs_stmt= & thread_statements_stack_array[index];
 
463
 
 
464
    pfs_tokens= & current_stmts_digest_token_array[index * pfs_max_digest_length];
 
465
    pfs_stmt->m_digest_storage.reset(pfs_tokens, pfs_max_digest_length);
 
466
  }
 
467
 
 
468
  for (index= 0; index < thread_statements_history_sizing; index++)
 
469
  {
 
470
    pfs_stmt= & thread_statements_history_array[index];
 
471
 
 
472
    pfs_tokens= & history_stmts_digest_token_array[index * pfs_max_digest_length];
 
473
    pfs_stmt->m_digest_storage.reset(pfs_tokens, pfs_max_digest_length);
 
474
  }
 
475
 
430
476
  if (stage_class_max > 0)
431
477
  {
432
478
    global_instr_class_stages_array=
497
543
  global_instr_class_statements_array= NULL;
498
544
  pfs_free(thread_session_connect_attrs_array);
499
545
  thread_session_connect_attrs_array=NULL;
 
546
  pfs_free(current_stmts_digest_token_array);
 
547
  current_stmts_digest_token_array= NULL;
 
548
  pfs_free(history_stmts_digest_token_array);
 
549
  history_stmts_digest_token_array= NULL;
500
550
}
501
551
 
502
552
C_MODE_START