性能模式使用这种内存分配模型:The Performance Schema uses this memory allocation model:
可能在服务器启动时分配内存May allocate memory at server startup
可能在服务器运行期间分配额外内存May allocate additional memory during server operation
在服务器运行期间从不释放内存(尽管可能会被回收)Never free memory during server operation (although it might be recycled)
在关闭时释放所有使用的内存Free all memory used at shutdown
其结果是放宽内存限制,以便性能模式可以在较少配置下使用,并减少内存占用,使消耗随服务器负载而变化。使用的内存取决于实际见到的负载,而不是估计的或明确配置的负载。The result is to relax memory constraints so that the Performance Schema can be used with less configuration, and to decrease the memory footprint so that consumption scales with server load. Memory used depends on the load actually seen, not the load estimated or explicitly configured for.
一些性能模式的大小参数是自动缩放的,除非您想对内存分配设定明确限制,否则无需显式配置:Several Performance Schema sizing parameters are autoscaled and need not be configured explicitly unless you want to establish an explicit limit on memory allocation:
performance_schema_accounts_size performance_schema_hosts_size performance_schema_max_cond_instances performance_schema_max_file_instances performance_schema_max_index_stat performance_schema_max_metadata_locks performance_schema_max_mutex_instances performance_schema_max_prepared_statements_instances performance_schema_max_program_instances performance_schema_max_rwlock_instances performance_schema_max_socket_instances performance_schema_max_table_handles performance_schema_max_table_instances performance_schema_max_table_lock_stat performance_schema_max_thread_instances performance_schema_users_size
对于自动缩放参数,配置方式如下:For an autoscaled parameter, configuration works like this:
当值设置为 -1(默认值)时,参数会自动缩放:With the value set to -1 (the default), the parameter is autoscaled:
相应的内部缓冲区最初为空,并且不会分配内存。The corresponding internal buffer is empty initially and no memory is allocated.
随着性能模式收集数据,会在相应的缓冲区中分配内存。缓冲区大小不受限制,可能会随着负载增长。As the Performance Schema collects data, memory is allocated in the corresponding buffer. The buffer size is unbounded, and may grow with the load.
当值设置为 0 时:With the value set to 0:
相应的内部缓冲区最初为空,并且不会分配内存。The corresponding internal buffer is empty initially and no memory is allocated.
当值设置为
N> 0 时:With the value set toN> 0:相应的内部缓冲区最初为空,并且不会分配内存。The corresponding internal buffer is empty initially and no memory is allocated.
随着性能模式收集数据,会在相应的缓冲区中分配内存,直到缓冲区大小达到
N。As the Performance Schema collects data, memory is allocated in the corresponding buffer, until the buffer size reachesN.一旦缓冲区大小达到
N,将不再分配内存。性能模式为该缓冲区收集的数据会丢失,任何相应的“丢失实例”计数器将会增加。Once the buffer size reachesN, no more memory is allocated. Data collected by the Performance Schema for this buffer is lost, and any corresponding “lost instance” counters are incremented.
要查看性能模式(Performance Schema)使用了多少内存,请检查为此目的设计的仪器。性能模式在内部分配内存,并将每个缓冲区与专用仪器相关联,以便内存消耗可以追踪到各个缓冲区。以memory/performance_schema/为前缀命名的仪器显示为这些内部缓冲区分配了多少内存。缓冲区是服务器全局的,因此这些仪器仅显示在memory_summary_global_by_event_name表中,而不会显示在其他memory_summary_by_表中。To see how much memory the Performance Schema is using, check the
instruments designed for that purpose. The Performance Schema
allocates memory internally and associates each buffer with a
dedicated instrument so that memory consumption can be traced to
individual buffers. Instruments named with the prefix
xxx_by_event_namememory/performance_schema/ expose how much
memory is allocated for these internal buffers. The buffers are
global to the server, so the instruments are displayed only in the
memory_summary_global_by_event_name
table, and not in other
memory_summary_by_
tables.xxx_by_event_name
此查询显示与内存仪器相关的信息:This query shows the information associated with the memory instruments:
SELECT * FROM performance_schema.memory_summary_global_by_event_name WHERE EVENT_NAME LIKE 'memory/performance_schema/%';