List:Commits« Previous MessageNext Message »
From:Marc Alff Date:June 5 2012 7:25am
Subject:bzr push into mysql-trunk branch (marc.alff:3954 to 3955) WL#6135
View as plain text  
 3955 Marc Alff	2012-06-05 [merge]
      WL#6135 PERFORMANCE_SCHEMA ENABLED BY DEFAULT
      
      Merge mysql-trunk-wl6135 --> mysql-trunk

    added:
      mysql-test/include/default_mysqld_autosize.cnf
      mysql-test/suite/perfschema/include/have_aligned_memory.inc
      mysql-test/suite/perfschema/include/sizing_auto.inc
      mysql-test/suite/perfschema/r/sizing_default.result
      mysql-test/suite/perfschema/r/sizing_growth.result
      mysql-test/suite/perfschema/r/sizing_high.result
      mysql-test/suite/perfschema/r/sizing_low.result
      mysql-test/suite/perfschema/r/sizing_med.result
      mysql-test/suite/perfschema/r/sizing_off.result
      mysql-test/suite/perfschema/t/sizing_default.cnf
      mysql-test/suite/perfschema/t/sizing_default.test
      mysql-test/suite/perfschema/t/sizing_growth.opt
      mysql-test/suite/perfschema/t/sizing_growth.test
      mysql-test/suite/perfschema/t/sizing_high.cnf
      mysql-test/suite/perfschema/t/sizing_high.test
      mysql-test/suite/perfschema/t/sizing_low.cnf
      mysql-test/suite/perfschema/t/sizing_low.test
      mysql-test/suite/perfschema/t/sizing_med.cnf
      mysql-test/suite/perfschema/t/sizing_med.test
      mysql-test/suite/perfschema/t/sizing_off.cnf
      mysql-test/suite/perfschema/t/sizing_off.test
      storage/perfschema/pfs_autosize.cc
    modified:
      libmysqld/lib_sql.cc
      mysql-test/include/default_mysqld.cnf
      mysql-test/r/mysqld--help-notwin.result
      mysql-test/r/mysqld--help-win.result
      sql/mysqld.cc
      sql/mysqld.h
      sql/sql_const.h
      sql/sys_vars.cc
      storage/perfschema/CMakeLists.txt
      storage/perfschema/pfs_engine_table.cc
      storage/perfschema/pfs_global.cc
      storage/perfschema/pfs_global.h
      storage/perfschema/pfs_server.cc
      storage/perfschema/pfs_server.h
 3954 Vasil Dimov	2012-06-04
      Followup to WL#6189 Turn InnoDB persistent statistics ON by default
      
      Adjust mtr tests, part 23.
      
      Persistent stats use a different sampling algorithm so it is possible
      that the stats numbers differ from transient stats.
      
      Also, persistent stats are updated less frequently or with a delay, so
      it is possible that persistent stats are not up to date as transient were
      even if both algorithms would return the same results.
      
      If possible, each failing test was fixed by manually running ANALYZE TABLE.
      This is doable if both transient and persistent sampling algorithms end up
      with the same numbers for the given table and its data.
      
      If persistent stats result in different stats, then test failures were fixed
      by forcing the usage of transient stats for the table by using
      CREATE TABLE ... STATS_PERSISTENT=0.
      
      Intentionally do not fix the tests by using persistent stats and adjustin
      the output of EXPLAIN in .result files because a different execution plan
      may cause a different code path to be executed, than the one originally
      intended in the test.

    modified:
      mysql-test/include/mix1.inc
      mysql-test/r/type_time.result
      mysql-test/t/type_time.test
