Commit 9f27e289 authored by Marc Alff's avatar Marc Alff

Bug#53566 SHOW ENGINE PERFORMANCE_SCHEMA STATUS reports less memory than really used

Backporting the fix from myql-next-mr (5.6) to mysql-trunk (5.5)
parent f16681d6
/* Copyright (C) 2008-2009 Sun Microsystems, Inc /* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software Foundation,
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
/** /**
@file storage/perfschema/pfs_engine_table.cc @file storage/perfschema/pfs_engine_table.cc
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
/* For show status */ /* For show status */
#include "pfs_column_values.h" #include "pfs_column_values.h"
#include "pfs_instr.h" #include "pfs_instr.h"
#include "pfs_global.h"
#include "sql_base.h" // close_thread_tables #include "sql_base.h" // close_thread_tables
#include "lock.h" // MYSQL_LOCK_IGNORE_TIMEOUT #include "lock.h" // MYSQL_LOCK_IGNORE_TIMEOUT
...@@ -677,6 +678,7 @@ bool pfs_show_status(handlerton *hton, THD *thd, ...@@ -677,6 +678,7 @@ bool pfs_show_status(handlerton *hton, THD *thd,
case 40: case 40:
name= "(PFS_FILE_HANDLE).MEMORY"; name= "(PFS_FILE_HANDLE).MEMORY";
size= file_handle_max * sizeof(PFS_file*); size= file_handle_max * sizeof(PFS_file*);
total_memory+= size;
break; break;
case 41: case 41:
name= "EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME.ROW_SIZE"; name= "EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME.ROW_SIZE";
...@@ -691,13 +693,41 @@ bool pfs_show_status(handlerton *hton, THD *thd, ...@@ -691,13 +693,41 @@ bool pfs_show_status(handlerton *hton, THD *thd,
size= thread_max * instr_class_per_thread * sizeof(PFS_single_stat_chain); size= thread_max * instr_class_per_thread * sizeof(PFS_single_stat_chain);
total_memory+= size; total_memory+= size;
break; break;
case 44:
name= "(PFS_TABLE_SHARE).ROW_SIZE";
size= sizeof(PFS_table_share);
break;
case 45:
name= "(PFS_TABLE_SHARE).ROW_COUNT";
size= table_share_max;
break;
case 46:
name= "(PFS_TABLE_SHARE).MEMORY";
size= table_share_max * sizeof(PFS_table_share);
total_memory+= size;
break;
case 47:
name= "(PFS_TABLE).ROW_SIZE";
size= sizeof(PFS_table);
break;
case 48:
name= "(PFS_TABLE).ROW_COUNT";
size= table_max;
break;
case 49:
name= "(PFS_TABLE).MEMORY";
size= table_max * sizeof(PFS_table);
total_memory+= size;
break;
/* /*
This case must be last, This case must be last,
for aggregation in total_memory. for aggregation in total_memory.
*/ */
case 44: case 50:
name= "PERFORMANCE_SCHEMA.MEMORY"; name= "PERFORMANCE_SCHEMA.MEMORY";
size= total_memory; size= total_memory;
/* This will fail if something is not advertised here */
DBUG_ASSERT(size == pfs_allocated_memory);
break; break;
default: default:
goto end; goto end;
......
/* Copyright (C) 2008-2009 Sun Microsystems, Inc /* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software Foundation,
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
/** /**
@file storage/perfschema/pfs_global.cc @file storage/perfschema/pfs_global.cc
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include <string.h> #include <string.h>
bool pfs_initialized= false; bool pfs_initialized= false;
ulonglong pfs_allocated_memory= 0;
/** /**
Memory allocation for the performance schema. Memory allocation for the performance schema.
...@@ -38,7 +39,9 @@ void *pfs_malloc(size_t size, myf flags) ...@@ -38,7 +39,9 @@ void *pfs_malloc(size_t size, myf flags)
DBUG_ASSERT(size > 0); DBUG_ASSERT(size > 0);
void *ptr= malloc(size); void *ptr= malloc(size);
if (ptr && (flags & MY_ZEROFILL)) if (likely(ptr != NULL))
pfs_allocated_memory+= size;
if (likely((ptr != NULL) && (flags & MY_ZEROFILL)))
memset(ptr, 0, size); memset(ptr, 0, size);
return ptr; return ptr;
} }
......
/* Copyright (C) 2008-2009 Sun Microsystems, Inc /* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software Foundation,
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
#ifndef PFS_GLOBAL_H #ifndef PFS_GLOBAL_H
#define PFS_GLOBAL_H #define PFS_GLOBAL_H
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
*/ */
extern bool pfs_initialized; extern bool pfs_initialized;
extern ulonglong pfs_allocated_memory;
void *pfs_malloc(size_t size, myf flags); void *pfs_malloc(size_t size, myf flags);
#define PFS_MALLOC_ARRAY(n, T, f) \ #define PFS_MALLOC_ARRAY(n, T, f) \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment