#At file:///Users/malff/BZR_TREE/mysql-next-mr-bugfixing-53566/ based on revid:alik@stripped
3175 Marc Alff 2010-05-11
Bug#53566 SHOW ENGINE PERFORMANCE_SCHEMA STATUS reports less memory than really used
Prior to this fix, the statement
SHOW ENGINE PERFORMANCE_SCHEMA STATUS
would report less memory that really allocated by the performance schema.
With this fix:
- memory usage is now reported accurately
- an assert enforces that everything allocated internally
is reported, to avoid future discrepancies.
No test script needed, as the existing scripts in the test suite
provide coverage when using a debug binary (with asserts).
modified:
storage/perfschema/pfs_engine_table.cc
storage/perfschema/pfs_global.cc
storage/perfschema/pfs_global.h
=== modified file 'storage/perfschema/pfs_engine_table.cc'
--- a/storage/perfschema/pfs_engine_table.cc 2010-05-03 15:04:02 +0000
+++ b/storage/perfschema/pfs_engine_table.cc 2010-05-11 14:19:09 +0000
@@ -36,6 +36,7 @@
/* For show status */
#include "pfs_column_values.h"
#include "pfs_instr.h"
+#include "pfs_global.h"
#include "sql_base.h" // close_thread_tables
#include "lock.h" // MYSQL_LOCK_IGNORE_TIMEOUT
@@ -698,6 +699,7 @@ bool pfs_show_status(handlerton *hton, T
case 40:
name= "(PFS_FILE_HANDLE).MEMORY";
size= file_handle_max * sizeof(PFS_file*);
+ total_memory+= size;
break;
case 41:
name= "EVENTS_WAITS_SUMMARY_BY_THREAD_BY_EVENT_NAME.ROW_SIZE";
@@ -712,13 +714,41 @@ bool pfs_show_status(handlerton *hton, T
size= thread_max * instr_class_per_thread * sizeof(PFS_single_stat_chain);
total_memory+= size;
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,
for aggregation in total_memory.
*/
- case 44:
+ case 50:
name= "PERFORMANCE_SCHEMA.MEMORY";
size= total_memory;
+ /* This will fail if something is not advertised here */
+ DBUG_ASSERT(size == pfs_allocated_memory);
break;
default:
goto end;
=== modified file 'storage/perfschema/pfs_global.cc'
--- a/storage/perfschema/pfs_global.cc 2010-04-19 12:26:29 +0000
+++ b/storage/perfschema/pfs_global.cc 2010-05-11 14:19:09 +0000
@@ -26,6 +26,7 @@
#include <string.h>
bool pfs_initialized= false;
+ulonglong pfs_allocated_memory= 0;
/**
Memory allocation for the performance schema.
@@ -38,7 +39,9 @@ void *pfs_malloc(size_t size, myf flags)
DBUG_ASSERT(size > 0);
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);
return ptr;
}
=== modified file 'storage/perfschema/pfs_global.h'
--- a/storage/perfschema/pfs_global.h 2010-04-14 09:54:35 +0000
+++ b/storage/perfschema/pfs_global.h 2010-05-11 14:19:09 +0000
@@ -22,6 +22,7 @@
*/
extern bool pfs_initialized;
+extern ulonglong pfs_allocated_memory;
void *pfs_malloc(size_t size, myf flags);
#define PFS_MALLOC_ARRAY(n, T, f) \
Attachment: [text/bzr-bundle] bzr/marc.alff@oracle.com-20100511141909-6qcd3gn91y53ao2s.bundle
| Thread |
|---|
| • bzr commit into mysql-next-mr-bugfixing branch (marc.alff:3175)Bug#53566 | Marc Alff | 11 May |