=== modified file 'libmysqld/lib_sql.cc'
--- a/libmysqld/lib_sql.cc	2012-05-21 12:00:48 +0000
+++ b/libmysqld/lib_sql.cc	2012-05-29 23:35:24 +0000
@@ -557,6 +557,16 @@ int init_embedded_server(int argc, char
   system_charset_info= &my_charset_utf8_general_ci;
   sys_var_init();
 
+  int ho_error= handle_early_options();
+  if (ho_error != 0)
+  {
+    buffered_logs.print();
+    buffered_logs.cleanup();
+    return 1;
+  }
+
+  adjust_related_options();
+
   if (init_common_variables())
   {
     mysql_server_end();

=== modified file 'mysql-test/include/default_mysqld.cnf'
--- a/mysql-test/include/default_mysqld.cnf	2011-12-09 21:08:37 +0000
+++ b/mysql-test/include/default_mysqld.cnf	2012-06-01 08:39:34 +0000
@@ -1,4 +1,4 @@
-# Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
 #
 # 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
@@ -42,18 +42,36 @@ slave-net-timeout=120
 
 log-bin=mysqld-bin
 
+# MAINTAINER:
+# the loose- syntax is to make sure the cnf file is also
+# valid when building without the performance schema.
+
 # Run tests with the performance schema instrumentation
 loose-enable-performance-schema
 # Run tests with a small number of instrumented objects
 # to limit memory consumption with MTR
+loose-performance-schema-accounts-size=100
+loose-performance-schema-digests-size=200
+loose-performance-schema-hosts-size=100
+loose-performance-schema-users-size=100
 loose-performance-schema-max-mutex-instances=5000
 loose-performance-schema-max-rwlock-instances=5000
+loose-performance-schema-max-cond-instances=1000
+loose-performance-schema-max-file-instances=10000
+loose-performance-schema-max-socket-instances=1000
 loose-performance-schema-max-table-instances=500
 loose-performance-schema-max-table-handles=1000
 
+loose-performance-schema-events-waits-history-size=10
+loose-performance-schema-events-waits-history-long-size=10000
+loose-performance-schema-events-stages-history-size=10
 loose-performance-schema-events-stages-history-long-size=1000
+loose-performance-schema-events-statements-history-size=10
 loose-performance-schema-events-statements-history-long-size=1000
 loose-performance-schema-max-thread-instances=200
+loose-performance-schema-session-connect-attrs-size=2048
+
+# Enable everything, for maximun code exposure during testing
 
 loose-performance-schema-instrument='%=ON'
 

=== added file 'mysql-test/include/default_mysqld_autosize.cnf'
--- a/mysql-test/include/default_mysqld_autosize.cnf	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/default_mysqld_autosize.cnf	2012-05-30 11:44:42 +0000
@@ -0,0 +1,63 @@
+# Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
+#
+# 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
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
+
+# Default values that applies to all MySQL Servers
+[mysqld]
+local-infile
+character-set-server=      latin1
+
+# Increase default connect_timeout to avoid intermittent
+# disconnects when test servers are put under load see BUG#28359
+connect-timeout=            60
+
+log-bin-trust-function-creators=1
+key_buffer_size=            1M
+sort_buffer=                256K
+max_heap_table_size=        1M
+
+loose-innodb_data_file_path=      ibdata1:10M:autoextend
+loose-innodb_buffer_pool_size=    8M
+loose-innodb_lru_scan_depth=      100
+loose-innodb_write_io_threads=    2
+loose-innodb_read_io_threads=     2
+loose-innodb_log_buffer_size=     1M
+loose-innodb_log_file_size=       5M
+loose-innodb_additional_mem_pool_size= 1M
+loose-innodb_log_files_in_group=  2
+
+slave-net-timeout=120
+
+log-bin=mysqld-bin
+
+# No performance schema sizing provided
+
+# Disable everything, we only need the sizing data,
+# and also need a stable output for show engine performance_schema status
+loose-performance-schema-consumer-global-instrumentation=OFF
+
+loose-performance-schema-instrument='%=ON'
+
+loose-performance-schema-consumer-events-stages-current=ON
+loose-performance-schema-consumer-events-stages-history=ON
+loose-performance-schema-consumer-events-stages-history-long=ON
+loose-performance-schema-consumer-events-statements-current=ON
+loose-performance-schema-consumer-events-statements-history=ON
+loose-performance-schema-consumer-events-statements-history-long=ON
+loose-performance-schema-consumer-events-waits-current=ON
+loose-performance-schema-consumer-events-waits-history=ON
+loose-performance-schema-consumer-events-waits-history-long=ON
+loose-performance-schema-consumer-thread-instrumentation=ON
+
+binlog-direct-non-transactional-updates

=== modified file 'mysql-test/r/mysqld--help-notwin.result'
--- a/mysql-test/r/mysqld--help-notwin.result	2012-06-01 08:26:25 +0000
+++ b/mysql-test/r/mysqld--help-notwin.result	2012-06-01 08:45:46 +0000
@@ -498,8 +498,10 @@ The following options may be given as th
  Offset of first optimizer trace to show; see manual
  --performance-schema 
  Enable the performance schema.
+ (Defaults to on; use --skip-performance-schema to disable.)
  --performance-schema-accounts-size=# 
- Maximum number of instrumented user@host accounts.
+ Maximum number of instrumented user@host accounts. Use 0
+ to disable, -1 for automated sizing.
  --performance-schema-consumer-events-stages-current 
  Default startup value for the events_stages_current
  consumer.
@@ -540,66 +542,84 @@ The following options may be given as th
  consumer.
  (Defaults to on; use --skip-performance-schema-consumer-thread-instrumentation to disable.)
  --performance-schema-digests-size=# 
- Size of the statement digest.
+ Size of the statement digest. Use 0 to disable, -1 for
+ automated sizing.
  --performance-schema-events-stages-history-long-size=# 
- Number of rows in EVENTS_STAGES_HISTORY_LONG.
+ Number of rows in EVENTS_STAGES_HISTORY_LONG. Use 0 to
+ disable, -1 for automated sizing.
  --performance-schema-events-stages-history-size=# 
- Number of rows per thread in EVENTS_STAGES_HISTORY.
+ Number of rows per thread in EVENTS_STAGES_HISTORY. Use 0
+ to disable, -1 for automated sizing.
  --performance-schema-events-statements-history-long-size=# 
- Number of rows in EVENTS_STATEMENTS_HISTORY_LONG.
+ Number of rows in EVENTS_STATEMENTS_HISTORY_LONG. Use 0
+ to disable, -1 for automated sizing.
  --performance-schema-events-statements-history-size=# 
  Number of rows per thread in EVENTS_STATEMENTS_HISTORY.
+ Use 0 to disable, -1 for automated sizing.
  --performance-schema-events-waits-history-long-size=# 
- Number of rows in EVENTS_WAITS_HISTORY_LONG.
+ Number of rows in EVENTS_WAITS_HISTORY_LONG. Use 0 to
+ disable, -1 for automated sizing.
  --performance-schema-events-waits-history-size=# 
- Number of rows per thread in EVENTS_WAITS_HISTORY.
+ Number of rows per thread in EVENTS_WAITS_HISTORY. Use 0
+ to disable, -1 for automated sizing.
  --performance-schema-hosts-size=# 
- Maximum number of instrumented hosts.
+ Maximum number of instrumented hosts. Use 0 to disable,
+ -1 for automated sizing.
  --performance-schema-instrument[=name] 
  Default startup value for a performance schema
  instrument.
  --performance-schema-max-cond-classes=# 
  Maximum number of condition instruments.
  --performance-schema-max-cond-instances=# 
- Maximum number of instrumented condition objects.
+ Maximum number of instrumented condition objects. Use 0
+ to disable, -1 for automated sizing.
  --performance-schema-max-file-classes=# 
  Maximum number of file instruments.
  --performance-schema-max-file-handles=# 
  Maximum number of opened instrumented files.
  --performance-schema-max-file-instances=# 
- Maximum number of instrumented files.
+ Maximum number of instrumented files. Use 0 to disable,
+ -1 for automated sizing.
  --performance-schema-max-mutex-classes=# 
  Maximum number of mutex instruments.
  --performance-schema-max-mutex-instances=# 
- Maximum number of instrumented MUTEX objects.
+ Maximum number of instrumented MUTEX objects. Use 0 to
+ disable, -1 for automated sizing.
  --performance-schema-max-rwlock-classes=# 
  Maximum number of rwlock instruments.
  --performance-schema-max-rwlock-instances=# 
- Maximum number of instrumented RWLOCK objects.
+ Maximum number of instrumented RWLOCK objects. Use 0 to
+ disable, -1 for automated sizing.
  --performance-schema-max-socket-classes=# 
  Maximum number of socket instruments.
  --performance-schema-max-socket-instances=# 
- Maximum number of opened instrumented sockets.
+ Maximum number of opened instrumented sockets. Use 0 to
+ disable, -1 for automated sizing.
  --performance-schema-max-stage-classes=# 
  Maximum number of stage instruments.
  --performance-schema-max-statement-classes=# 
  Maximum number of statement instruments.
  --performance-schema-max-table-handles=# 
- Maximum number of opened instrumented tables.
+ Maximum number of opened instrumented tables. Use 0 to
+ disable, -1 for automated sizing.
  --performance-schema-max-table-instances=# 
- Maximum number of instrumented tables.
+ Maximum number of instrumented tables. Use 0 to disable,
+ -1 for automated sizing.
  --performance-schema-max-thread-classes=# 
  Maximum number of thread instruments.
  --performance-schema-max-thread-instances=# 
- Maximum number of instrumented threads.
+ Maximum number of instrumented threads. Use 0 to disable,
+ -1 for automated sizing.
  --performance-schema-session-connect-attrs-size=# 
- Size of session attribute string buffer per thread.
+ Size of session attribute string buffer per thread. Use 0
+ to disable, -1 for automated sizing.
  --performance-schema-setup-actors-size=# 
  Maximum number of rows in SETUP_ACTORS.
  --performance-schema-setup-objects-size=# 
  Maximum number of rows in SETUP_OBJECTS.
  --performance-schema-users-size=# 
- Maximum number of instrumented users.
+ Maximum number of instrumented users. Use 0 to disable,
+ -1 for automated sizing.
  --pid-file=name     Pid file used by safe_mysqld
  --plugin-dir=name   Directory for plugins
  --plugin-load=name  Optional semicolon-separated list of plugins to load,
@@ -877,7 +897,6 @@ The following options may be given as th
  safe-replicable. Since 5.0, SYSDATE() returns a `dynamic'
  value different for different invocations, even within
  the same statement.
- --table-cache=#     Deprecated; use --table-open-cache instead.
  --table-definition-cache=# 
  The number of cached table definitions
  --table-open-cache=# 
@@ -1081,8 +1100,8 @@ optimizer-trace-features greedy_search=o
 optimizer-trace-limit 1
 optimizer-trace-max-mem-size 16384
 optimizer-trace-offset -1
-performance-schema FALSE
-performance-schema-accounts-size 100
+performance-schema TRUE
+performance-schema-accounts-size -1
 performance-schema-consumer-events-stages-current FALSE
 performance-schema-consumer-events-stages-history FALSE
 performance-schema-consumer-events-stages-history-long FALSE
@@ -1095,36 +1114,36 @@ performance-schema-consumer-events-waits
 performance-schema-consumer-global-instrumentation TRUE
 performance-schema-consumer-statements-digest TRUE
 performance-schema-consumer-thread-instrumentation TRUE
-performance-schema-digests-size 200
-performance-schema-events-stages-history-long-size 10000
-performance-schema-events-stages-history-size 10
-performance-schema-events-statements-history-long-size 10000
-performance-schema-events-statements-history-size 10
-performance-schema-events-waits-history-long-size 10000
-performance-schema-events-waits-history-size 10
-performance-schema-hosts-size 100
+performance-schema-digests-size -1
+performance-schema-events-stages-history-long-size -1
+performance-schema-events-stages-history-size -1
+performance-schema-events-statements-history-long-size -1
+performance-schema-events-statements-history-size -1
+performance-schema-events-waits-history-long-size -1
+performance-schema-events-waits-history-size -1
+performance-schema-hosts-size -1
 performance-schema-instrument 
 performance-schema-max-cond-classes 80
-performance-schema-max-cond-instances 1000
+performance-schema-max-cond-instances -1
 performance-schema-max-file-classes 50
 performance-schema-max-file-handles 32768
-performance-schema-max-file-instances 10000
+performance-schema-max-file-instances -1
 performance-schema-max-mutex-classes 200
-performance-schema-max-mutex-instances 1000000
+performance-schema-max-mutex-instances -1
 performance-schema-max-rwlock-classes 30
-performance-schema-max-rwlock-instances 1000000
+performance-schema-max-rwlock-instances -1
 performance-schema-max-socket-classes 10
-performance-schema-max-socket-instances 1000
+performance-schema-max-socket-instances -1
 performance-schema-max-stage-classes 150
 performance-schema-max-statement-classes 169
-performance-schema-max-table-handles 10000
-performance-schema-max-table-instances 1000
+performance-schema-max-table-handles -1
+performance-schema-max-table-instances -1
 performance-schema-max-thread-classes 50
-performance-schema-max-thread-instances 1000
-performance-schema-session-connect-attrs-size 2048
+performance-schema-max-thread-instances -1
+performance-schema-session-connect-attrs-size -1
 performance-schema-setup-actors-size 100
 performance-schema-setup-objects-size 100
-performance-schema-users-size 100
+performance-schema-users-size -1
 port 3306
 port-open-timeout 0
 preload-buffer-size 32768
@@ -1189,7 +1208,6 @@ sync-master-info 0
 sync-relay-log 0
 sync-relay-log-info 0
 sysdate-is-now FALSE
-table-cache 400
 table-definition-cache 400
 table-open-cache 400
 table-open-cache-instances 1

=== modified file 'mysql-test/r/mysqld--help-win.result'
--- a/mysql-test/r/mysqld--help-win.result	2012-06-01 08:26:25 +0000
+++ b/mysql-test/r/mysqld--help-win.result	2012-06-01 08:45:46 +0000
@@ -498,8 +498,10 @@ The following options may be given as th
  Offset of first optimizer trace to show; see manual
  --performance-schema 
  Enable the performance schema.
+ (Defaults to on; use --skip-performance-schema to disable.)
  --performance-schema-accounts-size=# 
- Maximum number of instrumented user@host accounts.
+ Maximum number of instrumented user@host accounts. Use 0
+ to disable, -1 for automated sizing.
  --performance-schema-consumer-events-stages-current 
  Default startup value for the events_stages_current
  consumer.
@@ -540,66 +542,84 @@ The following options may be given as th
  consumer.
  (Defaults to on; use --skip-performance-schema-consumer-thread-instrumentation to disable.)
  --performance-schema-digests-size=# 
- Size of the statement digest.
+ Size of the statement digest. Use 0 to disable, -1 for
+ automated sizing.
  --performance-schema-events-stages-history-long-size=# 
- Number of rows in EVENTS_STAGES_HISTORY_LONG.
+ Number of rows in EVENTS_STAGES_HISTORY_LONG. Use 0 to
+ disable, -1 for automated sizing.
  --performance-schema-events-stages-history-size=# 
- Number of rows per thread in EVENTS_STAGES_HISTORY.
+ Number of rows per thread in EVENTS_STAGES_HISTORY. Use 0
+ to disable, -1 for automated sizing.
  --performance-schema-events-statements-history-long-size=# 
- Number of rows in EVENTS_STATEMENTS_HISTORY_LONG.
+ Number of rows in EVENTS_STATEMENTS_HISTORY_LONG. Use 0
+ to disable, -1 for automated sizing.
  --performance-schema-events-statements-history-size=# 
  Number of rows per thread in EVENTS_STATEMENTS_HISTORY.
+ Use 0 to disable, -1 for automated sizing.
  --performance-schema-events-waits-history-long-size=# 
- Number of rows in EVENTS_WAITS_HISTORY_LONG.
+ Number of rows in EVENTS_WAITS_HISTORY_LONG. Use 0 to
+ disable, -1 for automated sizing.
  --performance-schema-events-waits-history-size=# 
- Number of rows per thread in EVENTS_WAITS_HISTORY.
+ Number of rows per thread in EVENTS_WAITS_HISTORY. Use 0
+ to disable, -1 for automated sizing.
  --performance-schema-hosts-size=# 
- Maximum number of instrumented hosts.
+ Maximum number of instrumented hosts. Use 0 to disable,
+ -1 for automated sizing.
  --performance-schema-instrument[=name] 
  Default startup value for a performance schema
  instrument.
  --performance-schema-max-cond-classes=# 
  Maximum number of condition instruments.
  --performance-schema-max-cond-instances=# 
- Maximum number of instrumented condition objects.
+ Maximum number of instrumented condition objects. Use 0
+ to disable, -1 for automated sizing.
  --performance-schema-max-file-classes=# 
  Maximum number of file instruments.
  --performance-schema-max-file-handles=# 
  Maximum number of opened instrumented files.
  --performance-schema-max-file-instances=# 
- Maximum number of instrumented files.
+ Maximum number of instrumented files. Use 0 to disable,
+ -1 for automated sizing.
  --performance-schema-max-mutex-classes=# 
  Maximum number of mutex instruments.
  --performance-schema-max-mutex-instances=# 
- Maximum number of instrumented MUTEX objects.
+ Maximum number of instrumented MUTEX objects. Use 0 to
+ disable, -1 for automated sizing.
  --performance-schema-max-rwlock-classes=# 
  Maximum number of rwlock instruments.
  --performance-schema-max-rwlock-instances=# 
- Maximum number of instrumented RWLOCK objects.
+ Maximum number of instrumented RWLOCK objects. Use 0 to
+ disable, -1 for automated sizing.
  --performance-schema-max-socket-classes=# 
  Maximum number of socket instruments.
  --performance-schema-max-socket-instances=# 
- Maximum number of opened instrumented sockets.
+ Maximum number of opened instrumented sockets. Use 0 to
+ disable, -1 for automated sizing.
  --performance-schema-max-stage-classes=# 
  Maximum number of stage instruments.
  --performance-schema-max-statement-classes=# 
  Maximum number of statement instruments.
  --performance-schema-max-table-handles=# 
- Maximum number of opened instrumented tables.
+ Maximum number of opened instrumented tables. Use 0 to
+ disable, -1 for automated sizing.
  --performance-schema-max-table-instances=# 
- Maximum number of instrumented tables.
+ Maximum number of instrumented tables. Use 0 to disable,
+ -1 for automated sizing.
  --performance-schema-max-thread-classes=# 
  Maximum number of thread instruments.
  --performance-schema-max-thread-instances=# 
- Maximum number of instrumented threads.
+ Maximum number of instrumented threads. Use 0 to disable,
+ -1 for automated sizing.
  --performance-schema-session-connect-attrs-size=# 
- Size of session attribute string buffer per thread.
+ Size of session attribute string buffer per thread. Use 0
+ to disable, -1 for automated sizing.
  --performance-schema-setup-actors-size=# 
  Maximum number of rows in SETUP_ACTORS.
  --performance-schema-setup-objects-size=# 
  Maximum number of rows in SETUP_OBJECTS.
  --performance-schema-users-size=# 
- Maximum number of instrumented users.
+ Maximum number of instrumented users. Use 0 to disable,
+ -1 for automated sizing.
  --pid-file=name     Pid file used by safe_mysqld
  --plugin-dir=name   Directory for plugins
  --plugin-load=name  Optional semicolon-separated list of plugins to load,
@@ -885,7 +905,6 @@ The following options may be given as th
  safe-replicable. Since 5.0, SYSDATE() returns a `dynamic'
  value different for different invocations, even within
  the same statement.
- --table-cache=#     Deprecated; use --table-open-cache instead.
  --table-definition-cache=# 
  The number of cached table definitions
  --table-open-cache=# 
@@ -1089,8 +1108,8 @@ optimizer-trace-features greedy_search=o
 optimizer-trace-limit 1
 optimizer-trace-max-mem-size 16384
 optimizer-trace-offset -1
-performance-schema FALSE
-performance-schema-accounts-size 100
+performance-schema TRUE
+performance-schema-accounts-size -1
 performance-schema-consumer-events-stages-current FALSE
 performance-schema-consumer-events-stages-history FALSE
 performance-schema-consumer-events-stages-history-long FALSE
@@ -1103,36 +1122,36 @@ performance-schema-consumer-events-waits
 performance-schema-consumer-global-instrumentation TRUE
 performance-schema-consumer-statements-digest TRUE
 performance-schema-consumer-thread-instrumentation TRUE
-performance-schema-digests-size 200
-performance-schema-events-stages-history-long-size 10000
-performance-schema-events-stages-history-size 10
-performance-schema-events-statements-history-long-size 10000
-performance-schema-events-statements-history-size 10
-performance-schema-events-waits-history-long-size 10000
-performance-schema-events-waits-history-size 10
-performance-schema-hosts-size 100
+performance-schema-digests-size -1
+performance-schema-events-stages-history-long-size -1
+performance-schema-events-stages-history-size -1
+performance-schema-events-statements-history-long-size -1
+performance-schema-events-statements-history-size -1
+performance-schema-events-waits-history-long-size -1
+performance-schema-events-waits-history-size -1
+performance-schema-hosts-size -1
 performance-schema-instrument 
 performance-schema-max-cond-classes 80
-performance-schema-max-cond-instances 1000
+performance-schema-max-cond-instances -1
 performance-schema-max-file-classes 50
 performance-schema-max-file-handles 32768
-performance-schema-max-file-instances 10000
+performance-schema-max-file-instances -1
 performance-schema-max-mutex-classes 200
-performance-schema-max-mutex-instances 1000000
+performance-schema-max-mutex-instances -1
 performance-schema-max-rwlock-classes 30
-performance-schema-max-rwlock-instances 1000000
+performance-schema-max-rwlock-instances -1
 performance-schema-max-socket-classes 10
-performance-schema-max-socket-instances 1000
+performance-schema-max-socket-instances -1
 performance-schema-max-stage-classes 150
 performance-schema-max-statement-classes 169
-performance-schema-max-table-handles 10000
-performance-schema-max-table-instances 1000
+performance-schema-max-table-handles -1
+performance-schema-max-table-instances -1
 performance-schema-max-thread-classes 50
-performance-schema-max-thread-instances 1000
-performance-schema-session-connect-attrs-size 2048
+performance-schema-max-thread-instances -1
+performance-schema-session-connect-attrs-size -1
 performance-schema-setup-actors-size 100
 performance-schema-setup-objects-size 100
-performance-schema-users-size 100
+performance-schema-users-size -1
 port 3306
 port-open-timeout 0
 preload-buffer-size 32768
@@ -1200,7 +1219,6 @@ sync-master-info 0
 sync-relay-log 0
 sync-relay-log-info 0
 sysdate-is-now FALSE
-table-cache 400
 table-definition-cache 400
 table-open-cache 400
 table-open-cache-instances 1

=== added file 'mysql-test/suite/perfschema/include/have_aligned_memory.inc'
--- a/mysql-test/suite/perfschema/include/have_aligned_memory.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/include/have_aligned_memory.inc	2012-05-30 23:04:50 +0000
@@ -0,0 +1,13 @@
+# The performance schema internal structures are compiled with PFS_ALIGN,
+# and the sizeof() structures is platform dependent.
+#
+# For tests sensitive to the internal sizes (show engine performance_schema
+# status), make sure we use a platform with aligned memory.
+
+--disable_query_log
+let $aligned = `SELECT count(*) from performance_schema.session_connect_attrs where PROCESSLIST_ID = connection_id() and ATTR_NAME = '_os' and ATTR_VALUE in ('Linux', 'Windows')`;
+if (!$aligned)
+{
+  skip Need a platform with aligned memory;
+}
+--enable_query_log

=== added file 'mysql-test/suite/perfschema/include/sizing_auto.inc'
--- a/mysql-test/suite/perfschema/include/sizing_auto.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/include/sizing_auto.inc	2012-06-01 08:39:34 +0000
@@ -0,0 +1,16 @@
+
+show variables like "table_definition_cache";
+show variables like "table_open_cache";
+show variables like "max_connections";
+# Results vary by platform:
+# show variables like "open_files_limit";
+show variables like "%performance_schema%";
+show status like "%performance_schema%";
+
+# Each test script should provide a different test.cnf file,
+# with different settings.
+# This output will show the sizes computed automatically.
+# Note that this output is very dependent on the platform.
+
+show engine performance_schema status;
+

=== added file 'mysql-test/suite/perfschema/r/sizing_default.result'
--- a/mysql-test/suite/perfschema/r/sizing_default.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/r/sizing_default.result	2012-06-01 08:39:34 +0000
@@ -0,0 +1,226 @@
+show variables like "table_definition_cache";
+Variable_name	Value
+table_definition_cache	400
+show variables like "table_open_cache";
+Variable_name	Value
+table_open_cache	400
+show variables like "max_connections";
+Variable_name	Value
+max_connections	151
+show variables like "%performance_schema%";
+Variable_name	Value
+performance_schema	ON
+performance_schema_accounts_size	10
+performance_schema_digests_size	1000
+performance_schema_events_stages_history_long_size	100
+performance_schema_events_stages_history_size	5
+performance_schema_events_statements_history_long_size	100
+performance_schema_events_statements_history_size	5
+performance_schema_events_waits_history_long_size	100
+performance_schema_events_waits_history_size	5
+performance_schema_hosts_size	20
+performance_schema_max_cond_classes	80
+performance_schema_max_cond_instances	836
+performance_schema_max_file_classes	50
+performance_schema_max_file_handles	32768
+performance_schema_max_file_instances	1138
+performance_schema_max_mutex_classes	200
+performance_schema_max_mutex_instances	2393
+performance_schema_max_rwlock_classes	30
+performance_schema_max_rwlock_instances	1724
+performance_schema_max_socket_classes	10
+performance_schema_max_socket_instances	179
+performance_schema_max_stage_classes	150
+performance_schema_max_statement_classes	169
+performance_schema_max_table_handles	445
+performance_schema_max_table_instances	445
+performance_schema_max_thread_classes	50
+performance_schema_max_thread_instances	224
+performance_schema_session_connect_attrs_size	512
+performance_schema_setup_actors_size	100
+performance_schema_setup_objects_size	100
+performance_schema_users_size	5
+show status like "%performance_schema%";
+Variable_name	Value
+Performance_schema_accounts_lost	0
+Performance_schema_cond_classes_lost	0
+Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
+Performance_schema_file_classes_lost	0
+Performance_schema_file_handles_lost	0
+Performance_schema_file_instances_lost	0
+Performance_schema_hosts_lost	0
+Performance_schema_locker_lost	0
+Performance_schema_mutex_classes_lost	0
+Performance_schema_mutex_instances_lost	0
+Performance_schema_rwlock_classes_lost	0
+Performance_schema_rwlock_instances_lost	0
+Performance_schema_session_connect_attrs_lost	0
+Performance_schema_socket_classes_lost	0
+Performance_schema_socket_instances_lost	0
+Performance_schema_stage_classes_lost	0
+Performance_schema_statement_classes_lost	0
+Performance_schema_table_handles_lost	0
+Performance_schema_table_instances_lost	0
+Performance_schema_thread_classes_lost	0
+Performance_schema_thread_instances_lost	0
+Performance_schema_users_lost	0
+show engine performance_schema status;
+Type	Name	Status
+performance_schema	events_waits_current.row_size	184
+performance_schema	events_waits_current.row_count	1344
+performance_schema	events_waits_history.row_size	184
+performance_schema	events_waits_history.row_count	1120
+performance_schema	events_waits_history.memory	206080
+performance_schema	events_waits_history_long.row_size	184
+performance_schema	events_waits_history_long.row_count	100
+performance_schema	events_waits_history_long.memory	18400
+performance_schema	(pfs_mutex_class).row_size	256
+performance_schema	(pfs_mutex_class).row_count	200
+performance_schema	(pfs_mutex_class).memory	51200
+performance_schema	(pfs_rwlock_class).row_size	256
+performance_schema	(pfs_rwlock_class).row_count	30
+performance_schema	(pfs_rwlock_class).memory	7680
+performance_schema	(pfs_cond_class).row_size	192
+performance_schema	(pfs_cond_class).row_count	80
+performance_schema	(pfs_cond_class).memory	15360
+performance_schema	(pfs_thread_class).row_size	192
+performance_schema	(pfs_thread_class).row_count	50
+performance_schema	(pfs_thread_class).memory	9600
+performance_schema	(pfs_file_class).row_size	320
+performance_schema	(pfs_file_class).row_count	50
+performance_schema	(pfs_file_class).memory	16000
+performance_schema	mutex_instances.row_size	192
+performance_schema	mutex_instances.row_count	2393
+performance_schema	mutex_instances.memory	459456
+performance_schema	rwlock_instances.row_size	192
+performance_schema	rwlock_instances.row_count	1724
+performance_schema	rwlock_instances.memory	331008
+performance_schema	cond_instances.row_size	128
+performance_schema	cond_instances.row_count	836
+performance_schema	cond_instances.memory	107008
+performance_schema	threads.row_size	1856
+performance_schema	threads.row_count	224
+performance_schema	threads.memory	415744
+performance_schema	file_instances.row_size	768
+performance_schema	file_instances.row_count	1138
+performance_schema	file_instances.memory	873984
+performance_schema	(pfs_file_handle).row_size	8
+performance_schema	(pfs_file_handle).row_count	32768
+performance_schema	(pfs_file_handle).memory	262144
+performance_schema	events_waits_summary_by_thread_by_event_name.row_size	32
+performance_schema	events_waits_summary_by_thread_by_event_name.row_count	83552
+performance_schema	events_waits_summary_by_thread_by_event_name.memory	2673664
+performance_schema	(pfs_table_share).row_size	22208
+performance_schema	(pfs_table_share).row_count	445
+performance_schema	(pfs_table_share).memory	9882560
+performance_schema	(pfs_table).row_size	9280
+performance_schema	(pfs_table).row_count	445
+performance_schema	(pfs_table).memory	4129600
+performance_schema	setup_actors.row_size	256
+performance_schema	setup_actors.row_count	100
+performance_schema	setup_actors.memory	25600
+performance_schema	setup_objects.row_size	448
+performance_schema	setup_objects.row_count	100
+performance_schema	setup_objects.memory	44800
+performance_schema	events_waits_summary_global_by_event_name.row_size	32
+performance_schema	events_waits_summary_global_by_event_name.row_count	373
+performance_schema	events_waits_summary_global_by_event_name.memory	11936
+performance_schema	(pfs_account).row_size	256
+performance_schema	(pfs_account).row_count	10
+performance_schema	(pfs_account).memory	2560
+performance_schema	events_waits_summary_by_account_by_event_name.row_size	32
+performance_schema	events_waits_summary_by_account_by_event_name.row_count	3730
+performance_schema	events_waits_summary_by_account_by_event_name.memory	119360
+performance_schema	events_waits_summary_by_user_by_event_name.row_size	32
+performance_schema	events_waits_summary_by_user_by_event_name.row_count	1865
+performance_schema	events_waits_summary_by_user_by_event_name.memory	59680
+performance_schema	events_waits_summary_by_host_by_event_name.row_size	32
+performance_schema	events_waits_summary_by_host_by_event_name.row_count	7460
+performance_schema	events_waits_summary_by_host_by_event_name.memory	238720
+performance_schema	(pfs_user).row_size	128
+performance_schema	(pfs_user).row_count	5
+performance_schema	(pfs_user).memory	640
+performance_schema	(pfs_host).row_size	192
+performance_schema	(pfs_host).row_count	20
+performance_schema	(pfs_host).memory	3840
+performance_schema	(pfs_stage_class).row_size	192
+performance_schema	(pfs_stage_class).row_count	150
+performance_schema	(pfs_stage_class).memory	28800
+performance_schema	events_stages_history.row_size	88
+performance_schema	events_stages_history.row_count	1120
+performance_schema	events_stages_history.memory	98560
+performance_schema	events_stages_history_long.row_size	88
+performance_schema	events_stages_history_long.row_count	100
+performance_schema	events_stages_history_long.memory	8800
+performance_schema	events_stages_summary_by_thread_by_event_name.row_size	32
+performance_schema	events_stages_summary_by_thread_by_event_name.row_count	33600
+performance_schema	events_stages_summary_by_thread_by_event_name.memory	1075200
+performance_schema	events_stages_summary_global_by_event_name.row_size	32
+performance_schema	events_stages_summary_global_by_event_name.row_count	150
+performance_schema	events_stages_summary_global_by_event_name.memory	4800
+performance_schema	events_stages_summary_by_account_by_event_name.row_size	32
+performance_schema	events_stages_summary_by_account_by_event_name.row_count	1500
+performance_schema	events_stages_summary_by_account_by_event_name.memory	48000
+performance_schema	events_stages_summary_by_user_by_event_name.row_size	32
+performance_schema	events_stages_summary_by_user_by_event_name.row_count	750
+performance_schema	events_stages_summary_by_user_by_event_name.memory	24000
+performance_schema	events_stages_summary_by_host_by_event_name.row_size	32
+performance_schema	events_stages_summary_by_host_by_event_name.row_count	3000
+performance_schema	events_stages_summary_by_host_by_event_name.memory	96000
+performance_schema	(pfs_statement_class).row_size	192
+performance_schema	(pfs_statement_class).row_count	169
+performance_schema	(pfs_statement_class).memory	32448
+performance_schema	events_statements_history.row_size	3024
+performance_schema	events_statements_history.row_count	1120
+performance_schema	events_statements_history.memory	3386880
+performance_schema	events_statements_history_long.row_size	3024
+performance_schema	events_statements_history_long.row_count	100
+performance_schema	events_statements_history_long.memory	302400
+performance_schema	events_statements_summary_by_thread_by_event_name.row_size	184
+performance_schema	events_statements_summary_by_thread_by_event_name.row_count	37856
+performance_schema	events_statements_summary_by_thread_by_event_name.memory	6965504
+performance_schema	events_statements_summary_global_by_event_name.row_size	184
+performance_schema	events_statements_summary_global_by_event_name.row_count	169
+performance_schema	events_statements_summary_global_by_event_name.memory	31096
+performance_schema	events_statements_summary_by_account_by_event_name.row_size	184
+performance_schema	events_statements_summary_by_account_by_event_name.row_count	1690
+performance_schema	events_statements_summary_by_account_by_event_name.memory	310960
+performance_schema	events_statements_summary_by_user_by_event_name.row_size	184
+performance_schema	events_statements_summary_by_user_by_event_name.row_count	845
+performance_schema	events_statements_summary_by_user_by_event_name.memory	155480
+performance_schema	events_statements_summary_by_host_by_event_name.row_size	184
+performance_schema	events_statements_summary_by_host_by_event_name.row_count	3380
+performance_schema	events_statements_summary_by_host_by_event_name.memory	621920
+performance_schema	events_statements_current.row_size	3024
+performance_schema	events_statements_current.row_count	224
+performance_schema	events_statements_current.memory	677376
+performance_schema	(pfs_socket_class).row_size	320
+performance_schema	(pfs_socket_class).row_count	10
+performance_schema	(pfs_socket_class).memory	3200
+performance_schema	socket_instances.row_size	384
+performance_schema	socket_instances.row_count	179
+performance_schema	socket_instances.memory	68736
+performance_schema	events_statements_summary_by_digest.row_size	1280
+performance_schema	events_statements_summary_by_digest.row_count	1000
+performance_schema	events_statements_summary_by_digest.memory	1280000
+performance_schema	session_connect_attrs.row_size	224
+performance_schema	session_connect_attrs.row_count	512
+performance_schema	session_connect_attrs.memory	114688
+performance_schema	(account_hash).count	2
+performance_schema	(account_hash).size	10
+performance_schema	(digest_hash).count	0
+performance_schema	(digest_hash).size	1000
+performance_schema	(filename_hash).count	0
+performance_schema	(filename_hash).size	1138
+performance_schema	(host_hash).count	2
+performance_schema	(host_hash).size	20
+performance_schema	(setup_actor_hash).count	1
+performance_schema	(setup_actor_hash).size	100
+performance_schema	(setup_object_hash).count	4
+performance_schema	(setup_object_hash).size	100
+performance_schema	(table_share_hash).count	83
+performance_schema	(table_share_hash).size	445
+performance_schema	(user_hash).count	2
+performance_schema	(user_hash).size	5
+performance_schema	performance_schema.memory	35301472

=== added file 'mysql-test/suite/perfschema/r/sizing_growth.result'
--- a/mysql-test/suite/perfschema/r/sizing_growth.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/r/sizing_growth.result	2012-05-25 13:22:34 +0000
@@ -0,0 +1,216 @@
+flush status;
+flush tables;
+select * from performance_schema.mutex_instances;
+select * from performance_schema.rwlock_instances;
+select * from performance_schema.cond_instances;
+select * from performance_schema.file_instances;
+select count(*) from performance_schema.mutex_instances
+into @v0_mutex_instances;
+select count(*) from performance_schema.rwlock_instances
+into @v0_rwlock_instances;
+select count(*) from performance_schema.cond_instances
+into @v0_cond_instances;
+select count(*) from performance_schema.file_instances
+into @v0_file_instances;
+select count(*) from performance_schema.mutex_instances
+into @v1_mutex_instances;
+select count(*) from performance_schema.rwlock_instances
+into @v1_rwlock_instances;
+select count(*) from performance_schema.cond_instances
+into @v1_cond_instances;
+select count(*) from performance_schema.file_instances
+into @v1_file_instances;
+select count(name), name from performance_schema.mutex_instances
+group by name;
+select count(name), name from performance_schema.rwlock_instances
+group by name;
+select count(name), name from performance_schema.cond_instances
+group by name;
+select count(event_name), event_name from performance_schema.file_instances
+group by event_name;
+begin;
+create table test.t1(a int) engine = innodb;
+create table test.t2(a int) engine = innodb;
+create table test.t3(a int) engine = innodb;
+create table test.t4(a int) engine = innodb;
+create table test.t5(a int) engine = innodb;
+create table test.t6(a int) engine = innodb;
+create table test.t7(a int) engine = innodb;
+create table test.t8(a int) engine = innodb;
+create table test.t9(a int) engine = innodb;
+create table test.t10(a int) engine = innodb;
+select * from test.t1;
+select * from test.t2;
+select * from test.t3;
+select * from test.t4;
+select * from test.t5;
+select * from test.t6;
+select * from test.t7;
+select * from test.t8;
+select * from test.t9;
+select * from test.t10;
+commit;
+select count(*) from performance_schema.mutex_instances
+into @v2_mutex_instances;
+select count(*) from performance_schema.rwlock_instances
+into @v2_rwlock_instances;
+select count(*) from performance_schema.cond_instances
+into @v2_cond_instances;
+select count(*) from performance_schema.file_instances
+into @v2_file_instances;
+select count(name), name from performance_schema.mutex_instances
+group by name;
+select count(name), name from performance_schema.rwlock_instances
+group by name;
+select count(name), name from performance_schema.cond_instances
+group by name;
+select count(event_name), event_name from performance_schema.file_instances
+group by event_name;
+select @v2_mutex_instances, @v1_mutex_instances, @v0_mutex_instances;
+select @v2_rwlock_instances, @v1_rwlock_instances, @v0_rwlock_instances;
+select @v2_cond_instances, @v1_cond_instances, @v0_cond_instances;
+select @v2_file_instances, @v1_file_instances, @v0_file_instances;
+select round((@v2_mutex_instances - @v1_mutex_instances) / 10)
+into @mutex_per_share;
+select round((@v2_rwlock_instances - @v1_rwlock_instances) / 10)
+into @rwlock_per_share;
+select round((@v2_cond_instances - @v1_cond_instances) / 10)
+into @cond_per_share;
+select round((@v2_file_instances - @v1_file_instances) / 10)
+into @file_per_share;
+select "con1 connected";
+select "con2 connected";
+select "con3 connected";
+select "con4 connected";
+select "con5 connected";
+select "con6 connected";
+select "con7 connected";
+select "con8 connected";
+select "con9 connected";
+select "con10 connected";
+select count(*) from performance_schema.mutex_instances
+into @v3_mutex_instances;
+select count(*) from performance_schema.rwlock_instances
+into @v3_rwlock_instances;
+select count(*) from performance_schema.cond_instances
+into @v3_cond_instances;
+select count(*) from performance_schema.file_instances
+into @v3_file_instances;
+select count(name), name from performance_schema.mutex_instances
+group by name;
+select count(name), name from performance_schema.rwlock_instances
+group by name;
+select count(name), name from performance_schema.cond_instances
+group by name;
+select count(event_name), event_name from performance_schema.file_instances
+group by event_name;
+select @v3_mutex_instances, @v2_mutex_instances;
+select @v3_rwlock_instances, @v2_rwlock_instances;
+select @v3_cond_instances, @v2_cond_instances;
+select @v3_file_instances, @v2_file_instances;
+select round((@v3_mutex_instances - @v2_mutex_instances) / 10)
+into @mutex_per_con;
+select round((@v3_rwlock_instances - @v2_rwlock_instances) / 10)
+into @rwlock_per_con;
+select round((@v3_cond_instances - @v2_cond_instances) / 10)
+into @cond_per_con;
+select round((@v3_file_instances - @v2_file_instances) / 10)
+into @file_per_con;
+lock table test.t1 write, test.t2 write, test.t3 write, test.t4 write,
+test.t5 write, test.t6 write, test.t7 write, test.t8 write, test.t9 write,
+test.t10 write;
+select t1.*, t2.*, t3.*, t4.*, t5.*, t6.*, t7.*, t8.*, t9.*, t10.*
+from t1, t2, t3, t4, t5, t6, t7, t8, t9, t10;
+select t1.*, t2.*, t3.*, t4.*, t5.*, t6.*, t7.*, t8.*, t9.*, t10.*
+from t1, t2, t3, t4, t5, t6, t7, t8, t9, t10;
+select t1.*, t2.*, t3.*, t4.*, t5.*, t6.*, t7.*, t8.*, t9.*, t10.*
+from t1, t2, t3, t4, t5, t6, t7, t8, t9, t10;
+select t1.*, t2.*, t3.*, t4.*, t5.*, t6.*, t7.*, t8.*, t9.*, t10.*
+from t1, t2, t3, t4, t5, t6, t7, t8, t9, t10;
+select t1.*, t2.*, t3.*, t4.*, t5.*, t6.*, t7.*, t8.*, t9.*, t10.*
+from t1, t2, t3, t4, t5, t6, t7, t8, t9, t10;
+select t1.*, t2.*, t3.*, t4.*, t5.*, t6.*, t7.*, t8.*, t9.*, t10.*
+from t1, t2, t3, t4, t5, t6, t7, t8, t9, t10;
+select t1.*, t2.*, t3.*, t4.*, t5.*, t6.*, t7.*, t8.*, t9.*, t10.*
+from t1, t2, t3, t4, t5, t6, t7, t8, t9, t10;
+select t1.*, t2.*, t3.*, t4.*, t5.*, t6.*, t7.*, t8.*, t9.*, t10.*
+from t1, t2, t3, t4, t5, t6, t7, t8, t9, t10;
+select t1.*, t2.*, t3.*, t4.*, t5.*, t6.*, t7.*, t8.*, t9.*, t10.*
+from t1, t2, t3, t4, t5, t6, t7, t8, t9, t10;
+select t1.*, t2.*, t3.*, t4.*, t5.*, t6.*, t7.*, t8.*, t9.*, t10.*
+from t1, t2, t3, t4, t5, t6, t7, t8, t9, t10;
+select count(*) from performance_schema.mutex_instances
+into @v4_mutex_instances;
+select count(*) from performance_schema.rwlock_instances
+into @v4_rwlock_instances;
+select count(*) from performance_schema.cond_instances
+into @v4_cond_instances;
+select count(*) from performance_schema.file_instances
+into @v4_file_instances;
+select count(name), name from performance_schema.mutex_instances
+group by name;
+select count(name), name from performance_schema.rwlock_instances
+group by name;
+select count(name), name from performance_schema.cond_instances
+group by name;
+select count(event_name), event_name from performance_schema.file_instances
+group by event_name;
+select @v4_mutex_instances, @v3_mutex_instances;
+select @v4_rwlock_instances, @v3_rwlock_instances;
+select @v4_cond_instances, @v3_cond_instances;
+select @v4_file_instances, @v3_file_instances;
+select round((@v4_mutex_instances - @v3_mutex_instances) / 10)
+into @mutex_per_handle;
+select round((@v4_rwlock_instances - @v3_rwlock_instances) / 10)
+into @rwlock_per_handle;
+select round((@v4_cond_instances - @v3_cond_instances) / 10)
+into @cond_per_handle;
+select round((@v4_file_instances - @v3_file_instances) / 10)
+into @file_per_handle;
+unlock tables;
+drop table test.t1;
+drop table test.t2;
+drop table test.t3;
+drop table test.t4;
+drop table test.t5;
+drop table test.t6;
+drop table test.t7;
+drop table test.t8;
+drop table test.t9;
+drop table test.t10;
+select @mutex_per_share;
+@mutex_per_share
+3
+select @rwlock_per_share;
+@rwlock_per_share
+1
+select @cond_per_share;
+@cond_per_share
+0
+select @file_per_share;
+@file_per_share
+2
+select @mutex_per_con;
+@mutex_per_con
+3
+select @rwlock_per_con;
+@rwlock_per_con
+1
+select @cond_per_con;
+@cond_per_con
+2
+select @file_per_con;
+@file_per_con
+0
+select @mutex_per_handle;
+@mutex_per_handle
+0
+select @rwlock_per_handle;
+@rwlock_per_handle
+0
+select @cond_per_handle;
+@cond_per_handle
+0
+select @file_per_handle;
+@file_per_handle
+0

=== added file 'mysql-test/suite/perfschema/r/sizing_high.result'
--- a/mysql-test/suite/perfschema/r/sizing_high.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/r/sizing_high.result	2012-06-01 08:39:34 +0000
@@ -0,0 +1,226 @@
+show variables like "table_definition_cache";
+Variable_name	Value
+table_definition_cache	5000
+show variables like "table_open_cache";
+Variable_name	Value
+table_open_cache	400
+show variables like "max_connections";
+Variable_name	Value
+max_connections	200
+show variables like "%performance_schema%";
+Variable_name	Value
+performance_schema	ON
+performance_schema_accounts_size	100
+performance_schema_digests_size	10000
+performance_schema_events_stages_history_long_size	10000
+performance_schema_events_stages_history_size	10
+performance_schema_events_statements_history_long_size	10000
+performance_schema_events_statements_history_size	10
+performance_schema_events_waits_history_long_size	10000
+performance_schema_events_waits_history_size	10
+performance_schema_hosts_size	100
+performance_schema_max_cond_classes	80
+performance_schema_max_cond_instances	10900
+performance_schema_max_file_classes	50
+performance_schema_max_file_handles	32768
+performance_schema_max_file_instances	15693
+performance_schema_max_mutex_classes	200
+performance_schema_max_mutex_instances	32200
+performance_schema_max_rwlock_classes	30
+performance_schema_max_rwlock_instances	30800
+performance_schema_max_socket_classes	10
+performance_schema_max_socket_instances	420
+performance_schema_max_stage_classes	150
+performance_schema_max_statement_classes	169
+performance_schema_max_table_handles	800
+performance_schema_max_table_instances	12500
+performance_schema_max_thread_classes	50
+performance_schema_max_thread_instances	500
+performance_schema_session_connect_attrs_size	512
+performance_schema_setup_actors_size	100
+performance_schema_setup_objects_size	100
+performance_schema_users_size	100
+show status like "%performance_schema%";
+Variable_name	Value
+Performance_schema_accounts_lost	0
+Performance_schema_cond_classes_lost	0
+Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
+Performance_schema_file_classes_lost	0
+Performance_schema_file_handles_lost	0
+Performance_schema_file_instances_lost	0
+Performance_schema_hosts_lost	0
+Performance_schema_locker_lost	0
+Performance_schema_mutex_classes_lost	0
+Performance_schema_mutex_instances_lost	0
+Performance_schema_rwlock_classes_lost	0
+Performance_schema_rwlock_instances_lost	0
+Performance_schema_session_connect_attrs_lost	0
+Performance_schema_socket_classes_lost	0
+Performance_schema_socket_instances_lost	0
+Performance_schema_stage_classes_lost	0
+Performance_schema_statement_classes_lost	0
+Performance_schema_table_handles_lost	0
+Performance_schema_table_instances_lost	0
+Performance_schema_thread_classes_lost	0
+Performance_schema_thread_instances_lost	0
+Performance_schema_users_lost	0
+show engine performance_schema status;
+Type	Name	Status
+performance_schema	events_waits_current.row_size	184
+performance_schema	events_waits_current.row_count	3000
+performance_schema	events_waits_history.row_size	184
+performance_schema	events_waits_history.row_count	5000
+performance_schema	events_waits_history.memory	920000
+performance_schema	events_waits_history_long.row_size	184
+performance_schema	events_waits_history_long.row_count	10000
+performance_schema	events_waits_history_long.memory	1840000
+performance_schema	(pfs_mutex_class).row_size	256
+performance_schema	(pfs_mutex_class).row_count	200
+performance_schema	(pfs_mutex_class).memory	51200
+performance_schema	(pfs_rwlock_class).row_size	256
+performance_schema	(pfs_rwlock_class).row_count	30
+performance_schema	(pfs_rwlock_class).memory	7680
+performance_schema	(pfs_cond_class).row_size	192
+performance_schema	(pfs_cond_class).row_count	80
+performance_schema	(pfs_cond_class).memory	15360
+performance_schema	(pfs_thread_class).row_size	192
+performance_schema	(pfs_thread_class).row_count	50
+performance_schema	(pfs_thread_class).memory	9600
+performance_schema	(pfs_file_class).row_size	320
+performance_schema	(pfs_file_class).row_count	50
+performance_schema	(pfs_file_class).memory	16000
+performance_schema	mutex_instances.row_size	192
+performance_schema	mutex_instances.row_count	32200
+performance_schema	mutex_instances.memory	6182400
+performance_schema	rwlock_instances.row_size	192
+performance_schema	rwlock_instances.row_count	30800
+performance_schema	rwlock_instances.memory	5913600
+performance_schema	cond_instances.row_size	128
+performance_schema	cond_instances.row_count	10900
+performance_schema	cond_instances.memory	1395200
+performance_schema	threads.row_size	1856
+performance_schema	threads.row_count	500
+performance_schema	threads.memory	928000
+performance_schema	file_instances.row_size	768
+performance_schema	file_instances.row_count	15693
+performance_schema	file_instances.memory	12052224
+performance_schema	(pfs_file_handle).row_size	8
+performance_schema	(pfs_file_handle).row_count	32768
+performance_schema	(pfs_file_handle).memory	262144
+performance_schema	events_waits_summary_by_thread_by_event_name.row_size	32
+performance_schema	events_waits_summary_by_thread_by_event_name.row_count	186500
+performance_schema	events_waits_summary_by_thread_by_event_name.memory	5968000
+performance_schema	(pfs_table_share).row_size	22208
+performance_schema	(pfs_table_share).row_count	12500
+performance_schema	(pfs_table_share).memory	277600000
+performance_schema	(pfs_table).row_size	9280
+performance_schema	(pfs_table).row_count	800
+performance_schema	(pfs_table).memory	7424000
+performance_schema	setup_actors.row_size	256
+performance_schema	setup_actors.row_count	100
+performance_schema	setup_actors.memory	25600
+performance_schema	setup_objects.row_size	448
+performance_schema	setup_objects.row_count	100
+performance_schema	setup_objects.memory	44800
+performance_schema	events_waits_summary_global_by_event_name.row_size	32
+performance_schema	events_waits_summary_global_by_event_name.row_count	373
+performance_schema	events_waits_summary_global_by_event_name.memory	11936
+performance_schema	(pfs_account).row_size	256
+performance_schema	(pfs_account).row_count	100
+performance_schema	(pfs_account).memory	25600
+performance_schema	events_waits_summary_by_account_by_event_name.row_size	32
+performance_schema	events_waits_summary_by_account_by_event_name.row_count	37300
+performance_schema	events_waits_summary_by_account_by_event_name.memory	1193600
+performance_schema	events_waits_summary_by_user_by_event_name.row_size	32
+performance_schema	events_waits_summary_by_user_by_event_name.row_count	37300
+performance_schema	events_waits_summary_by_user_by_event_name.memory	1193600
+performance_schema	events_waits_summary_by_host_by_event_name.row_size	32
+performance_schema	events_waits_summary_by_host_by_event_name.row_count	37300
+performance_schema	events_waits_summary_by_host_by_event_name.memory	1193600
+performance_schema	(pfs_user).row_size	128
+performance_schema	(pfs_user).row_count	100
+performance_schema	(pfs_user).memory	12800
+performance_schema	(pfs_host).row_size	192
+performance_schema	(pfs_host).row_count	100
+performance_schema	(pfs_host).memory	19200
+performance_schema	(pfs_stage_class).row_size	192
+performance_schema	(pfs_stage_class).row_count	150
+performance_schema	(pfs_stage_class).memory	28800
+performance_schema	events_stages_history.row_size	88
+performance_schema	events_stages_history.row_count	5000
+performance_schema	events_stages_history.memory	440000
+performance_schema	events_stages_history_long.row_size	88
+performance_schema	events_stages_history_long.row_count	10000
+performance_schema	events_stages_history_long.memory	880000
+performance_schema	events_stages_summary_by_thread_by_event_name.row_size	32
+performance_schema	events_stages_summary_by_thread_by_event_name.row_count	75000
+performance_schema	events_stages_summary_by_thread_by_event_name.memory	2400000
+performance_schema	events_stages_summary_global_by_event_name.row_size	32
+performance_schema	events_stages_summary_global_by_event_name.row_count	150
+performance_schema	events_stages_summary_global_by_event_name.memory	4800
+performance_schema	events_stages_summary_by_account_by_event_name.row_size	32
+performance_schema	events_stages_summary_by_account_by_event_name.row_count	15000
+performance_schema	events_stages_summary_by_account_by_event_name.memory	480000
+performance_schema	events_stages_summary_by_user_by_event_name.row_size	32
+performance_schema	events_stages_summary_by_user_by_event_name.row_count	15000
+performance_schema	events_stages_summary_by_user_by_event_name.memory	480000
+performance_schema	events_stages_summary_by_host_by_event_name.row_size	32
+performance_schema	events_stages_summary_by_host_by_event_name.row_count	15000
+performance_schema	events_stages_summary_by_host_by_event_name.memory	480000
+performance_schema	(pfs_statement_class).row_size	192
+performance_schema	(pfs_statement_class).row_count	169
+performance_schema	(pfs_statement_class).memory	32448
+performance_schema	events_statements_history.row_size	3024
+performance_schema	events_statements_history.row_count	5000
+performance_schema	events_statements_history.memory	15120000
+performance_schema	events_statements_history_long.row_size	3024
+performance_schema	events_statements_history_long.row_count	10000
+performance_schema	events_statements_history_long.memory	30240000
+performance_schema	events_statements_summary_by_thread_by_event_name.row_size	184
+performance_schema	events_statements_summary_by_thread_by_event_name.row_count	84500
+performance_schema	events_statements_summary_by_thread_by_event_name.memory	15548000
+performance_schema	events_statements_summary_global_by_event_name.row_size	184
+performance_schema	events_statements_summary_global_by_event_name.row_count	169
+performance_schema	events_statements_summary_global_by_event_name.memory	31096
+performance_schema	events_statements_summary_by_account_by_event_name.row_size	184
+performance_schema	events_statements_summary_by_account_by_event_name.row_count	16900
+performance_schema	events_statements_summary_by_account_by_event_name.memory	3109600
+performance_schema	events_statements_summary_by_user_by_event_name.row_size	184
+performance_schema	events_statements_summary_by_user_by_event_name.row_count	16900
+performance_schema	events_statements_summary_by_user_by_event_name.memory	3109600
+performance_schema	events_statements_summary_by_host_by_event_name.row_size	184
+performance_schema	events_statements_summary_by_host_by_event_name.row_count	16900
+performance_schema	events_statements_summary_by_host_by_event_name.memory	3109600
+performance_schema	events_statements_current.row_size	3024
+performance_schema	events_statements_current.row_count	500
+performance_schema	events_statements_current.memory	1512000
+performance_schema	(pfs_socket_class).row_size	320
+performance_schema	(pfs_socket_class).row_count	10
+performance_schema	(pfs_socket_class).memory	3200
+performance_schema	socket_instances.row_size	384
+performance_schema	socket_instances.row_count	420
+performance_schema	socket_instances.memory	161280
+performance_schema	events_statements_summary_by_digest.row_size	1280
+performance_schema	events_statements_summary_by_digest.row_count	10000
+performance_schema	events_statements_summary_by_digest.memory	12800000
+performance_schema	session_connect_attrs.row_size	500
+performance_schema	session_connect_attrs.row_count	512
+performance_schema	session_connect_attrs.memory	256000
+performance_schema	(account_hash).count	2
+performance_schema	(account_hash).size	100
+performance_schema	(digest_hash).count	0
+performance_schema	(digest_hash).size	10000
+performance_schema	(filename_hash).count	0
+performance_schema	(filename_hash).size	15693
+performance_schema	(host_hash).count	2
+performance_schema	(host_hash).size	100
+performance_schema	(setup_actor_hash).count	1
+performance_schema	(setup_actor_hash).size	100
+performance_schema	(setup_object_hash).count	4
+performance_schema	(setup_object_hash).size	100
+performance_schema	(table_share_hash).count	83
+performance_schema	(table_share_hash).size	12500
+performance_schema	(user_hash).count	2
+performance_schema	(user_hash).size	100
+performance_schema	performance_schema.memory	414532568

=== added file 'mysql-test/suite/perfschema/r/sizing_low.result'
--- a/mysql-test/suite/perfschema/r/sizing_low.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/r/sizing_low.result	2012-06-01 08:39:34 +0000
@@ -0,0 +1,226 @@
+show variables like "table_definition_cache";
+Variable_name	Value
+table_definition_cache	400
+show variables like "table_open_cache";
+Variable_name	Value
+table_open_cache	100
+show variables like "max_connections";
+Variable_name	Value
+max_connections	50
+show variables like "%performance_schema%";
+Variable_name	Value
+performance_schema	ON
+performance_schema_accounts_size	10
+performance_schema_digests_size	1000
+performance_schema_events_stages_history_long_size	100
+performance_schema_events_stages_history_size	5
+performance_schema_events_statements_history_long_size	100
+performance_schema_events_statements_history_size	5
+performance_schema_events_waits_history_long_size	100
+performance_schema_events_waits_history_size	5
+performance_schema_hosts_size	20
+performance_schema_max_cond_classes	80
+performance_schema_max_cond_instances	612
+performance_schema_max_file_classes	50
+performance_schema_max_file_handles	32768
+performance_schema_max_file_instances	1138
+performance_schema_max_mutex_classes	200
+performance_schema_max_mutex_instances	2056
+performance_schema_max_rwlock_classes	30
+performance_schema_max_rwlock_instances	1612
+performance_schema_max_socket_classes	10
+performance_schema_max_socket_instances	67
+performance_schema_max_stage_classes	150
+performance_schema_max_statement_classes	169
+performance_schema_max_table_handles	112
+performance_schema_max_table_instances	445
+performance_schema_max_thread_classes	50
+performance_schema_max_thread_instances	112
+performance_schema_session_connect_attrs_size	512
+performance_schema_setup_actors_size	100
+performance_schema_setup_objects_size	100
+performance_schema_users_size	5
+show status like "%performance_schema%";
+Variable_name	Value
+Performance_schema_accounts_lost	0
+Performance_schema_cond_classes_lost	0
+Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
+Performance_schema_file_classes_lost	0
+Performance_schema_file_handles_lost	0
+Performance_schema_file_instances_lost	0
+Performance_schema_hosts_lost	0
+Performance_schema_locker_lost	0
+Performance_schema_mutex_classes_lost	0
+Performance_schema_mutex_instances_lost	0
+Performance_schema_rwlock_classes_lost	0
+Performance_schema_rwlock_instances_lost	0
+Performance_schema_session_connect_attrs_lost	0
+Performance_schema_socket_classes_lost	0
+Performance_schema_socket_instances_lost	0
+Performance_schema_stage_classes_lost	0
+Performance_schema_statement_classes_lost	0
+Performance_schema_table_handles_lost	0
+Performance_schema_table_instances_lost	0
+Performance_schema_thread_classes_lost	0
+Performance_schema_thread_instances_lost	0
+Performance_schema_users_lost	0
+show engine performance_schema status;
+Type	Name	Status
+performance_schema	events_waits_current.row_size	184
+performance_schema	events_waits_current.row_count	672
+performance_schema	events_waits_history.row_size	184
+performance_schema	events_waits_history.row_count	560
+performance_schema	events_waits_history.memory	103040
+performance_schema	events_waits_history_long.row_size	184
+performance_schema	events_waits_history_long.row_count	100
+performance_schema	events_waits_history_long.memory	18400
+performance_schema	(pfs_mutex_class).row_size	256
+performance_schema	(pfs_mutex_class).row_count	200
+performance_schema	(pfs_mutex_class).memory	51200
+performance_schema	(pfs_rwlock_class).row_size	256
+performance_schema	(pfs_rwlock_class).row_count	30
+performance_schema	(pfs_rwlock_class).memory	7680
+performance_schema	(pfs_cond_class).row_size	192
+performance_schema	(pfs_cond_class).row_count	80
+performance_schema	(pfs_cond_class).memory	15360
+performance_schema	(pfs_thread_class).row_size	192
+performance_schema	(pfs_thread_class).row_count	50
+performance_schema	(pfs_thread_class).memory	9600
+performance_schema	(pfs_file_class).row_size	320
+performance_schema	(pfs_file_class).row_count	50
+performance_schema	(pfs_file_class).memory	16000
+performance_schema	mutex_instances.row_size	192
+performance_schema	mutex_instances.row_count	2056
+performance_schema	mutex_instances.memory	394752
+performance_schema	rwlock_instances.row_size	192
+performance_schema	rwlock_instances.row_count	1612
+performance_schema	rwlock_instances.memory	309504
+performance_schema	cond_instances.row_size	128
+performance_schema	cond_instances.row_count	612
+performance_schema	cond_instances.memory	78336
+performance_schema	threads.row_size	1856
+performance_schema	threads.row_count	112
+performance_schema	threads.memory	207872
+performance_schema	file_instances.row_size	768
+performance_schema	file_instances.row_count	1138
+performance_schema	file_instances.memory	873984
+performance_schema	(pfs_file_handle).row_size	8
+performance_schema	(pfs_file_handle).row_count	32768
+performance_schema	(pfs_file_handle).memory	262144
+performance_schema	events_waits_summary_by_thread_by_event_name.row_size	32
+performance_schema	events_waits_summary_by_thread_by_event_name.row_count	41776
+performance_schema	events_waits_summary_by_thread_by_event_name.memory	1336832
+performance_schema	(pfs_table_share).row_size	22208
+performance_schema	(pfs_table_share).row_count	445
+performance_schema	(pfs_table_share).memory	9882560
+performance_schema	(pfs_table).row_size	9280
+performance_schema	(pfs_table).row_count	112
+performance_schema	(pfs_table).memory	1039360
+performance_schema	setup_actors.row_size	256
+performance_schema	setup_actors.row_count	100
+performance_schema	setup_actors.memory	25600
+performance_schema	setup_objects.row_size	448
+performance_schema	setup_objects.row_count	100
+performance_schema	setup_objects.memory	44800
+performance_schema	events_waits_summary_global_by_event_name.row_size	32
+performance_schema	events_waits_summary_global_by_event_name.row_count	373
+performance_schema	events_waits_summary_global_by_event_name.memory	11936
+performance_schema	(pfs_account).row_size	256
+performance_schema	(pfs_account).row_count	10
+performance_schema	(pfs_account).memory	2560
+performance_schema	events_waits_summary_by_account_by_event_name.row_size	32
+performance_schema	events_waits_summary_by_account_by_event_name.row_count	3730
+performance_schema	events_waits_summary_by_account_by_event_name.memory	119360
+performance_schema	events_waits_summary_by_user_by_event_name.row_size	32
+performance_schema	events_waits_summary_by_user_by_event_name.row_count	1865
+performance_schema	events_waits_summary_by_user_by_event_name.memory	59680
+performance_schema	events_waits_summary_by_host_by_event_name.row_size	32
+performance_schema	events_waits_summary_by_host_by_event_name.row_count	7460
+performance_schema	events_waits_summary_by_host_by_event_name.memory	238720
+performance_schema	(pfs_user).row_size	128
+performance_schema	(pfs_user).row_count	5
+performance_schema	(pfs_user).memory	640
+performance_schema	(pfs_host).row_size	192
+performance_schema	(pfs_host).row_count	20
+performance_schema	(pfs_host).memory	3840
+performance_schema	(pfs_stage_class).row_size	192
+performance_schema	(pfs_stage_class).row_count	150
+performance_schema	(pfs_stage_class).memory	28800
+performance_schema	events_stages_history.row_size	88
+performance_schema	events_stages_history.row_count	560
+performance_schema	events_stages_history.memory	49280
+performance_schema	events_stages_history_long.row_size	88
+performance_schema	events_stages_history_long.row_count	100
+performance_schema	events_stages_history_long.memory	8800
+performance_schema	events_stages_summary_by_thread_by_event_name.row_size	32
+performance_schema	events_stages_summary_by_thread_by_event_name.row_count	16800
+performance_schema	events_stages_summary_by_thread_by_event_name.memory	537600
+performance_schema	events_stages_summary_global_by_event_name.row_size	32
+performance_schema	events_stages_summary_global_by_event_name.row_count	150
+performance_schema	events_stages_summary_global_by_event_name.memory	4800
+performance_schema	events_stages_summary_by_account_by_event_name.row_size	32
+performance_schema	events_stages_summary_by_account_by_event_name.row_count	1500
+performance_schema	events_stages_summary_by_account_by_event_name.memory	48000
+performance_schema	events_stages_summary_by_user_by_event_name.row_size	32
+performance_schema	events_stages_summary_by_user_by_event_name.row_count	750
+performance_schema	events_stages_summary_by_user_by_event_name.memory	24000
+performance_schema	events_stages_summary_by_host_by_event_name.row_size	32
+performance_schema	events_stages_summary_by_host_by_event_name.row_count	3000
+performance_schema	events_stages_summary_by_host_by_event_name.memory	96000
+performance_schema	(pfs_statement_class).row_size	192
+performance_schema	(pfs_statement_class).row_count	169
+performance_schema	(pfs_statement_class).memory	32448
+performance_schema	events_statements_history.row_size	3024
+performance_schema	events_statements_history.row_count	560
+performance_schema	events_statements_history.memory	1693440
+performance_schema	events_statements_history_long.row_size	3024
+performance_schema	events_statements_history_long.row_count	100
+performance_schema	events_statements_history_long.memory	302400
+performance_schema	events_statements_summary_by_thread_by_event_name.row_size	184
+performance_schema	events_statements_summary_by_thread_by_event_name.row_count	18928
+performance_schema	events_statements_summary_by_thread_by_event_name.memory	3482752
+performance_schema	events_statements_summary_global_by_event_name.row_size	184
+performance_schema	events_statements_summary_global_by_event_name.row_count	169
+performance_schema	events_statements_summary_global_by_event_name.memory	31096
+performance_schema	events_statements_summary_by_account_by_event_name.row_size	184
+performance_schema	events_statements_summary_by_account_by_event_name.row_count	1690
+performance_schema	events_statements_summary_by_account_by_event_name.memory	310960
+performance_schema	events_statements_summary_by_user_by_event_name.row_size	184
+performance_schema	events_statements_summary_by_user_by_event_name.row_count	845
+performance_schema	events_statements_summary_by_user_by_event_name.memory	155480
+performance_schema	events_statements_summary_by_host_by_event_name.row_size	184
+performance_schema	events_statements_summary_by_host_by_event_name.row_count	3380
+performance_schema	events_statements_summary_by_host_by_event_name.memory	621920
+performance_schema	events_statements_current.row_size	3024
+performance_schema	events_statements_current.row_count	112
+performance_schema	events_statements_current.memory	338688
+performance_schema	(pfs_socket_class).row_size	320
+performance_schema	(pfs_socket_class).row_count	10
+performance_schema	(pfs_socket_class).memory	3200
+performance_schema	socket_instances.row_size	384
+performance_schema	socket_instances.row_count	67
+performance_schema	socket_instances.memory	25728
+performance_schema	events_statements_summary_by_digest.row_size	1280
+performance_schema	events_statements_summary_by_digest.row_count	1000
+performance_schema	events_statements_summary_by_digest.memory	1280000
+performance_schema	session_connect_attrs.row_size	112
+performance_schema	session_connect_attrs.row_count	512
+performance_schema	session_connect_attrs.memory	57344
+performance_schema	(account_hash).count	2
+performance_schema	(account_hash).size	10
+performance_schema	(digest_hash).count	0
+performance_schema	(digest_hash).size	1000
+performance_schema	(filename_hash).count	0
+performance_schema	(filename_hash).size	1138
+performance_schema	(host_hash).count	2
+performance_schema	(host_hash).size	20
+performance_schema	(setup_actor_hash).count	1
+performance_schema	(setup_actor_hash).size	100
+performance_schema	(setup_object_hash).count	4
+performance_schema	(setup_object_hash).size	100
+performance_schema	(table_share_hash).count	83
+performance_schema	(table_share_hash).size	445
+performance_schema	(user_hash).count	2
+performance_schema	(user_hash).size	5
+performance_schema	performance_schema.memory	24246496

=== added file 'mysql-test/suite/perfschema/r/sizing_med.result'
--- a/mysql-test/suite/perfschema/r/sizing_med.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/r/sizing_med.result	2012-06-01 08:39:34 +0000
@@ -0,0 +1,226 @@
+show variables like "table_definition_cache";
+Variable_name	Value
+table_definition_cache	401
+show variables like "table_open_cache";
+Variable_name	Value
+table_open_cache	401
+show variables like "max_connections";
+Variable_name	Value
+max_connections	152
+show variables like "%performance_schema%";
+Variable_name	Value
+performance_schema	ON
+performance_schema_accounts_size	100
+performance_schema_digests_size	5000
+performance_schema_events_stages_history_long_size	1000
+performance_schema_events_stages_history_size	10
+performance_schema_events_statements_history_long_size	1000
+performance_schema_events_statements_history_size	10
+performance_schema_events_waits_history_long_size	1000
+performance_schema_events_waits_history_size	10
+performance_schema_hosts_size	100
+performance_schema_max_cond_classes	80
+performance_schema_max_cond_instances	1079
+performance_schema_max_file_classes	50
+performance_schema_max_file_handles	32768
+performance_schema_max_file_instances	1280
+performance_schema_max_mutex_classes	200
+performance_schema_max_mutex_instances	3085
+performance_schema_max_rwlock_classes	30
+performance_schema_max_rwlock_instances	2222
+performance_schema_max_socket_classes	10
+performance_schema_max_socket_instances	232
+performance_schema_max_stage_classes	150
+performance_schema_max_statement_classes	169
+performance_schema_max_table_handles	573
+performance_schema_max_table_instances	556
+performance_schema_max_thread_classes	50
+performance_schema_max_thread_instances	289
+performance_schema_session_connect_attrs_size	512
+performance_schema_setup_actors_size	100
+performance_schema_setup_objects_size	100
+performance_schema_users_size	100
+show status like "%performance_schema%";
+Variable_name	Value
+Performance_schema_accounts_lost	0
+Performance_schema_cond_classes_lost	0
+Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
+Performance_schema_file_classes_lost	0
+Performance_schema_file_handles_lost	0
+Performance_schema_file_instances_lost	0
+Performance_schema_hosts_lost	0
+Performance_schema_locker_lost	0
+Performance_schema_mutex_classes_lost	0
+Performance_schema_mutex_instances_lost	0
+Performance_schema_rwlock_classes_lost	0
+Performance_schema_rwlock_instances_lost	0
+Performance_schema_session_connect_attrs_lost	0
+Performance_schema_socket_classes_lost	0
+Performance_schema_socket_instances_lost	0
+Performance_schema_stage_classes_lost	0
+Performance_schema_statement_classes_lost	0
+Performance_schema_table_handles_lost	0
+Performance_schema_table_instances_lost	0
+Performance_schema_thread_classes_lost	0
+Performance_schema_thread_instances_lost	0
+Performance_schema_users_lost	0
+show engine performance_schema status;
+Type	Name	Status
+performance_schema	events_waits_current.row_size	184
+performance_schema	events_waits_current.row_count	1734
+performance_schema	events_waits_history.row_size	184
+performance_schema	events_waits_history.row_count	2890
+performance_schema	events_waits_history.memory	531760
+performance_schema	events_waits_history_long.row_size	184
+performance_schema	events_waits_history_long.row_count	1000
+performance_schema	events_waits_history_long.memory	184000
+performance_schema	(pfs_mutex_class).row_size	256
+performance_schema	(pfs_mutex_class).row_count	200
+performance_schema	(pfs_mutex_class).memory	51200
+performance_schema	(pfs_rwlock_class).row_size	256
+performance_schema	(pfs_rwlock_class).row_count	30
+performance_schema	(pfs_rwlock_class).memory	7680
+performance_schema	(pfs_cond_class).row_size	192
+performance_schema	(pfs_cond_class).row_count	80
+performance_schema	(pfs_cond_class).memory	15360
+performance_schema	(pfs_thread_class).row_size	192
+performance_schema	(pfs_thread_class).row_count	50
+performance_schema	(pfs_thread_class).memory	9600
+performance_schema	(pfs_file_class).row_size	320
+performance_schema	(pfs_file_class).row_count	50
+performance_schema	(pfs_file_class).memory	16000
+performance_schema	mutex_instances.row_size	192
+performance_schema	mutex_instances.row_count	3085
+performance_schema	mutex_instances.memory	592320
+performance_schema	rwlock_instances.row_size	192
+performance_schema	rwlock_instances.row_count	2222
+performance_schema	rwlock_instances.memory	426624
+performance_schema	cond_instances.row_size	128
+performance_schema	cond_instances.row_count	1079
+performance_schema	cond_instances.memory	138112
+performance_schema	threads.row_size	1856
+performance_schema	threads.row_count	289
+performance_schema	threads.memory	536384
+performance_schema	file_instances.row_size	768
+performance_schema	file_instances.row_count	1280
+performance_schema	file_instances.memory	983040
+performance_schema	(pfs_file_handle).row_size	8
+performance_schema	(pfs_file_handle).row_count	32768
+performance_schema	(pfs_file_handle).memory	262144
+performance_schema	events_waits_summary_by_thread_by_event_name.row_size	32
+performance_schema	events_waits_summary_by_thread_by_event_name.row_count	107797
+performance_schema	events_waits_summary_by_thread_by_event_name.memory	3449504
+performance_schema	(pfs_table_share).row_size	22208
+performance_schema	(pfs_table_share).row_count	556
+performance_schema	(pfs_table_share).memory	12347648
+performance_schema	(pfs_table).row_size	9280
+performance_schema	(pfs_table).row_count	573
+performance_schema	(pfs_table).memory	5317440
+performance_schema	setup_actors.row_size	256
+performance_schema	setup_actors.row_count	100
+performance_schema	setup_actors.memory	25600
+performance_schema	setup_objects.row_size	448
+performance_schema	setup_objects.row_count	100
+performance_schema	setup_objects.memory	44800
+performance_schema	events_waits_summary_global_by_event_name.row_size	32
+performance_schema	events_waits_summary_global_by_event_name.row_count	373
+performance_schema	events_waits_summary_global_by_event_name.memory	11936
+performance_schema	(pfs_account).row_size	256
+performance_schema	(pfs_account).row_count	100
+performance_schema	(pfs_account).memory	25600
+performance_schema	events_waits_summary_by_account_by_event_name.row_size	32
+performance_schema	events_waits_summary_by_account_by_event_name.row_count	37300
+performance_schema	events_waits_summary_by_account_by_event_name.memory	1193600
+performance_schema	events_waits_summary_by_user_by_event_name.row_size	32
+performance_schema	events_waits_summary_by_user_by_event_name.row_count	37300
+performance_schema	events_waits_summary_by_user_by_event_name.memory	1193600
+performance_schema	events_waits_summary_by_host_by_event_name.row_size	32
+performance_schema	events_waits_summary_by_host_by_event_name.row_count	37300
+performance_schema	events_waits_summary_by_host_by_event_name.memory	1193600
+performance_schema	(pfs_user).row_size	128
+performance_schema	(pfs_user).row_count	100
+performance_schema	(pfs_user).memory	12800
+performance_schema	(pfs_host).row_size	192
+performance_schema	(pfs_host).row_count	100
+performance_schema	(pfs_host).memory	19200
+performance_schema	(pfs_stage_class).row_size	192
+performance_schema	(pfs_stage_class).row_count	150
+performance_schema	(pfs_stage_class).memory	28800
+performance_schema	events_stages_history.row_size	88
+performance_schema	events_stages_history.row_count	2890
+performance_schema	events_stages_history.memory	254320
+performance_schema	events_stages_history_long.row_size	88
+performance_schema	events_stages_history_long.row_count	1000
+performance_schema	events_stages_history_long.memory	88000
+performance_schema	events_stages_summary_by_thread_by_event_name.row_size	32
+performance_schema	events_stages_summary_by_thread_by_event_name.row_count	43350
+performance_schema	events_stages_summary_by_thread_by_event_name.memory	1387200
+performance_schema	events_stages_summary_global_by_event_name.row_size	32
+performance_schema	events_stages_summary_global_by_event_name.row_count	150
+performance_schema	events_stages_summary_global_by_event_name.memory	4800
+performance_schema	events_stages_summary_by_account_by_event_name.row_size	32
+performance_schema	events_stages_summary_by_account_by_event_name.row_count	15000
+performance_schema	events_stages_summary_by_account_by_event_name.memory	480000
+performance_schema	events_stages_summary_by_user_by_event_name.row_size	32
+performance_schema	events_stages_summary_by_user_by_event_name.row_count	15000
+performance_schema	events_stages_summary_by_user_by_event_name.memory	480000
+performance_schema	events_stages_summary_by_host_by_event_name.row_size	32
+performance_schema	events_stages_summary_by_host_by_event_name.row_count	15000
+performance_schema	events_stages_summary_by_host_by_event_name.memory	480000
+performance_schema	(pfs_statement_class).row_size	192
+performance_schema	(pfs_statement_class).row_count	169
+performance_schema	(pfs_statement_class).memory	32448
+performance_schema	events_statements_history.row_size	3024
+performance_schema	events_statements_history.row_count	2890
+performance_schema	events_statements_history.memory	8739360
+performance_schema	events_statements_history_long.row_size	3024
+performance_schema	events_statements_history_long.row_count	1000
+performance_schema	events_statements_history_long.memory	3024000
+performance_schema	events_statements_summary_by_thread_by_event_name.row_size	184
+performance_schema	events_statements_summary_by_thread_by_event_name.row_count	48841
+performance_schema	events_statements_summary_by_thread_by_event_name.memory	8986744
+performance_schema	events_statements_summary_global_by_event_name.row_size	184
+performance_schema	events_statements_summary_global_by_event_name.row_count	169
+performance_schema	events_statements_summary_global_by_event_name.memory	31096
+performance_schema	events_statements_summary_by_account_by_event_name.row_size	184
+performance_schema	events_statements_summary_by_account_by_event_name.row_count	16900
+performance_schema	events_statements_summary_by_account_by_event_name.memory	3109600
+performance_schema	events_statements_summary_by_user_by_event_name.row_size	184
+performance_schema	events_statements_summary_by_user_by_event_name.row_count	16900
+performance_schema	events_statements_summary_by_user_by_event_name.memory	3109600
+performance_schema	events_statements_summary_by_host_by_event_name.row_size	184
+performance_schema	events_statements_summary_by_host_by_event_name.row_count	16900
+performance_schema	events_statements_summary_by_host_by_event_name.memory	3109600
+performance_schema	events_statements_current.row_size	3024
+performance_schema	events_statements_current.row_count	289
+performance_schema	events_statements_current.memory	873936
+performance_schema	(pfs_socket_class).row_size	320
+performance_schema	(pfs_socket_class).row_count	10
+performance_schema	(pfs_socket_class).memory	3200
+performance_schema	socket_instances.row_size	384
+performance_schema	socket_instances.row_count	232
+performance_schema	socket_instances.memory	89088
+performance_schema	events_statements_summary_by_digest.row_size	1280
+performance_schema	events_statements_summary_by_digest.row_count	5000
+performance_schema	events_statements_summary_by_digest.memory	6400000
+performance_schema	session_connect_attrs.row_size	289
+performance_schema	session_connect_attrs.row_count	512
+performance_schema	session_connect_attrs.memory	147968
+performance_schema	(account_hash).count	2
+performance_schema	(account_hash).size	100
+performance_schema	(digest_hash).count	0
+performance_schema	(digest_hash).size	5000
+performance_schema	(filename_hash).count	0
+performance_schema	(filename_hash).size	1280
+performance_schema	(host_hash).count	2
+performance_schema	(host_hash).size	100
+performance_schema	(setup_actor_hash).count	1
+performance_schema	(setup_actor_hash).size	100
+performance_schema	(setup_object_hash).count	4
+performance_schema	(setup_object_hash).size	100
+performance_schema	(table_share_hash).count	83
+performance_schema	(table_share_hash).size	556
+performance_schema	(user_hash).count	2
+performance_schema	(user_hash).size	100
+performance_schema	performance_schema.memory	69449312

=== added file 'mysql-test/suite/perfschema/r/sizing_off.result'
--- a/mysql-test/suite/perfschema/r/sizing_off.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/r/sizing_off.result	2012-06-01 10:05:58 +0000
@@ -0,0 +1,58 @@
+show variables like "performance_schema%";
+Variable_name	Value
+performance_schema	OFF
+performance_schema_accounts_size	-1
+performance_schema_digests_size	-1
+performance_schema_events_stages_history_long_size	-1
+performance_schema_events_stages_history_size	-1
+performance_schema_events_statements_history_long_size	-1
+performance_schema_events_statements_history_size	-1
+performance_schema_events_waits_history_long_size	-1
+performance_schema_events_waits_history_size	-1
+performance_schema_hosts_size	-1
+performance_schema_max_cond_classes	80
+performance_schema_max_cond_instances	-1
+performance_schema_max_file_classes	50
+performance_schema_max_file_handles	32768
+performance_schema_max_file_instances	-1
+performance_schema_max_mutex_classes	200
+performance_schema_max_mutex_instances	-1
+performance_schema_max_rwlock_classes	30
+performance_schema_max_rwlock_instances	-1
+performance_schema_max_socket_classes	10
+performance_schema_max_socket_instances	-1
+performance_schema_max_stage_classes	150
+performance_schema_max_statement_classes	169
+performance_schema_max_table_handles	-1
+performance_schema_max_table_instances	-1
+performance_schema_max_thread_classes	50
+performance_schema_max_thread_instances	-1
+performance_schema_session_connect_attrs_size	-1
+performance_schema_setup_actors_size	100
+performance_schema_setup_objects_size	100
+performance_schema_users_size	-1
+show status like "performance_schema%";
+Variable_name	Value
+Performance_schema_accounts_lost	0
+Performance_schema_cond_classes_lost	0
+Performance_schema_cond_instances_lost	0
+Performance_schema_digest_lost	0
+Performance_schema_file_classes_lost	0
+Performance_schema_file_handles_lost	0
+Performance_schema_file_instances_lost	0
+Performance_schema_hosts_lost	0
+Performance_schema_locker_lost	0
+Performance_schema_mutex_classes_lost	0
+Performance_schema_mutex_instances_lost	0
+Performance_schema_rwlock_classes_lost	0
+Performance_schema_rwlock_instances_lost	0
+Performance_schema_session_connect_attrs_lost	0
+Performance_schema_socket_classes_lost	0
+Performance_schema_socket_instances_lost	0
+Performance_schema_stage_classes_lost	0
+Performance_schema_statement_classes_lost	0
+Performance_schema_table_handles_lost	0
+Performance_schema_table_instances_lost	0
+Performance_schema_thread_classes_lost	0
+Performance_schema_thread_instances_lost	0
+Performance_schema_users_lost	0

=== added file 'mysql-test/suite/perfschema/t/sizing_default.cnf'
--- a/mysql-test/suite/perfschema/t/sizing_default.cnf	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/sizing_default.cnf	2012-05-30 11:44:42 +0000
@@ -0,0 +1,34 @@
+
+!include include/default_mysqld_autosize.cnf
+
+[mysqld.1]
+
+# Default values used in the server, out of the box
+table_definition_cache=400
+table_open_cache=400
+max_connections=151
+open_files_limit=1024
+
+# Automated sizing for everything
+
+loose-performance-schema-accounts-size=-1
+loose-performance-schema-digests-size=-1
+loose-performance-schema-hosts-size=-1
+loose-performance-schema-users-size=-1
+
+loose-performance-schema-events-waits-history-size=-1
+loose-performance-schema-events-waits-history-long-size=-1
+loose-performance-schema-events-stages-history-size=-1
+loose-performance-schema-events-stages-history-long-size=-1
+loose-performance-schema-events-statements-history-size=-1
+loose-performance-schema-events-statements-history-long-size=-1
+
+loose-performance-schema-max-mutex-instances=-1
+loose-performance-schema-max-rwlock-instances=-1
+loose-performance-schema-max-cond-instances=-1
+loose-performance-schema-max-file-instances=-1
+loose-performance-schema-max-socket-instances=-1
+loose-performance-schema-max-thread-instances=-1
+loose-performance-schema-max-table-instances=-1
+loose-performance-schema-max-table-handles=-1
+

=== added file 'mysql-test/suite/perfschema/t/sizing_default.test'
--- a/mysql-test/suite/perfschema/t/sizing_default.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/sizing_default.test	2012-06-04 14:12:37 +0000
@@ -0,0 +1,9 @@
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source include/have_64bit.inc
+--source include/not_valgrind.inc
+--source ../include/have_aligned_memory.inc
+
+--source ../include/sizing_auto.inc
+

=== added file 'mysql-test/suite/perfschema/t/sizing_growth.opt'
--- a/mysql-test/suite/perfschema/t/sizing_growth.opt	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/sizing_growth.opt	2012-05-25 13:22:34 +0000
@@ -0,0 +1,3 @@
+--force-restart
+--innodb_file_per_table=1
+

=== added file 'mysql-test/suite/perfschema/t/sizing_growth.test'
--- a/mysql-test/suite/perfschema/t/sizing_growth.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/sizing_growth.test	2012-05-25 13:22:34 +0000
@@ -0,0 +1,429 @@
+# Tests for PERFORMANCE_SCHEMA
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+#
+# Important note:
+# this test is extremely sensitive to how threads are running inside the server,
+# so it has it's own -master.opt file, to enforce it runs alone in mysqld
+#
+
+# Setup
+
+flush status;
+flush tables;
+
+# Remove to debug
+--disable_result_log
+
+# Make sure the internal server caches are all full
+select * from performance_schema.mutex_instances;
+select * from performance_schema.rwlock_instances;
+select * from performance_schema.cond_instances;
+select * from performance_schema.file_instances;
+
+select count(*) from performance_schema.mutex_instances
+  into @v0_mutex_instances;
+
+select count(*) from performance_schema.rwlock_instances
+  into @v0_rwlock_instances;
+
+select count(*) from performance_schema.cond_instances
+  into @v0_cond_instances;
+
+select count(*) from performance_schema.file_instances
+  into @v0_file_instances;
+
+select count(*) from performance_schema.mutex_instances
+  into @v1_mutex_instances;
+
+select count(*) from performance_schema.rwlock_instances
+  into @v1_rwlock_instances;
+
+select count(*) from performance_schema.cond_instances
+  into @v1_cond_instances;
+
+select count(*) from performance_schema.file_instances
+  into @v1_file_instances;
+
+select count(name), name from performance_schema.mutex_instances
+  group by name;
+
+select count(name), name from performance_schema.rwlock_instances
+  group by name;
+
+select count(name), name from performance_schema.cond_instances
+  group by name;
+
+select count(event_name), event_name from performance_schema.file_instances
+  group by event_name;
+
+begin;
+create table test.t1(a int) engine = innodb;
+create table test.t2(a int) engine = innodb;
+create table test.t3(a int) engine = innodb;
+create table test.t4(a int) engine = innodb;
+create table test.t5(a int) engine = innodb;
+create table test.t6(a int) engine = innodb;
+create table test.t7(a int) engine = innodb;
+create table test.t8(a int) engine = innodb;
+create table test.t9(a int) engine = innodb;
+create table test.t10(a int) engine = innodb;
+
+# Make sure there is at least 1 table handle,
+# to fully initialize the storage engine share if needed.
+select * from test.t1;
+select * from test.t2;
+select * from test.t3;
+select * from test.t4;
+select * from test.t5;
+select * from test.t6;
+select * from test.t7;
+select * from test.t8;
+select * from test.t9;
+select * from test.t10;
+commit;
+
+select count(*) from performance_schema.mutex_instances
+  into @v2_mutex_instances;
+
+select count(*) from performance_schema.rwlock_instances
+  into @v2_rwlock_instances;
+
+select count(*) from performance_schema.cond_instances
+  into @v2_cond_instances;
+
+select count(*) from performance_schema.file_instances
+  into @v2_file_instances;
+
+select count(name), name from performance_schema.mutex_instances
+  group by name;
+
+select count(name), name from performance_schema.rwlock_instances
+  group by name;
+
+select count(name), name from performance_schema.cond_instances
+  group by name;
+
+select count(event_name), event_name from performance_schema.file_instances
+  group by event_name;
+
+select @v2_mutex_instances, @v1_mutex_instances, @v0_mutex_instances;
+select @v2_rwlock_instances, @v1_rwlock_instances, @v0_rwlock_instances;
+select @v2_cond_instances, @v1_cond_instances, @v0_cond_instances;
+select @v2_file_instances, @v1_file_instances, @v0_file_instances;
+
+select round((@v2_mutex_instances - @v1_mutex_instances) / 10)
+  into @mutex_per_share;
+select round((@v2_rwlock_instances - @v1_rwlock_instances) / 10)
+  into @rwlock_per_share;
+select round((@v2_cond_instances - @v1_cond_instances) / 10)
+  into @cond_per_share;
+select round((@v2_file_instances - @v1_file_instances) / 10)
+  into @file_per_share;
+
+connect (con1, localhost, root,,);
+select "con1 connected";
+
+connect (con2, localhost, root,,);
+select "con2 connected";
+
+connect (con3, localhost, root,,);
+select "con3 connected";
+
+connect (con4, localhost, root,,);
+select "con4 connected";
+
+connect (con5, localhost, root,,);
+select "con5 connected";
+
+connect (con6, localhost, root,,);
+select "con6 connected";
+
+connect (con7, localhost, root,,);
+select "con7 connected";
+
+connect (con8, localhost, root,,);
+select "con8 connected";
+
+connect (con9, localhost, root,,);
+select "con9 connected";
+
+connect (con10, localhost, root,,);
+select "con10 connected";
+
+connection default;
+
+select count(*) from performance_schema.mutex_instances
+  into @v3_mutex_instances;
+
+select count(*) from performance_schema.rwlock_instances
+  into @v3_rwlock_instances;
+
+select count(*) from performance_schema.cond_instances
+  into @v3_cond_instances;
+
+select count(*) from performance_schema.file_instances
+  into @v3_file_instances;
+
+select count(name), name from performance_schema.mutex_instances
+  group by name;
+
+select count(name), name from performance_schema.rwlock_instances
+  group by name;
+
+select count(name), name from performance_schema.cond_instances
+  group by name;
+
+select count(event_name), event_name from performance_schema.file_instances
+  group by event_name;
+
+select @v3_mutex_instances, @v2_mutex_instances;
+select @v3_rwlock_instances, @v2_rwlock_instances;
+select @v3_cond_instances, @v2_cond_instances;
+select @v3_file_instances, @v2_file_instances;
+
+select round((@v3_mutex_instances - @v2_mutex_instances) / 10)
+  into @mutex_per_con;
+select round((@v3_rwlock_instances - @v2_rwlock_instances) / 10)
+  into @rwlock_per_con;
+select round((@v3_cond_instances - @v2_cond_instances) / 10)
+  into @cond_per_con;
+select round((@v3_file_instances - @v2_file_instances) / 10)
+  into @file_per_con;
+
+--connection con1
+
+lock table test.t1 write, test.t2 write, test.t3 write, test.t4 write,
+test.t5 write, test.t6 write, test.t7 write, test.t8 write, test.t9 write,
+test.t10 write;
+
+--send
+select t1.*, t2.*, t3.*, t4.*, t5.*, t6.*, t7.*, t8.*, t9.*, t10.*
+  from t1, t2, t3, t4, t5, t6, t7, t8, t9, t10;
+
+--connection con2
+
+--send
+select t1.*, t2.*, t3.*, t4.*, t5.*, t6.*, t7.*, t8.*, t9.*, t10.*
+  from t1, t2, t3, t4, t5, t6, t7, t8, t9, t10;
+
+--connection con3
+
+--send
+select t1.*, t2.*, t3.*, t4.*, t5.*, t6.*, t7.*, t8.*, t9.*, t10.*
+  from t1, t2, t3, t4, t5, t6, t7, t8, t9, t10;
+
+--connection con4
+
+--send
+select t1.*, t2.*, t3.*, t4.*, t5.*, t6.*, t7.*, t8.*, t9.*, t10.*
+  from t1, t2, t3, t4, t5, t6, t7, t8, t9, t10;
+
+--connection con5
+
+--send
+select t1.*, t2.*, t3.*, t4.*, t5.*, t6.*, t7.*, t8.*, t9.*, t10.*
+  from t1, t2, t3, t4, t5, t6, t7, t8, t9, t10;
+
+--connection con6
+
+--send
+select t1.*, t2.*, t3.*, t4.*, t5.*, t6.*, t7.*, t8.*, t9.*, t10.*
+  from t1, t2, t3, t4, t5, t6, t7, t8, t9, t10;
+
+--connection con7
+
+--send
+select t1.*, t2.*, t3.*, t4.*, t5.*, t6.*, t7.*, t8.*, t9.*, t10.*
+  from t1, t2, t3, t4, t5, t6, t7, t8, t9, t10;
+
+--connection con8
+
+--send
+select t1.*, t2.*, t3.*, t4.*, t5.*, t6.*, t7.*, t8.*, t9.*, t10.*
+  from t1, t2, t3, t4, t5, t6, t7, t8, t9, t10;
+
+--connection con9
+
+--send
+select t1.*, t2.*, t3.*, t4.*, t5.*, t6.*, t7.*, t8.*, t9.*, t10.*
+  from t1, t2, t3, t4, t5, t6, t7, t8, t9, t10;
+
+--connection con10
+
+--send
+select t1.*, t2.*, t3.*, t4.*, t5.*, t6.*, t7.*, t8.*, t9.*, t10.*
+  from t1, t2, t3, t4, t5, t6, t7, t8, t9, t10;
+
+connection default;
+
+select count(*) from performance_schema.mutex_instances
+  into @v4_mutex_instances;
+
+select count(*) from performance_schema.rwlock_instances
+  into @v4_rwlock_instances;
+
+select count(*) from performance_schema.cond_instances
+  into @v4_cond_instances;
+
+select count(*) from performance_schema.file_instances
+  into @v4_file_instances;
+
+select count(name), name from performance_schema.mutex_instances
+  group by name;
+
+select count(name), name from performance_schema.rwlock_instances
+  group by name;
+
+select count(name), name from performance_schema.cond_instances
+  group by name;
+
+select count(event_name), event_name from performance_schema.file_instances
+  group by event_name;
+
+select @v4_mutex_instances, @v3_mutex_instances;
+select @v4_rwlock_instances, @v3_rwlock_instances;
+select @v4_cond_instances, @v3_cond_instances;
+select @v4_file_instances, @v3_file_instances;
+
+select round((@v4_mutex_instances - @v3_mutex_instances) / 10)
+  into @mutex_per_handle;
+select round((@v4_rwlock_instances - @v3_rwlock_instances) / 10)
+  into @rwlock_per_handle;
+select round((@v4_cond_instances - @v3_cond_instances) / 10)
+  into @cond_per_handle;
+select round((@v4_file_instances - @v3_file_instances) / 10)
+  into @file_per_handle;
+
+--connection con1
+--reap
+
+unlock tables;
+
+--connection con2
+--reap
+
+--connection con3
+--reap
+
+--connection con4
+--reap
+
+--connection con5
+--reap
+
+--connection con6
+--reap
+
+--connection con7
+--reap
+
+--connection con8
+--reap
+
+--connection con9
+--reap
+
+--connection con10
+--reap
+
+--disconnect con1
+--disconnect con2
+--disconnect con3
+--disconnect con4
+--disconnect con5
+--disconnect con6
+--disconnect con7
+--disconnect con8
+--disconnect con9
+--disconnect con10
+
+--connection default
+
+drop table test.t1;
+drop table test.t2;
+drop table test.t3;
+drop table test.t4;
+drop table test.t5;
+drop table test.t6;
+drop table test.t7;
+drop table test.t8;
+drop table test.t9;
+drop table test.t10;
+
+--enable_result_log
+
+#
+# Expecting 3:
+# - wait/synch/mutex/sql/MDL_wait::LOCK_wait_status
+# - wait/synch/mutex/sql/TABLE_SHARE::LOCK_ha_data
+# - wait/synch/mutex/innodb/autoinc_mutex
+# 
+select @mutex_per_share;
+
+#
+# Expecting 1:
+# - wait/synch/rwlock/sql/MDL_lock::rwlock
+#
+select @rwlock_per_share;
+
+#
+# Expecting 0:
+#
+select @cond_per_share;
+
+#
+# Expecting 1:
+# - wait/io/file/sql/FRM
+# more with innodb file per table
+#
+select @file_per_share;
+
+#
+# Expecting 3:
+# - wait/synch/mutex/mysys/my_thread_var::mutex
+# - wait/synch/mutex/mysys/THR_LOCK::mutex
+# - wait/synch/mutex/sql/THD::LOCK_thd_data
+#
+select @mutex_per_con;
+
+#
+# Expecting 1:
+# - wait/synch/rwlock/sql/MDL_context::LOCK_waiting_for
+#
+select @rwlock_per_con;
+
+#
+# Expecting 2:
+# - wait/synch/cond/mysys/my_thread_var::suspend
+# - wait/synch/cond/sql/MDL_context::COND_wait_status
+#
+select @cond_per_con;
+
+#
+# Expecting 0:
+#
+select @file_per_con;
+
+#
+# Expecting 0:
+#
+select @mutex_per_handle;
+
+#
+# Expecting 0:
+#
+select @rwlock_per_handle;
+
+#
+# Expecting 0:
+#
+select @cond_per_handle;
+
+#
+# Expecting 0:
+#
+select @file_per_handle;
+

=== added file 'mysql-test/suite/perfschema/t/sizing_high.cnf'
--- a/mysql-test/suite/perfschema/t/sizing_high.cnf	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/sizing_high.cnf	2012-05-31 13:12:15 +0000
@@ -0,0 +1,56 @@
+
+!include include/default_mysqld_autosize.cnf
+
+[mysqld.1]
+
+# WARNING about open_files_limit and ulimit -n
+#
+# mysqld checks how many files can be opened on the machine,
+# and this is by definition very:
+# - os dependent, see OS_FILE_LIMIT, HAVE_GETRLIMIT
+# - configuration dependent, for each machine (ulimit -n), see
+#   my_set_max_open_files() in mysys/my_file.c,
+#   see getrlimit(RLIMIT_NOFILE)
+#
+# Based on the this, the server tunes _down_ max_connections and
+# table_cache_size to match the open_files_limit found,
+# which significantly interfere with this test.
+#
+# Solution: use a big table definition cache,
+# but small values for max_connection and table_open_cache,
+# to stay within open_files_limit of 1024.
+#
+# This is the best test we can do that has a chance to pass on all
+# platforms, while still providing code coverage.
+
+table_definition_cache=5000
+table_open_cache=400
+max_connections=200
+open_files_limit=1024
+
+# 10+max_connections+table_cache_size*2 = 10 + 200 + 400*2 = 1010
+# max_connections*5 = 200*5 = 1000
+
+# Automated sizing for everything
+
+loose-performance-schema-accounts-size=-1
+loose-performance-schema-digests-size=-1
+loose-performance-schema-hosts-size=-1
+loose-performance-schema-users-size=-1
+
+loose-performance-schema-events-waits-history-size=-1
+loose-performance-schema-events-waits-history-long-size=-1
+loose-performance-schema-events-stages-history-size=-1
+loose-performance-schema-events-stages-history-long-size=-1
+loose-performance-schema-events-statements-history-size=-1
+loose-performance-schema-events-statements-history-long-size=-1
+
+loose-performance-schema-max-mutex-instances=-1
+loose-performance-schema-max-rwlock-instances=-1
+loose-performance-schema-max-cond-instances=-1
+loose-performance-schema-max-file-instances=-1
+loose-performance-schema-max-socket-instances=-1
+loose-performance-schema-max-thread-instances=-1
+loose-performance-schema-max-table-instances=-1
+loose-performance-schema-max-table-handles=-1
+

=== added file 'mysql-test/suite/perfschema/t/sizing_high.test'
--- a/mysql-test/suite/perfschema/t/sizing_high.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/sizing_high.test	2012-06-04 14:12:37 +0000
@@ -0,0 +1,9 @@
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source include/have_64bit.inc
+--source include/not_valgrind.inc
+--source ../include/have_aligned_memory.inc
+
+--source ../include/sizing_auto.inc
+

=== added file 'mysql-test/suite/perfschema/t/sizing_low.cnf'
--- a/mysql-test/suite/perfschema/t/sizing_low.cnf	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/sizing_low.cnf	2012-05-30 11:44:42 +0000
@@ -0,0 +1,33 @@
+
+!include include/default_mysqld_autosize.cnf
+
+[mysqld.1]
+
+table_definition_cache=400
+table_open_cache=100
+max_connections=50
+open_files_limit=1024
+
+# Automated sizing for everything
+
+loose-performance-schema-accounts-size=-1
+loose-performance-schema-digests-size=-1
+loose-performance-schema-hosts-size=-1
+loose-performance-schema-users-size=-1
+
+loose-performance-schema-events-waits-history-size=-1
+loose-performance-schema-events-waits-history-long-size=-1
+loose-performance-schema-events-stages-history-size=-1
+loose-performance-schema-events-stages-history-long-size=-1
+loose-performance-schema-events-statements-history-size=-1
+loose-performance-schema-events-statements-history-long-size=-1
+
+loose-performance-schema-max-mutex-instances=-1
+loose-performance-schema-max-rwlock-instances=-1
+loose-performance-schema-max-cond-instances=-1
+loose-performance-schema-max-file-instances=-1
+loose-performance-schema-max-socket-instances=-1
+loose-performance-schema-max-thread-instances=-1
+loose-performance-schema-max-table-instances=-1
+loose-performance-schema-max-table-handles=-1
+

=== added file 'mysql-test/suite/perfschema/t/sizing_low.test'
--- a/mysql-test/suite/perfschema/t/sizing_low.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/sizing_low.test	2012-06-04 14:12:37 +0000
@@ -0,0 +1,9 @@
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source include/have_64bit.inc
+--source include/not_valgrind.inc
+--source ../include/have_aligned_memory.inc
+
+--source ../include/sizing_auto.inc
+

=== added file 'mysql-test/suite/perfschema/t/sizing_med.cnf'
--- a/mysql-test/suite/perfschema/t/sizing_med.cnf	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/sizing_med.cnf	2012-05-30 11:44:42 +0000
@@ -0,0 +1,33 @@
+
+!include include/default_mysqld_autosize.cnf
+
+[mysqld.1]
+
+table_definition_cache=401
+table_open_cache=401
+max_connections=152
+open_files_limit=1024
+
+# Automated sizing for everything
+
+loose-performance-schema-accounts-size=-1
+loose-performance-schema-digests-size=-1
+loose-performance-schema-hosts-size=-1
+loose-performance-schema-users-size=-1
+
+loose-performance-schema-events-waits-history-size=-1
+loose-performance-schema-events-waits-history-long-size=-1
+loose-performance-schema-events-stages-history-size=-1
+loose-performance-schema-events-stages-history-long-size=-1
+loose-performance-schema-events-statements-history-size=-1
+loose-performance-schema-events-statements-history-long-size=-1
+
+loose-performance-schema-max-mutex-instances=-1
+loose-performance-schema-max-rwlock-instances=-1
+loose-performance-schema-max-cond-instances=-1
+loose-performance-schema-max-file-instances=-1
+loose-performance-schema-max-socket-instances=-1
+loose-performance-schema-max-thread-instances=-1
+loose-performance-schema-max-table-instances=-1
+loose-performance-schema-max-table-handles=-1
+

=== added file 'mysql-test/suite/perfschema/t/sizing_med.test'
--- a/mysql-test/suite/perfschema/t/sizing_med.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/sizing_med.test	2012-06-04 14:12:37 +0000
@@ -0,0 +1,9 @@
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+--source include/have_64bit.inc
+--source include/not_valgrind.inc
+--source ../include/have_aligned_memory.inc
+
+--source ../include/sizing_auto.inc
+

=== added file 'mysql-test/suite/perfschema/t/sizing_off.cnf'
--- a/mysql-test/suite/perfschema/t/sizing_off.cnf	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/sizing_off.cnf	2012-05-31 13:12:15 +0000
@@ -0,0 +1,38 @@
+
+!include include/default_mysqld_autosize.cnf
+
+[mysqld.1]
+
+# Default values used in the server, out of the box
+table_definition_cache=400
+table_open_cache=400
+max_connections=151
+open_files_limit=1024
+
+# Disable the performacne schema.
+# Sizing does not occur then
+skip-performance-schema
+
+# Automated sizing for everything
+
+loose-performance-schema-accounts-size=-1
+loose-performance-schema-digests-size=-1
+loose-performance-schema-hosts-size=-1
+loose-performance-schema-users-size=-1
+
+loose-performance-schema-events-waits-history-size=-1
+loose-performance-schema-events-waits-history-long-size=-1
+loose-performance-schema-events-stages-history-size=-1
+loose-performance-schema-events-stages-history-long-size=-1
+loose-performance-schema-events-statements-history-size=-1
+loose-performance-schema-events-statements-history-long-size=-1
+
+loose-performance-schema-max-mutex-instances=-1
+loose-performance-schema-max-rwlock-instances=-1
+loose-performance-schema-max-cond-instances=-1
+loose-performance-schema-max-file-instances=-1
+loose-performance-schema-max-socket-instances=-1
+loose-performance-schema-max-thread-instances=-1
+loose-performance-schema-max-table-instances=-1
+loose-performance-schema-max-table-handles=-1
+

=== added file 'mysql-test/suite/perfschema/t/sizing_off.test'
--- a/mysql-test/suite/perfschema/t/sizing_off.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/perfschema/t/sizing_off.test	2012-06-01 08:39:34 +0000
@@ -0,0 +1,6 @@
+
+--source include/not_embedded.inc
+--source include/have_perfschema.inc
+
+show variables like "performance_schema%";
+show status like "performance_schema%";

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2012-06-05 05:58:05 +0000
+++ b/sql/mysqld.cc	2012-06-05 06:42:20 +0000
@@ -407,7 +407,7 @@ ulong slow_start_timeout;
   SQL commands in the init file and in --bootstrap mode.
 */
 bool in_bootstrap= FALSE;
-my_bool opt_bootstrap;
+my_bool opt_bootstrap= 0;
 
 /**
    @brief 'grant_option' is used to indicate if privileges needs
@@ -466,7 +466,7 @@ my_bool opt_old_style_user_limits= 0, tr
   changed). False otherwise.
 */
 volatile bool mqh_used = 0;
-my_bool opt_noacl;
+my_bool opt_noacl= 0;
 my_bool sp_automatic_privileges= 1;
 
 ulong opt_binlog_rows_event_max_size;
@@ -925,12 +925,6 @@ void init_net_server_extension(THD *thd)
 }
 #endif /* EMBEDDED_LIBRARY */
 
-/*
-  Since buffered_option_error_reporter is only used currently
-  for parsing performance schema options, this code is not needed
-  when the performance schema is not compiled in.
-*/
-#ifdef WITH_PERFSCHEMA_STORAGE_ENGINE
 /**
   A log message for the error log, buffered in memory.
   Log messages are temporarily buffered when generated before the error log
@@ -1066,7 +1060,6 @@ void Buffered_logs::print()
 /** Logs reported before a logger is available. */
 static Buffered_logs buffered_logs;
 
-#ifndef EMBEDDED_LIBRARY
 /**
   Error reporter that buffer log messages.
   @param level          log message level
@@ -1085,8 +1078,6 @@ static void buffered_option_error_report
   buffered_logs.buffer(level, buffer);
 }
 C_MODE_END
-#endif /* !EMBEDDED_LIBRARY */
-#endif /* WITH_PERFSCHEMA_STORAGE_ENGINE */
 
 static MYSQL_SOCKET unix_sock, ip_sock;
 struct rand_struct sql_rand; ///< used by sql_class.cc:THD::THD()
@@ -4878,48 +4869,29 @@ int mysqld_main(int argc, char **argv)
 
   sys_var_init();
 
-#ifdef WITH_PERFSCHEMA_STORAGE_ENGINE
-  /*
-    The performance schema needs to be initialized as early as possible,
-    before to-be-instrumented objects of the server are initialized.
-  */
   int ho_error;
-  vector<my_option> all_early_options;
-  all_early_options.reserve(100);
-
-  my_getopt_register_get_addr(NULL);
-  /* Skip unknown options so that they may be processed later */
-  my_getopt_skip_unknown= TRUE;
-
-  /* prepare all_early_options array */
-  sys_var_add_options(&all_early_options, sys_var::PARSE_EARLY);
-  add_terminator(&all_early_options);
-
-  /*
-    Logs generated while parsing the command line
-    options are buffered and printed later.
-  */
-  buffered_logs.init();
-  my_getopt_error_reporter= buffered_option_error_reporter;
-  my_charset_error_reporter= buffered_option_error_reporter;
 
+#ifdef WITH_PERFSCHEMA_STORAGE_ENGINE
   /*
     Initialize the array of performance schema instrument configurations.
   */
   init_pfs_instrument_array();
+#endif /* WITH_PERFSCHEMA_STORAGE_ENGINE */
 
-  ho_error= handle_options(&remaining_argc, &remaining_argv,
-                           &all_early_options[0], mysqld_get_one_option);
-  // Swap with an empty vector, i.e. delete elements and free allocated space.
-  vector<my_option>().swap(all_early_options);
+  ho_error= handle_early_options();
+
+  adjust_related_options();
 
+#ifdef WITH_PERFSCHEMA_STORAGE_ENGINE
   if (ho_error == 0)
   {
-    /* Add back the program name handle_options removes */
-    remaining_argc++;
-    remaining_argv--;
-    if (pfs_param.m_enabled)
+    if (pfs_param.m_enabled && !opt_help && !opt_bootstrap)
     {
+      /* Add sizing hints from the server sizing parameters. */
+      pfs_param.m_hints.m_table_definition_cache= table_def_size;
+      pfs_param.m_hints.m_table_open_cache= table_cache_size;
+      pfs_param.m_hints.m_max_connections= max_connections;
+      pfs_param.m_hints.m_open_files_limit= open_files_limit;
       PSI_hook= initialize_performance_schema(&pfs_param);
       if (PSI_hook == NULL)
       {
@@ -4991,7 +4963,6 @@ int mysqld_main(int argc, char **argv)
   */
   logger.init_base();
 
-#ifdef WITH_PERFSCHEMA_STORAGE_ENGINE
   if (ho_error)
   {
     /*
@@ -5011,7 +4982,6 @@ int mysqld_main(int argc, char **argv)
     */
     exit (ho_error);
   }
-#endif /* WITH_PERFSCHEMA_STORAGE_ENGINE */
 
 #ifdef _CUSTOMSTARTUPCONFIG_
   if (_cust_check_startup())
@@ -6446,8 +6416,92 @@ error:
   Handle start options
 ******************************************************************************/
 
+/**
+  Process command line options flagged as 'early'.
+  Some components needs to be initialized as early as possible,
+  because the rest of the server initialization depends on them.
+  Options that needs to be parsed early includes:
+  - the performance schema, when compiled in,
+  - options related to the help,
+  - options related to the bootstrap
+  The performance schema needs to be initialized as early as possible,
+  before to-be-instrumented objects of the server are initialized.
+*/
+int handle_early_options()
+{
+  int ho_error;
+  vector<my_option> all_early_options;
+  all_early_options.reserve(100);
+
+  my_getopt_register_get_addr(NULL);
+  /* Skip unknown options so that they may be processed later */
+  my_getopt_skip_unknown= TRUE;
+
+  /* Add the system variables parsed early */
+  sys_var_add_options(&all_early_options, sys_var::PARSE_EARLY);
+
+  /* Add the command line options parsed early */
+  for (my_option *opt= my_long_early_options;
+       opt->name != NULL;
+       opt++)
+    all_early_options.push_back(*opt);
+
+  add_terminator(&all_early_options);
+
+  /*
+    Logs generated while parsing the command line
+    options are buffered and printed later.
+  */
+  buffered_logs.init();
+  my_getopt_error_reporter= buffered_option_error_reporter;
+  my_charset_error_reporter= buffered_option_error_reporter;
+
+  ho_error= handle_options(&remaining_argc, &remaining_argv,
+                           &all_early_options[0], mysqld_get_one_option);
+  if (ho_error == 0)
+  {
+    /* Add back the program name handle_options removes */
+    remaining_argc++;
+    remaining_argv--;
+  }
+
+  // Swap with an empty vector, i.e. delete elements and free allocated space.
+  vector<my_option>().swap(all_early_options);
+
+  return ho_error;
+}
+
+void adjust_related_options()
+{
+  /* In bootstrap, disable grant tables (we are about to create them) */
+  if (opt_bootstrap)
+    opt_noacl= 1;
+}
+
 vector<my_option> all_options;
 
+struct my_option my_long_early_options[]=
+{
+#ifndef DISABLE_GRANT_OPTIONS
+  {"bootstrap", OPT_BOOTSTRAP, "Used by mysql installation scripts.", 0, 0, 0,
+   GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
+#endif
+#ifndef DISABLE_GRANT_OPTIONS
+  {"skip-grant-tables", 0,
+   "Start without grant tables. This gives all users FULL ACCESS to all tables.",
+   &opt_noacl, &opt_noacl, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
+   0},
+#endif
+  {"help", '?', "Display this help and exit.",
+   &opt_help, &opt_help, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
+   0, 0},
+  {"verbose", 'v', "Used with --help option for detailed help.",
+   &opt_verbose, &opt_verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
+  {"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG,
+   NO_ARG, 0, 0, 0, 0, 0, 0},
+  {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
+};
+
 /**
   System variables are automatically command-line options (few
   exceptions are documented in sys_var.h), so don't need
@@ -6456,9 +6510,6 @@ vector<my_option> all_options;
 
 struct my_option my_long_options[]=
 {
-  {"help", '?', "Display this help and exit.",
-   &opt_help, &opt_help, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0,
-   0, 0},
 #ifdef HAVE_REPLICATION
   {"abort-slave-event-count", 0,
    "Option used by mysql-test for debugging and testing of replication.",
@@ -6499,10 +6550,6 @@ struct my_option my_long_options[]=
    /* sub_size */     0, /* block_size */ 256,
    /* app_type */ 0
   },
-#ifndef DISABLE_GRANT_OPTIONS
-  {"bootstrap", OPT_BOOTSTRAP, "Used by mysql installation scripts.", 0, 0, 0,
-   GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
-#endif
   {"character-set-client-handshake", 0,
    "Don't ignore client side character set value sent during handshake.",
    &opt_character_set_client_handshake,
@@ -6723,12 +6770,6 @@ struct my_option my_long_options[]=
    "Show user and password in SHOW SLAVE HOSTS on this master.",
    &opt_show_slave_auth_info, &opt_show_slave_auth_info, 0,
    GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
-#ifndef DISABLE_GRANT_OPTIONS
-  {"skip-grant-tables", 0,
-   "Start without grant tables. This gives all users FULL ACCESS to all tables.",
-   &opt_noacl, &opt_noacl, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
-   0},
-#endif
   {"skip-host-cache", OPT_SKIP_HOST_CACHE, "Don't cache host names.", 0, 0, 0,
    GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
   {"skip-new", OPT_SKIP_NEW, "Don't use new, possibly wrong routines.",
@@ -6812,10 +6853,6 @@ struct my_option my_long_options[]=
    GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
   {"user", 'u', "Run mysqld daemon as user.", 0, 0, 0, GET_STR, REQUIRED_ARG,
    0, 0, 0, 0, 0, 0},
-  {"verbose", 'v', "Used with --help option for detailed help.",
-   &opt_verbose, &opt_verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
-  {"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG,
-   NO_ARG, 0, 0, 0, 0, 0, 0},
   {"plugin-load", OPT_PLUGIN_LOAD,
    "Optional semicolon-separated list of plugins to load, where each plugin is "
    "identified as name=library, where name is the plugin name and library "
@@ -6830,9 +6867,6 @@ struct my_option my_long_options[]=
    "Multiple --plugin-load-add are supported.",
    0, 0, 0,
    GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
-  {"table_cache", 0, "Deprecated; use --table-open-cache instead.",
-   &table_cache_size, &table_cache_size, 0, GET_ULONG,
-   REQUIRED_ARG, TABLE_OPEN_CACHE_DEFAULT, 1, 512*1024L, 0, 1, 0},
   {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
 };
 
@@ -7567,6 +7601,12 @@ static void print_help()
 
   all_options.pop_back();
   sys_var_add_options(&all_options, sys_var::PARSE_EARLY);
+  for (my_option *opt= my_long_early_options;
+       opt->name != NULL;
+       opt++)
+  {
+    all_options.push_back(*opt);
+  }
   add_plugin_options(&all_options, &mem_root);
   std::sort(all_options.begin(), all_options.end(), std::less<my_option>());
   add_terminator(&all_options);
@@ -7658,7 +7698,7 @@ static int mysql_init_variables(void)
   opt_tc_log_file= (char *)"tc.log";      // no hostname in tc_log file name !
   opt_secure_auth= 0;
   opt_secure_file_priv= NULL;
-  opt_bootstrap= opt_myisam_log= 0;
+  opt_myisam_log= 0;
   mqh_used= 0;
   kill_in_progress= 0;
   cleanup_done= 0;
@@ -8028,7 +8068,7 @@ mysqld_get_one_option(int optid,
       opt_error_log= 0;     // Force logs to stdout
     break;
   case OPT_BOOTSTRAP:
-    opt_noacl=opt_bootstrap=1;
+    opt_bootstrap=1;
     break;
   case OPT_SERVER_ID:
     server_id_supplied = 1;
@@ -8098,6 +8138,7 @@ mysqld_get_one_option(int optid,
 
   case OPT_PFS_INSTRUMENT:
 #ifdef WITH_PERFSCHEMA_STORAGE_ENGINE
+#ifndef EMBEDDED_LIBRARY
     /* Parse instrument name and value from argument string */
     char* name = argument,*p, *val;
 
@@ -8161,8 +8202,8 @@ mysqld_get_one_option(int optid,
                              "'%s'", argument);
       return 0;
     }
-
-#endif
+#endif /* EMBEDDED_LIBRARY */
+#endif /* WITH_PERFSCHEMA_STORAGE_ENGINE */
     break;
   }
   return 0;
@@ -8245,7 +8286,9 @@ static int get_options(int *argc_ptr, ch
   for (my_option *opt= my_long_options;
        opt < my_long_options + array_elements(my_long_options) - 1;
        opt++)
+  {
     all_options.push_back(*opt);
+  }
   sys_var_add_options(&all_options, sys_var::PARSE_NORMAL);
   add_terminator(&all_options);
 

=== modified file 'sql/mysqld.h'
--- a/sql/mysqld.h	2012-06-04 04:50:38 +0000
+++ b/sql/mysqld.h	2012-06-04 14:12:37 +0000
@@ -256,6 +256,9 @@ extern ulong opt_ndb_wait_setup;
 #endif
 extern const char *load_default_groups[];
 extern struct my_option my_long_options[];
+extern struct my_option my_long_early_options[];
+int handle_early_options();
+void adjust_related_options();
 extern int mysqld_server_started;
 extern "C" MYSQL_PLUGIN_IMPORT int orig_argc;
 extern "C" MYSQL_PLUGIN_IMPORT char **orig_argv;

=== modified file 'sql/sql_const.h'
--- a/sql/sql_const.h	2012-02-27 10:20:18 +0000
+++ b/sql/sql_const.h	2012-05-25 13:22:34 +0000
@@ -114,6 +114,12 @@
 #define TABLE_OPEN_CACHE_DEFAULT 400
 #define TABLE_DEF_CACHE_DEFAULT 400
 /**
+  Maximum number of connections default value.
+  151 is larger than Apache's default max children,
+  to avoid "too many connections" error in a common setup.
+*/
+#define MAX_CONNECTIONS_DEFAULT 151
+/**
   We must have room for at least 400 table definitions in the table
   cache, since otherwise there is no chance prepared
   statements that use these many tables can work.

=== modified file 'sql/sys_vars.cc'
--- a/sql/sys_vars.cc	2012-06-01 08:26:25 +0000
+++ b/sql/sys_vars.cc	2012-06-01 08:45:46 +0000
@@ -150,6 +150,7 @@ static bool update_keycache_param(THD *t
 #define export /* not static */
 
 #ifdef WITH_PERFSCHEMA_STORAGE_ENGINE
+#ifndef EMBEDDED_LIBRARY
 
 #define PFS_TRAILING_PROPERTIES \
   NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(NULL), ON_UPDATE(NULL), \
@@ -159,7 +160,7 @@ static Sys_var_mybool Sys_pfs_enabled(
        "performance_schema",
        "Enable the performance schema.",
        READ_ONLY GLOBAL_VAR(pfs_param.m_enabled),
-       CMD_LINE(OPT_ARG), DEFAULT(FALSE),
+       CMD_LINE(OPT_ARG), DEFAULT(TRUE),
        PFS_TRAILING_PROPERTIES);
 
 static Sys_var_charptr Sys_pfs_instrument(
@@ -255,20 +256,22 @@ static Sys_var_mybool Sys_pfs_consumer_s
        CMD_LINE(OPT_ARG), DEFAULT(TRUE),
        PFS_TRAILING_PROPERTIES);
 
-static Sys_var_ulong Sys_pfs_events_waits_history_long_size(
+static Sys_var_long Sys_pfs_events_waits_history_long_size(
        "performance_schema_events_waits_history_long_size",
-       "Number of rows in EVENTS_WAITS_HISTORY_LONG.",
+       "Number of rows in EVENTS_WAITS_HISTORY_LONG."
+         " Use 0 to disable, -1 for automated sizing.",
        READ_ONLY GLOBAL_VAR(pfs_param.m_events_waits_history_long_sizing),
-       CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 1024*1024),
-       DEFAULT(PFS_WAITS_HISTORY_LONG_SIZE),
+       CMD_LINE(REQUIRED_ARG), VALID_RANGE(-1, 1024*1024),
+       DEFAULT(-1),
        BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
 
-static Sys_var_ulong Sys_pfs_events_waits_history_size(
+static Sys_var_long Sys_pfs_events_waits_history_size(
        "performance_schema_events_waits_history_size",
-       "Number of rows per thread in EVENTS_WAITS_HISTORY.",
+       "Number of rows per thread in EVENTS_WAITS_HISTORY."
+         " Use 0 to disable, -1 for automated sizing.",
        READ_ONLY GLOBAL_VAR(pfs_param.m_events_waits_history_sizing),
-       CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 1024),
-       DEFAULT(PFS_WAITS_HISTORY_SIZE),
+       CMD_LINE(REQUIRED_ARG), VALID_RANGE(-1, 1024),
+       DEFAULT(-1),
        BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
 
 static Sys_var_ulong Sys_pfs_max_cond_classes(
@@ -279,12 +282,13 @@ static Sys_var_ulong Sys_pfs_max_cond_cl
        DEFAULT(PFS_MAX_COND_CLASS),
        BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
 
-static Sys_var_ulong Sys_pfs_max_cond_instances(
+static Sys_var_long Sys_pfs_max_cond_instances(
        "performance_schema_max_cond_instances",
-       "Maximum number of instrumented condition objects.",
+       "Maximum number of instrumented condition objects."
+         " Use 0 to disable, -1 for automated sizing.",
        READ_ONLY GLOBAL_VAR(pfs_param.m_cond_sizing),
-       CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 1024*1024),
-       DEFAULT(PFS_MAX_COND),
+       CMD_LINE(REQUIRED_ARG), VALID_RANGE(-1, 1024*1024),
+       DEFAULT(-1),
        BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
 
 static Sys_var_ulong Sys_pfs_max_file_classes(
@@ -303,20 +307,22 @@ static Sys_var_ulong Sys_pfs_max_file_ha
        DEFAULT(PFS_MAX_FILE_HANDLE),
        BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
 
-static Sys_var_ulong Sys_pfs_max_file_instances(
+static Sys_var_long Sys_pfs_max_file_instances(
        "performance_schema_max_file_instances",
-       "Maximum number of instrumented files.",
+       "Maximum number of instrumented files."
+         " Use 0 to disable, -1 for automated sizing.",
        READ_ONLY GLOBAL_VAR(pfs_param.m_file_sizing),
-       CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 1024*1024),
-       DEFAULT(PFS_MAX_FILE),
+       CMD_LINE(REQUIRED_ARG), VALID_RANGE(-1, 1024*1024),
+       DEFAULT(-1),
        BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
 
-static Sys_var_ulong Sys_pfs_max_sockets(
+static Sys_var_long Sys_pfs_max_sockets(
        "performance_schema_max_socket_instances",
-       "Maximum number of opened instrumented sockets.",
+       "Maximum number of opened instrumented sockets."
+         " Use 0 to disable, -1 for automated sizing.",
        READ_ONLY GLOBAL_VAR(pfs_param.m_socket_sizing),
-       CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 1024*1024),
-       DEFAULT(PFS_MAX_SOCKETS),
+       CMD_LINE(REQUIRED_ARG), VALID_RANGE(-1, 1024*1024),
+       DEFAULT(-1),
        BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
 
 static Sys_var_ulong Sys_pfs_max_socket_classes(
@@ -335,12 +341,13 @@ static Sys_var_ulong Sys_pfs_max_mutex_c
        DEFAULT(PFS_MAX_MUTEX_CLASS),
        BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
 
-static Sys_var_ulong Sys_pfs_max_mutex_instances(
+static Sys_var_long Sys_pfs_max_mutex_instances(
        "performance_schema_max_mutex_instances",
-       "Maximum number of instrumented MUTEX objects.",
+       "Maximum number of instrumented MUTEX objects."
+         " Use 0 to disable, -1 for automated sizing.",
        READ_ONLY GLOBAL_VAR(pfs_param.m_mutex_sizing),
-       CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 100*1024*1024),
-       DEFAULT(PFS_MAX_MUTEX),
+       CMD_LINE(REQUIRED_ARG), VALID_RANGE(-1, 100*1024*1024),
+       DEFAULT(-1),
        BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
 
 static Sys_var_ulong Sys_pfs_max_rwlock_classes(
@@ -351,28 +358,31 @@ static Sys_var_ulong Sys_pfs_max_rwlock_
        DEFAULT(PFS_MAX_RWLOCK_CLASS),
        BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
 
-static Sys_var_ulong Sys_pfs_max_rwlock_instances(
+static Sys_var_long Sys_pfs_max_rwlock_instances(
        "performance_schema_max_rwlock_instances",
-       "Maximum number of instrumented RWLOCK objects.",
+       "Maximum number of instrumented RWLOCK objects."
+         " Use 0 to disable, -1 for automated sizing.",
        READ_ONLY GLOBAL_VAR(pfs_param.m_rwlock_sizing),
-       CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 100*1024*1024),
-       DEFAULT(PFS_MAX_RWLOCK),
+       CMD_LINE(REQUIRED_ARG), VALID_RANGE(-1, 100*1024*1024),
+       DEFAULT(-1),
        BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
 
-static Sys_var_ulong Sys_pfs_max_table_handles(
+static Sys_var_long Sys_pfs_max_table_handles(
        "performance_schema_max_table_handles",
-       "Maximum number of opened instrumented tables.",
+       "Maximum number of opened instrumented tables."
+         " Use 0 to disable, -1 for automated sizing.",
        READ_ONLY GLOBAL_VAR(pfs_param.m_table_sizing),
-       CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 1024*1024),
-       DEFAULT(PFS_MAX_TABLE),
+       CMD_LINE(REQUIRED_ARG), VALID_RANGE(-1, 1024*1024),
+       DEFAULT(-1),
        BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
 
-static Sys_var_ulong Sys_pfs_max_table_instances(
+static Sys_var_long Sys_pfs_max_table_instances(
        "performance_schema_max_table_instances",
-       "Maximum number of instrumented tables.",
+       "Maximum number of instrumented tables."
+         " Use 0 to disable, -1 for automated sizing.",
        READ_ONLY GLOBAL_VAR(pfs_param.m_table_share_sizing),
-       CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 1024*1024),
-       DEFAULT(PFS_MAX_TABLE_SHARE),
+       CMD_LINE(REQUIRED_ARG), VALID_RANGE(-1, 1024*1024),
+       DEFAULT(-1),
        BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
 
 static Sys_var_ulong Sys_pfs_max_thread_classes(
@@ -383,12 +393,13 @@ static Sys_var_ulong Sys_pfs_max_thread_
        DEFAULT(PFS_MAX_THREAD_CLASS),
        BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
 
-static Sys_var_ulong Sys_pfs_max_thread_instances(
+static Sys_var_long Sys_pfs_max_thread_instances(
        "performance_schema_max_thread_instances",
-       "Maximum number of instrumented threads.",
+       "Maximum number of instrumented threads."
+         " Use 0 to disable, -1 for automated sizing.",
        READ_ONLY GLOBAL_VAR(pfs_param.m_thread_sizing),
-       CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 1024*1024),
-       DEFAULT(PFS_MAX_THREAD),
+       CMD_LINE(REQUIRED_ARG), VALID_RANGE(-1, 1024*1024),
+       DEFAULT(-1),
        BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
 
 static Sys_var_ulong Sys_pfs_setup_actors_size(
@@ -407,28 +418,31 @@ static Sys_var_ulong Sys_pfs_setup_objec
        DEFAULT(PFS_MAX_SETUP_OBJECT),
        BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
 
-static Sys_var_ulong Sys_pfs_accounts_size(
+static Sys_var_long Sys_pfs_accounts_size(
        "performance_schema_accounts_size",
-       "Maximum number of instrumented user@host accounts.",
+       "Maximum number of instrumented user@host accounts."
+         " Use 0 to disable, -1 for automated sizing.",
        READ_ONLY GLOBAL_VAR(pfs_param.m_account_sizing),
-       CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 1024*1024),
-       DEFAULT(PFS_MAX_ACCOUNT),
+       CMD_LINE(REQUIRED_ARG), VALID_RANGE(-1, 1024*1024),
+       DEFAULT(-1),
        BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
 
-static Sys_var_ulong Sys_pfs_hosts_size(
+static Sys_var_long Sys_pfs_hosts_size(
        "performance_schema_hosts_size",
-       "Maximum number of instrumented hosts.",
+       "Maximum number of instrumented hosts."
+         " Use 0 to disable, -1 for automated sizing.",
        READ_ONLY GLOBAL_VAR(pfs_param.m_host_sizing),
-       CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 1024*1024),
-       DEFAULT(PFS_MAX_HOST),
+       CMD_LINE(REQUIRED_ARG), VALID_RANGE(-1, 1024*1024),
+       DEFAULT(-1),
        BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
 
-static Sys_var_ulong Sys_pfs_users_size(
+static Sys_var_long Sys_pfs_users_size(
        "performance_schema_users_size",
-       "Maximum number of instrumented users.",
+       "Maximum number of instrumented users."
+         " Use 0 to disable, -1 for automated sizing.",
        READ_ONLY GLOBAL_VAR(pfs_param.m_user_sizing),
-       CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 1024*1024),
-       DEFAULT(PFS_MAX_USER),
+       CMD_LINE(REQUIRED_ARG), VALID_RANGE(-1, 1024*1024),
+       DEFAULT(-1),
        BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
 
 static Sys_var_ulong Sys_pfs_max_stage_classes(
@@ -439,20 +453,22 @@ static Sys_var_ulong Sys_pfs_max_stage_c
        DEFAULT(PFS_MAX_STAGE_CLASS),
        BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
 
-static Sys_var_ulong Sys_pfs_events_stages_history_long_size(
+static Sys_var_long Sys_pfs_events_stages_history_long_size(
        "performance_schema_events_stages_history_long_size",
-       "Number of rows in EVENTS_STAGES_HISTORY_LONG.",
+       "Number of rows in EVENTS_STAGES_HISTORY_LONG."
+         " Use 0 to disable, -1 for automated sizing.",
        READ_ONLY GLOBAL_VAR(pfs_param.m_events_stages_history_long_sizing),
-       CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 1024*1024),
-       DEFAULT(PFS_STAGES_HISTORY_LONG_SIZE),
+       CMD_LINE(REQUIRED_ARG), VALID_RANGE(-1, 1024*1024),
+       DEFAULT(-1),
        BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
 
-static Sys_var_ulong Sys_pfs_events_stages_history_size(
+static Sys_var_long Sys_pfs_events_stages_history_size(
        "performance_schema_events_stages_history_size",
-       "Number of rows per thread in EVENTS_STAGES_HISTORY.",
+       "Number of rows per thread in EVENTS_STAGES_HISTORY."
+         " Use 0 to disable, -1 for automated sizing.",
        READ_ONLY GLOBAL_VAR(pfs_param.m_events_stages_history_sizing),
-       CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 1024),
-       DEFAULT(PFS_STAGES_HISTORY_SIZE),
+       CMD_LINE(REQUIRED_ARG), VALID_RANGE(-1, 1024),
+       DEFAULT(-1),
        BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
 
 /**
@@ -472,38 +488,43 @@ static Sys_var_ulong Sys_pfs_max_stateme
        DEFAULT((ulong) SQLCOM_END + (ulong) COM_END + 3),
        BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
 
-static Sys_var_ulong Sys_pfs_events_statements_history_long_size(
+static Sys_var_long Sys_pfs_events_statements_history_long_size(
        "performance_schema_events_statements_history_long_size",
-       "Number of rows in EVENTS_STATEMENTS_HISTORY_LONG.",
+       "Number of rows in EVENTS_STATEMENTS_HISTORY_LONG."
+         " Use 0 to disable, -1 for automated sizing.",
        READ_ONLY GLOBAL_VAR(pfs_param.m_events_statements_history_long_sizing),
-       CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 1024*1024),
-       DEFAULT(PFS_STATEMENTS_HISTORY_LONG_SIZE),
+       CMD_LINE(REQUIRED_ARG), VALID_RANGE(-1, 1024*1024),
+       DEFAULT(-1),
        BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
 
-static Sys_var_ulong Sys_pfs_events_statements_history_size(
+static Sys_var_long Sys_pfs_events_statements_history_size(
        "performance_schema_events_statements_history_size",
-       "Number of rows per thread in EVENTS_STATEMENTS_HISTORY.",
+       "Number of rows per thread in EVENTS_STATEMENTS_HISTORY."
+         " Use 0 to disable, -1 for automated sizing.",
        READ_ONLY GLOBAL_VAR(pfs_param.m_events_statements_history_sizing),
-       CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 1024),
-       DEFAULT(PFS_STATEMENTS_HISTORY_SIZE),
+       CMD_LINE(REQUIRED_ARG), VALID_RANGE(-1, 1024),
+       DEFAULT(-1),
        BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
 
-static Sys_var_ulong Sys_pfs_digest_size(
+static Sys_var_long Sys_pfs_digest_size(
        "performance_schema_digests_size",
-       "Size of the statement digest.",
+       "Size of the statement digest."
+         " Use 0 to disable, -1 for automated sizing.",
        READ_ONLY GLOBAL_VAR(pfs_param.m_digest_sizing),
-       CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 1024 * 1024),
-       DEFAULT(PFS_DIGEST_SIZE),
+       CMD_LINE(REQUIRED_ARG), VALID_RANGE(-1, 1024 * 1024),
+       DEFAULT(-1),
        BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
 
-static Sys_var_ulong Sys_pfs_connect_attrs_size(
+static Sys_var_long Sys_pfs_connect_attrs_size(
        "performance_schema_session_connect_attrs_size",
-       "Size of session attribute string buffer per thread.",
+       "Size of session attribute string buffer per thread."
+         " Use 0 to disable, -1 for automated sizing.",
        READ_ONLY GLOBAL_VAR(pfs_param.m_session_connect_attrs_sizing),
-       CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, 1024 * 1024),
-       DEFAULT(PFS_SESSION_CONNECT_ATTRS_SIZE),
+       CMD_LINE(REQUIRED_ARG), VALID_RANGE(-1, 1024 * 1024),
+       DEFAULT(-1),
        BLOCK_SIZE(1), PFS_TRAILING_PROPERTIES);
 
+#endif /* EMBEDDED_LIBRARY */
 #endif /* WITH_PERFSCHEMA_STORAGE_ENGINE */
 
 static Sys_var_ulong Sys_auto_increment_increment(
@@ -1636,13 +1657,19 @@ static bool fix_max_connections(sys_var
   return false;
 }
 
-// Default max_connections of 151 is larger than Apache's default max
-// children, to avoid "too many connections" error in a common setup
 static Sys_var_ulong Sys_max_connections(
        "max_connections", "The number of simultaneous clients allowed",
        GLOBAL_VAR(max_connections), CMD_LINE(REQUIRED_ARG),
-       VALID_RANGE(1, 100000), DEFAULT(151), BLOCK_SIZE(1), NO_MUTEX_GUARD,
-       NOT_IN_BINLOG, ON_CHECK(0), ON_UPDATE(fix_max_connections));
+       VALID_RANGE(1, 100000),
+       DEFAULT(MAX_CONNECTIONS_DEFAULT),
+       BLOCK_SIZE(1),
+       NO_MUTEX_GUARD,
+       NOT_IN_BINLOG,
+       ON_CHECK(0),
+       ON_UPDATE(fix_max_connections),
+       NULL,
+       /* max_connections is used as a sizing hint by the performance schema. */
+       sys_var::PARSE_EARLY);
 
 static Sys_var_ulong Sys_max_connect_errors(
        "max_connect_errors",
@@ -1910,7 +1937,11 @@ static Sys_var_ulong Sys_open_files_limi
        "will reserve max_connections*5 or max_connections + table_cache*2 "
        "(whichever is larger) number of file descriptors",
        READ_ONLY GLOBAL_VAR(open_files_limit), CMD_LINE(REQUIRED_ARG),
-       VALID_RANGE(0, OS_FILE_LIMIT), DEFAULT(0), BLOCK_SIZE(1));
+       VALID_RANGE(0, OS_FILE_LIMIT), DEFAULT(0), BLOCK_SIZE(1),
+       NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(NULL), ON_UPDATE(NULL),
+       NULL,
+       /* open_files_limit is used as a sizing hint by the performance schema. */
+       sys_var::PARSE_EARLY);
 
 /// @todo change to enum
 static Sys_var_ulong Sys_optimizer_prune_level(
@@ -2776,7 +2807,15 @@ static Sys_var_ulong Sys_table_def_size(
        "The number of cached table definitions",
        GLOBAL_VAR(table_def_size), CMD_LINE(REQUIRED_ARG),
        VALID_RANGE(TABLE_DEF_CACHE_MIN, 512*1024),
-       DEFAULT(TABLE_DEF_CACHE_DEFAULT), BLOCK_SIZE(1));
+       DEFAULT(TABLE_DEF_CACHE_DEFAULT),
+       BLOCK_SIZE(1),
+       NO_MUTEX_GUARD,
+       NOT_IN_BINLOG,
+       ON_CHECK(NULL),
+       ON_UPDATE(NULL),
+       NULL,
+       /* table_definition_cache is used as a sizing hint by the performance schema. */
+       sys_var::PARSE_EARLY);
 
 static bool fix_table_cache_size(sys_var *self, THD *thd, enum_var_type type)
 {
@@ -2795,13 +2834,24 @@ static Sys_var_ulong Sys_table_cache_siz
        GLOBAL_VAR(table_cache_size), CMD_LINE(REQUIRED_ARG),
        VALID_RANGE(1, 512*1024), DEFAULT(TABLE_OPEN_CACHE_DEFAULT),
        BLOCK_SIZE(1), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(NULL),
-       ON_UPDATE(fix_table_cache_size));
+       ON_UPDATE(fix_table_cache_size),
+       NULL,
+       /* table_open_cache is used as a sizing hint by the performance schema. */
+       sys_var::PARSE_EARLY);
 
 static Sys_var_ulong Sys_table_cache_instances(
        "table_open_cache_instances", "The number of table cache instances",
        READ_ONLY GLOBAL_VAR(table_cache_instances), CMD_LINE(REQUIRED_ARG),
        VALID_RANGE(1, Table_cache_manager::MAX_TABLE_CACHES), DEFAULT(1),
-       BLOCK_SIZE(1));
+       BLOCK_SIZE(1), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(NULL),
+       ON_UPDATE(NULL), NULL,
+       /*
+         table_open_cache is used as a sizing hint by the performance schema,
+         and 'table_open_cache' is a prefix of 'table_open_cache_instances'.
+         Is is better to keep these options together, to avoid confusing
+         handle_options() with partial name matches.
+       */
+       sys_var::PARSE_EARLY);
 
 static Sys_var_ulong Sys_thread_cache_size(
        "thread_cache_size",

=== modified file 'storage/perfschema/CMakeLists.txt'
--- a/storage/perfschema/CMakeLists.txt	2012-05-04 10:54:36 +0000
+++ b/storage/perfschema/CMakeLists.txt	2012-05-29 09:25:25 +0000
@@ -130,6 +130,7 @@ ha_perfschema.cc
 pfs.cc
 pfs_account.cc
 pfs_atomic.cc
+pfs_autosize.cc
 pfs_check.cc
 pfs_column_values.cc
 pfs_con_slice.cc

=== added file 'storage/perfschema/pfs_autosize.cc'
--- a/storage/perfschema/pfs_autosize.cc	1970-01-01 00:00:00 +0000
+++ b/storage/perfschema/pfs_autosize.cc	2012-06-01 08:39:34 +0000
@@ -0,0 +1,388 @@
+/* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+
+  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
+  the Free Software Foundation; version 2 of the License.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software Foundation,
+  51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
+
+/**
+  @file storage/perfschema/pfs_autosize.cc
+  Private interface for the server (implementation).
+*/
+
+#include "my_global.h"
+#include "sql_const.h"
+#include "pfs_server.h"
+
+#include <algorithm>
+using std::min;
+using std::max;
+
+static const ulong fixed_mutex_instances= 500;
+static const ulong fixed_rwlock_instances= 200;
+static const ulong fixed_cond_instances= 50;
+static const ulong fixed_file_instances= 200;
+static const ulong fixed_socket_instances= 10;
+static const ulong fixed_thread_instances= 50;
+
+static const ulong mutex_per_connection= 3;
+static const ulong rwlock_per_connection= 1;
+static const ulong cond_per_connection= 2;
+static const ulong file_per_connection= 0;
+static const ulong socket_per_connection= 1;
+static const ulong thread_per_connection= 1;
+
+static const ulong mutex_per_handle= 0;
+static const ulong rwlock_per_handle= 0;
+static const ulong cond_per_handle= 0;
+static const ulong file_per_handle= 0;
+static const ulong socket_per_handle= 0;
+static const ulong thread_per_handle= 0;
+
+static const ulong mutex_per_share= 3;
+static const ulong rwlock_per_share= 3;
+static const ulong cond_per_share= 1;
+static const ulong file_per_share= 2;
+static const ulong socket_per_share= 0;
+static const ulong thread_per_share= 0;
+
+struct PFS_sizing_data
+{
+  /** Default value for @c PFS_param.m_account_sizing. */
+  ulong m_account_sizing;
+  /** Default value for @c PFS_param.m_user_sizing. */
+  ulong m_user_sizing;
+  /** Default value for @c PFS_param.m_host_sizing. */
+  ulong m_host_sizing;
+
+  /** Default value for @c PFS_param.m_events_waits_history_sizing. */
+  ulong m_events_waits_history_sizing;
+  /** Default value for @c PFS_param.m_events_waits_history_long_sizing. */
+  ulong m_events_waits_history_long_sizing;
+  /** Default value for @c PFS_param.m_events_stages_history_sizing. */
+  ulong m_events_stages_history_sizing;
+  /** Default value for @c PFS_param.m_events_stages_history_long_sizing. */
+  ulong m_events_stages_history_long_sizing;
+  /** Default value for @c PFS_param.m_events_statements_history_sizing. */
+  ulong m_events_statements_history_sizing;
+  /** Default value for @c PFS_param.m_events_statements_history_long_sizing. */
+  ulong m_events_statements_history_long_sizing;
+  /** Default value for @c PFS_param.m_digest_sizing. */
+  ulong m_digest_sizing;
+  /** Default value for @c PFS_param.m_session_connect_attrs_sizing. */
+  ulong m_session_connect_attrs_sizing;
+
+  /**
+    Minimum number of tables to keep statistics for.
+    On small deployments, all the tables can fit into the table definition cache,
+    and this value can be 0.
+    On big deployments, the table definition cache is only a subset of all the tables
+    in the database, which are accounted for here.
+  */
+  ulong m_min_number_of_tables;
+
+  /**
+    Load factor for 'volatile' objects (mutexes, table handles, ...).
+    Instrumented objects that:
+    - use little memory
+    - are created/destroyed very frequently
+    should be stored in a low density (mostly empty) memory buffer,
+    to optimize for speed.
+  */
+  float m_load_factor_volatile;
+  /**
+    Load factor for 'normal' objects (files).
+    Instrumented objects that:
+    - use a medium amount of memory
+    - are created/destroyed 
+    should be stored in a medium density memory buffer,
+    as a trade off between space and speed.
+  */
+  float m_load_factor_normal;
+  /**
+    Load factor for 'static' objects (table shares).
+    Instrumented objects that:
+    - use a lot of memory
+    - are created/destroyed very rarely
+    can be stored in a high density (mostly packed) memory buffer,
+    to optimize for space.
+  */
+  float m_load_factor_static;
+};
+
+PFS_sizing_data small_data=
+{
+  /* Account / user / host */
+  10, 5, 20,
+  /* History sizes */
+  5, 100, 5, 100, 5, 100,
+  /* Digests */
+  1000,
+  /* Session connect attrs. */
+  512,
+  /* Min tables */
+  200,
+  /* Load factors */
+  0.90, 0.90, 0.90
+};
+
+PFS_sizing_data medium_data=
+{
+  /* Account / user / host */
+  100, 100, 100,
+  /* History sizes */
+  10, 1000, 10, 1000, 10, 1000,
+  /* Digests */
+  5000,
+  /* Session connect attrs. */
+  512,
+  /* Min tables */
+  500,
+  /* Load factors */
+  0.70, 0.80, 0.90
+};
+
+PFS_sizing_data large_data=
+{
+  /* Account / user / host */
+  100, 100, 100,
+  /* History sizes */
+  10, 10000, 10, 10000, 10, 10000,
+  /* Digests */
+  10000,
+  /* Session connect attrs. */
+  512,
+  /* Min tables */
+  10000,
+  /* Load factors */
+  0.50, 0.65, 0.80
+};
+
+void enforce_range_long(long *value, long min_value, long max_value)
+{
+  if (*value < min_value)
+  {
+    *value = min_value;
+  }
+  else if (*value > max_value)
+  {
+    *value = max_value;
+  }
+}
+
+static inline ulong apply_load_factor(ulong raw_value, float factor)
+{
+  float value = ((float) raw_value) / factor;
+  return (ulong) ceil(value);
+}
+
+PFS_sizing_data *estimate_hints(PFS_global_param *param)
+{
+  /*
+    Sanitize hints, to avoid returning extremely high or low estimates.
+    If the real configuration used is outside of these bounds,
+    manual tuning will be preferable.
+  */
+
+  enforce_range_long(& param->m_hints.m_max_connections, 10, 65535);
+  enforce_range_long(& param->m_hints.m_table_definition_cache, 100, 10000);
+  enforce_range_long(& param->m_hints.m_table_open_cache, 100, 10000);
+
+  if ((param->m_hints.m_max_connections <= MAX_CONNECTIONS_DEFAULT) &&
+      (param->m_hints.m_table_definition_cache <= TABLE_DEF_CACHE_DEFAULT) &&
+      (param->m_hints.m_table_open_cache <= TABLE_OPEN_CACHE_DEFAULT))
+  {
+    /* The my.cnf used is either unchanged, or lower than factory defaults. */
+    return & small_data;
+  }
+
+  if ((param->m_hints.m_max_connections <= MAX_CONNECTIONS_DEFAULT * 2) &&
+      (param->m_hints.m_table_definition_cache <= TABLE_DEF_CACHE_DEFAULT * 2) &&
+      (param->m_hints.m_table_open_cache <= TABLE_OPEN_CACHE_DEFAULT * 2))
+  {
+    /* Some defaults have been increased, to "moderate" values. */
+    return & medium_data;
+  }
+
+  /* Looks like a server in production. */
+  return & large_data;
+}
+
+static void apply_heuristic(PFS_global_param *p, PFS_sizing_data *h)
+{
+  ulong count;
+  ulong con = p->m_hints.m_max_connections;
+  ulong handle = p->m_hints.m_table_open_cache;
+  ulong share = p->m_hints.m_table_definition_cache;
+  ulong file = p->m_hints.m_open_files_limit;
+
+  if (p->m_table_sizing < 0)
+  {
+    count= handle;
+
+    p->m_table_sizing= apply_load_factor(count, h->m_load_factor_volatile);
+  }
+
+  if (p->m_table_share_sizing < 0)
+  {
+    count= share;
+
+    count= max<ulong>(count, h->m_min_number_of_tables);
+    p->m_table_share_sizing= apply_load_factor(count, h->m_load_factor_static);
+  }
+
+  if (p->m_account_sizing < 0)
+  {
+    p->m_account_sizing= h->m_account_sizing;
+  }
+
+  if (p->m_user_sizing < 0)
+  {
+    p->m_user_sizing= h->m_user_sizing;
+  }
+
+  if (p->m_host_sizing < 0)
+  {
+    p->m_host_sizing= h->m_host_sizing;
+  }
+
+  if (p->m_events_waits_history_sizing < 0)
+  {
+    p->m_events_waits_history_sizing= h->m_events_waits_history_sizing;
+  }
+
+  if (p->m_events_waits_history_long_sizing < 0)
+  {
+    p->m_events_waits_history_long_sizing= h->m_events_waits_history_long_sizing;
+  }
+
+  if (p->m_events_stages_history_sizing < 0)
+  {
+    p->m_events_stages_history_sizing= h->m_events_stages_history_sizing;
+  }
+
+  if (p->m_events_stages_history_long_sizing < 0)
+  {
+    p->m_events_stages_history_long_sizing= h->m_events_stages_history_long_sizing;
+  }
+
+  if (p->m_events_statements_history_sizing < 0)
+  {
+    p->m_events_statements_history_sizing= h->m_events_statements_history_sizing;
+  }
+
+  if (p->m_events_statements_history_long_sizing < 0)
+  {
+    p->m_events_statements_history_long_sizing= h->m_events_statements_history_long_sizing;
+  }
+
+  if (p->m_digest_sizing < 0)
+  {
+    p->m_digest_sizing= h->m_digest_sizing;
+  }
+
+  if (p->m_session_connect_attrs_sizing < 0)
+  {
+    p->m_session_connect_attrs_sizing= h->m_session_connect_attrs_sizing;
+  }
+
+  if (p->m_mutex_sizing < 0)
+  {
+    count= fixed_mutex_instances
+      + con * mutex_per_connection
+      + handle * mutex_per_handle
+      + share * mutex_per_share;
+
+    p->m_mutex_sizing= apply_load_factor(count, h->m_load_factor_volatile);
+  }
+
+  if (p->m_rwlock_sizing < 0)
+  {
+    count= fixed_rwlock_instances
+      + con * rwlock_per_connection
+      + handle * rwlock_per_handle
+      + share * rwlock_per_share;
+
+    p->m_rwlock_sizing= apply_load_factor(count, h->m_load_factor_volatile);
+  }
+
+  if (p->m_cond_sizing < 0)
+  {
+    ulong count;
+    count= fixed_cond_instances
+      + con * cond_per_connection
+      + handle * cond_per_handle
+      + share * cond_per_share;
+
+    p->m_cond_sizing= apply_load_factor(count, h->m_load_factor_volatile);
+  }
+
+  if (p->m_file_sizing < 0)
+  {
+    count= fixed_file_instances
+      + con * file_per_connection
+      + handle * file_per_handle
+      + share * file_per_share;
+
+    count= max<ulong>(count, file);
+    p->m_file_sizing= apply_load_factor(count, h->m_load_factor_normal);
+  }
+
+  if (p->m_socket_sizing < 0)
+  {
+    count= fixed_socket_instances
+      + con * socket_per_connection
+      + handle * socket_per_handle
+      + share * socket_per_share;
+
+    p->m_socket_sizing= apply_load_factor(count, h->m_load_factor_volatile);
+  }
+
+  if (p->m_thread_sizing < 0)
+  {
+    count= fixed_thread_instances
+      + con * thread_per_connection
+      + handle * thread_per_handle
+      + share * thread_per_share;
+
+    p->m_thread_sizing= apply_load_factor(count, h->m_load_factor_volatile);
+  }
+}
+
+void pfs_automated_sizing(PFS_global_param *param)
+{
+  PFS_sizing_data *heuristic;
+  heuristic= estimate_hints(param);
+  apply_heuristic(param, heuristic);
+
+  DBUG_ASSERT(param->m_account_sizing >= 0);
+  DBUG_ASSERT(param->m_digest_sizing >= 0);
+  DBUG_ASSERT(param->m_host_sizing >= 0);
+  DBUG_ASSERT(param->m_user_sizing >= 0);
+
+  DBUG_ASSERT(param->m_events_waits_history_sizing >= 0);
+  DBUG_ASSERT(param->m_events_waits_history_long_sizing >= 0);
+  DBUG_ASSERT(param->m_events_stages_history_sizing >= 0);
+  DBUG_ASSERT(param->m_events_stages_history_long_sizing >= 0);
+  DBUG_ASSERT(param->m_events_statements_history_sizing >= 0);
+  DBUG_ASSERT(param->m_events_statements_history_long_sizing >= 0);
+  DBUG_ASSERT(param->m_session_connect_attrs_sizing >= 0);
+
+  DBUG_ASSERT(param->m_mutex_sizing >= 0);
+  DBUG_ASSERT(param->m_rwlock_sizing >= 0);
+  DBUG_ASSERT(param->m_cond_sizing >= 0);
+  DBUG_ASSERT(param->m_file_sizing >= 0);
+  DBUG_ASSERT(param->m_socket_sizing >= 0);
+  DBUG_ASSERT(param->m_thread_sizing >= 0);
+  DBUG_ASSERT(param->m_table_sizing >= 0);
+  DBUG_ASSERT(param->m_table_share_sizing >= 0);
+}
+

=== modified file 'storage/perfschema/pfs_engine_table.cc'
--- a/storage/perfschema/pfs_engine_table.cc	2012-05-31 15:15:33 +0000
+++ b/storage/perfschema/pfs_engine_table.cc	2012-06-01 08:39:34 +0000
@@ -1336,72 +1336,80 @@ bool pfs_show_status(handlerton *hton, T
       total_memory+= size;
       break;
     case 137:
+      name= "session_connect_attrs.row_size";
+      size= thread_max;
+      break;
+    case 138:
+      name= "session_connect_attrs.row_count";
+      size= session_connect_attrs_size_per_thread;
+      break;
+    case 139:
       name= "session_connect_attrs.memory";
       size= thread_max * session_connect_attrs_size_per_thread;
       total_memory+= size;
       break;
 
-    case 138:
+    case 140:
       name= "(account_hash).count";
       size= account_hash.count;
       break;
-    case 139:
+    case 141:
       name= "(account_hash).size";
       size= account_hash.size;
       break;
-    case 140:
+    case 142:
       name= "(digest_hash).count";
       size= digest_hash.count;
       break;
-    case 141:
+    case 143:
       name= "(digest_hash).size";
       size= digest_hash.size;
       break;
-    case 142:
+    case 144:
       name= "(filename_hash).count";
       size= filename_hash.count;
       break;
-    case 143:
+    case 145:
       name= "(filename_hash).size";
       size= filename_hash.size;
       break;
-    case 144:
+    case 146:
       name= "(host_hash).count";
       size= host_hash.count;
       break;
-    case 145:
+    case 147:
       name= "(host_hash).size";
       size= host_hash.size;
       break;
-    case 146:
+    case 148:
       name= "(setup_actor_hash).count";
       size= setup_actor_hash.count;
       break;
-    case 147:
+    case 149:
       name= "(setup_actor_hash).size";
       size= setup_actor_hash.size;
       break;
-    case 148:
+    case 150:
       name= "(setup_object_hash).count";
       size= setup_object_hash.count;
       break;
-    case 149:
+    case 151:
       name= "(setup_object_hash).size";
       size= setup_object_hash.size;
       break;
-    case 150:
+    case 152:
       name= "(table_share_hash).count";
       size= table_share_hash.count;
       break;
-    case 151:
+    case 153:
       name= "(table_share_hash).size";
       size= table_share_hash.size;
       break;
-    case 152:
+    case 154:
       name= "(user_hash).count";
       size= user_hash.count;
       break;
-    case 153:
+    case 155:
       name= "(user_hash).size";
       size= user_hash.size;
       break;
@@ -1410,7 +1418,7 @@ bool pfs_show_status(handlerton *hton, T
       This case must be last,
       for aggregation in total_memory.
     */
-    case 154:
+    case 156:
       name= "performance_schema.memory";
       size= total_memory;
       /* This will fail if something is not advertised here */

=== modified file 'storage/perfschema/pfs_global.cc'
--- a/storage/perfschema/pfs_global.cc	2012-05-15 19:14:49 +0000
+++ b/storage/perfschema/pfs_global.cc	2012-05-25 16:14:57 +0000
@@ -51,6 +51,7 @@ void *pfs_malloc(size_t size, myf flags)
 
   void *ptr;
 
+#ifdef PFS_ALIGNEMENT
 #ifdef HAVE_POSIX_MEMALIGN
   /* Linux */
   if (unlikely(posix_memalign(& ptr, PFS_ALIGNEMENT, size)))
@@ -68,13 +69,16 @@ void *pfs_malloc(size_t size, myf flags)
   if (unlikely(ptr == NULL))
     return NULL;
 #else
+#error "Missing implementation for PFS_ALIGNENT"
+#endif /* HAVE_ALIGNED_MALLOC */
+#endif /* HAVE_MEMALIGN */
+#endif /* HAVE_POSIX_MEMALIGN */
+#else /* PFS_ALIGNMENT */
   /* Everything else */
   ptr= malloc(size);
   if (unlikely(ptr == NULL))
     return NULL;
-#endif /* HAVE_ALIGNED_MALLOC */
-#endif /* HAVE_MEMALIGN */
-#endif /* HAVE_POSIX_MEMALIGN */
+#endif
 
   pfs_allocated_memory+= size;
   if (flags & MY_ZEROFILL)

=== modified file 'storage/perfschema/pfs_global.h'
--- a/storage/perfschema/pfs_global.h	2012-05-15 16:18:30 +0000
+++ b/storage/perfschema/pfs_global.h	2012-05-25 16:14:57 +0000
@@ -30,7 +30,7 @@ extern bool pfs_initialized;
 extern ulonglong pfs_allocated_memory;
 
 #if defined(HAVE_POSIX_MEMALIGN) || defined(HAVE_MEMALIGN) || defined(HAVE_ALIGNED_MALLOC)
-#define PFS_ALIGNEMENT 128
+#define PFS_ALIGNEMENT 64
 #define PFS_ALIGNED MY_ALIGNED(PFS_ALIGNEMENT)
 #else
 /*

=== modified file 'storage/perfschema/pfs_server.cc'
--- a/storage/perfschema/pfs_server.cc	2012-05-15 09:39:47 +0000
+++ b/storage/perfschema/pfs_server.cc	2012-05-25 07:53:01 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
 
   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
@@ -50,7 +50,7 @@ static void cleanup_performance_schema(v
 void cleanup_instrument_config(void);
 
 struct PSI_bootstrap*
-initialize_performance_schema(const PFS_global_param *param)
+initialize_performance_schema(PFS_global_param *param)
 {
   pfs_initialized= false;
 
@@ -58,6 +58,8 @@ initialize_performance_schema(const PFS_
   global_table_io_stat.reset();
   global_table_lock_stat.reset();
 
+  pfs_automated_sizing(param);
+
   if (! param->m_enabled)
   {
     /*

=== modified file 'storage/perfschema/pfs_server.h'
--- a/storage/perfschema/pfs_server.h	2012-05-31 15:15:33 +0000
+++ b/storage/perfschema/pfs_server.h	2012-06-01 08:39:34 +0000
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
 
   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
@@ -24,101 +24,50 @@
 #ifndef PFS_MAX_MUTEX_CLASS
   #define PFS_MAX_MUTEX_CLASS 200
 #endif
-#ifndef PFS_MAX_MUTEX
-  #define PFS_MAX_MUTEX 1000000
-#endif
 #ifndef PFS_MAX_RWLOCK_CLASS
   #define PFS_MAX_RWLOCK_CLASS 30
 #endif
-#ifndef PFS_MAX_RWLOCK
-  #define PFS_MAX_RWLOCK 1000000
-#endif
 #ifndef PFS_MAX_COND_CLASS
   #define PFS_MAX_COND_CLASS 80
 #endif
-#ifndef PFS_MAX_COND
-  #define PFS_MAX_COND 1000
-#endif
 #ifndef PFS_MAX_THREAD_CLASS
   #define PFS_MAX_THREAD_CLASS 50
 #endif
-#ifndef PFS_MAX_THREAD
-  #define PFS_MAX_THREAD 1000
-#endif
 #ifndef PFS_MAX_FILE_CLASS
   #define PFS_MAX_FILE_CLASS 50
 #endif
-#ifndef PFS_MAX_FILE
-  #define PFS_MAX_FILE 10000
-#endif
 #ifndef PFS_MAX_FILE_HANDLE
   #define PFS_MAX_FILE_HANDLE 32768
 #endif
-#ifndef PFS_MAX_SOCKETS
-  #define PFS_MAX_SOCKETS 1000
-#endif
 #ifndef PFS_MAX_SOCKET_CLASS
   #define PFS_MAX_SOCKET_CLASS 10
 #endif
-#ifndef PFS_MAX_TABLE_SHARE
-  #define PFS_MAX_TABLE_SHARE 1000
-#endif
-#ifndef PFS_MAX_TABLE
-  #define PFS_MAX_TABLE 10000
-#endif
-#ifndef PFS_WAITS_HISTORY_SIZE
-  #define PFS_WAITS_HISTORY_SIZE 10
-#endif
-#ifndef PFS_WAITS_HISTORY_LONG_SIZE
-  #define PFS_WAITS_HISTORY_LONG_SIZE 10000
-#endif
 #ifndef PFS_MAX_SETUP_ACTOR
   #define PFS_MAX_SETUP_ACTOR 100
 #endif
 #ifndef PFS_MAX_SETUP_OBJECT
   #define PFS_MAX_SETUP_OBJECT 100
 #endif
-#ifndef PFS_MAX_HOST
-  #define PFS_MAX_HOST 100
-#endif
-#ifndef PFS_MAX_USER
-  #define PFS_MAX_USER 100
-#endif
-#ifndef PFS_MAX_ACCOUNT
-  #define PFS_MAX_ACCOUNT 100
-#endif
 #ifndef PFS_MAX_STAGE_CLASS
   #define PFS_MAX_STAGE_CLASS 150
 #endif
-#ifndef PFS_STAGES_HISTORY_SIZE
-  #define PFS_STAGES_HISTORY_SIZE 10
-#endif
-#ifndef PFS_STAGES_HISTORY_LONG_SIZE
-  #define PFS_STAGES_HISTORY_LONG_SIZE 10000
-#endif
-#ifndef PFS_STATEMENTS_HISTORY_SIZE
-  #define PFS_STATEMENTS_HISTORY_SIZE 10
-#endif
-#ifndef PFS_STATEMENTS_HISTORY_LONG_SIZE
-  #define PFS_STATEMENTS_HISTORY_LONG_SIZE 10000
-#endif
 #ifndef PFS_STATEMENTS_STACK_SIZE
   #define PFS_STATEMENTS_STACK_SIZE 10
 #endif
-#ifndef PFS_DIGEST_SIZE
-  #define PFS_DIGEST_SIZE 200
-#endif
-#ifndef PFS_CONNECT_ATTRS_SIZE
-  #define PFS_SESSION_CONNECT_ATTRS_SIZE 2048
-#endif
-
 
+struct PFS_sizing_hints
+{
+  long m_table_definition_cache;
+  long m_table_open_cache;
+  long m_max_connections;
+  long m_open_files_limit;
+};
 
 /** Performance schema global sizing parameters. */
 struct PFS_global_param
 {
   /** True if the performance schema is enabled. */
-  bool m_enabled; 
+  bool m_enabled;
   /** Default values for SETUP_CONSUMERS. */
   bool m_consumer_events_stages_current_enabled;
   bool m_consumer_events_stages_history_enabled;
@@ -160,7 +109,7 @@ struct PFS_global_param
     Maximum number of instrumented table share.
     @sa table_share_lost.
   */
-  ulong m_table_share_sizing;
+  long m_table_share_sizing;
   /**
     Maximum number of instrumented file classes.
     @sa file_class_lost.
@@ -170,83 +119,86 @@ struct PFS_global_param
     Maximum number of instrumented mutex instances.
     @sa mutex_lost.
   */
-  ulong m_mutex_sizing;
+  long m_mutex_sizing;
   /**
     Maximum number of instrumented rwlock instances.
     @sa rwlock_lost.
   */
-  ulong m_rwlock_sizing;
+  long m_rwlock_sizing;
   /**
     Maximum number of instrumented cond instances.
     @sa cond_lost.
   */
-  ulong m_cond_sizing;
+  long m_cond_sizing;
   /**
     Maximum number of instrumented thread instances.
     @sa thread_lost.
   */
-  ulong m_thread_sizing;
+  long m_thread_sizing;
   /**
     Maximum number of instrumented table handles.
     @sa table_lost.
   */
-  ulong m_table_sizing;
+  long m_table_sizing;
   /**
     Maximum number of instrumented file instances.
     @sa file_lost.
   */
-  ulong m_file_sizing;
+  long m_file_sizing;
   /**
     Maximum number of instrumented file handles.
     @sa file_handle_lost.
   */
-  ulong m_file_handle_sizing;
+  long m_file_handle_sizing;
   /**
     Maxium number of instrumented socket instances
     @sa socket_lost  
   */
-  ulong m_socket_sizing;
+  long m_socket_sizing;
   /**
     Maximum number of instrumented socket classes.
     @sa socket_class_lost.
   */
   ulong m_socket_class_sizing;
   /** Maximum number of rows per thread in table EVENTS_WAITS_HISTORY. */
-  ulong m_events_waits_history_sizing;
+  long m_events_waits_history_sizing;
   /** Maximum number of rows in table EVENTS_WAITS_HISTORY_LONG. */
-  ulong m_events_waits_history_long_sizing;
+  long m_events_waits_history_long_sizing;
   /** Maximum number of rows in table SETUP_ACTORS. */
   ulong m_setup_actor_sizing;
   /** Maximum number of rows in table SETUP_OBJECTS. */
   ulong m_setup_object_sizing;
   /** Maximum number of rows in table HOSTS. */
-  ulong m_host_sizing;
+  long m_host_sizing;
   /** Maximum number of rows in table USERS. */
-  ulong m_user_sizing;
+  long m_user_sizing;
   /** Maximum number of rows in table ACCOUNTS. */
-  ulong m_account_sizing;
+  long m_account_sizing;
   /**
     Maximum number of instrumented stage classes.
     @sa stage_class_lost.
   */
   ulong m_stage_class_sizing;
   /** Maximum number of rows per thread in table EVENTS_STAGES_HISTORY. */
-  ulong m_events_stages_history_sizing;
+  long m_events_stages_history_sizing;
   /** Maximum number of rows in table EVENTS_STAGES_HISTORY_LONG. */
-  ulong m_events_stages_history_long_sizing;
+  long m_events_stages_history_long_sizing;
   /**
     Maximum number of instrumented statement classes.
     @sa statement_class_lost.
   */
   ulong m_statement_class_sizing;
   /** Maximum number of rows per thread in table EVENTS_STATEMENT_HISTORY. */
-  ulong m_events_statements_history_sizing;
+  long m_events_statements_history_sizing;
   /** Maximum number of rows in table EVENTS_STATEMENTS_HISTORY_LONG. */
-  ulong m_events_statements_history_long_sizing;
+  long m_events_statements_history_long_sizing;
   /** Maximum number of digests to be captured */
-  ulong m_digest_sizing;
+  long m_digest_sizing;
   /** Maximum number of session attribute strings per thread */
-  ulong m_session_connect_attrs_sizing;
+  long m_session_connect_attrs_sizing;
+
+  /** Sizing hints, for auto tuning. */
+  PFS_sizing_hints m_hints;
 };
 
 /**
@@ -261,7 +213,9 @@ extern PFS_global_param pfs_param;
   @return A boostrap handle, or NULL.
 */
 struct PSI_bootstrap*
-initialize_performance_schema(const PFS_global_param *param);
+initialize_performance_schema(PFS_global_param *param);
+
+void pfs_automated_sizing(PFS_global_param *param);
 
 /**
   Initialize the performance schema ACL.

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (marc.alff:3954 to 3955) WL#6135Marc Alff5 Jun