-
Marc Alff authored
Before this fix, the perforance schema memory instrumentation could cause runtime overhead when enabled. The root cause is due to instruments with the following properties: - the instrument flags are 0, defined as per thread and not global - the instrumented memory is allocated / freed very often during execution - the instrumented memory can be allocated by one thread and freed by a different thread. Not having the global (PSI_FLAG_ONLY_GLOBAL_STAT) flag indicates that the performance schema should maintain: - per thread stats - per account stats - per user stats - per host stats as well as global statistics. Frequent instrumentation, and memory transfer of ownership between threads, causes a lot of overhead when maintaining the high/low water mark. The affected code to maintain high/low water marks is: - PFS_thread::carry_memory_stat_delta() - PFS_account::carry_memory_stat_delta() - PFS_user::carry_memory_stat_delta() - PFS_host::carry_memory_stat_delta() This fix requalifies many memory instruments as global, with the flag PSI_FLAG_ONLY_GLOBAL_STAT. This is a fix for both: 1) Correctness. Instruments that keep track of a global resource, for example "memory/sql/host_cache::hostname", are by definition global. Keeping per thread stats is meaningless. 2) Performances. This avoids keeping track of high/low watermarks, and reduce overhead. Also, a minor bug was fixed in pfs_memory_claim_v1(), which did not honor the PSI_FLAG_ONLY_GLOBAL_STAT flag.
Marc Alff authoredBefore this fix, the perforance schema memory instrumentation could cause runtime overhead when enabled. The root cause is due to instruments with the following properties: - the instrument flags are 0, defined as per thread and not global - the instrumented memory is allocated / freed very often during execution - the instrumented memory can be allocated by one thread and freed by a different thread. Not having the global (PSI_FLAG_ONLY_GLOBAL_STAT) flag indicates that the performance schema should maintain: - per thread stats - per account stats - per user stats - per host stats as well as global statistics. Frequent instrumentation, and memory transfer of ownership between threads, causes a lot of overhead when maintaining the high/low water mark. The affected code to maintain high/low water marks is: - PFS_thread::carry_memory_stat_delta() - PFS_account::carry_memory_stat_delta() - PFS_user::carry_memory_stat_delta() - PFS_host::carry_memory_stat_delta() This fix requalifies many memory instruments as global, with the flag PSI_FLAG_ONLY_GLOBAL_STAT. This is a fix for both: 1) Correctness. Instruments that keep track of a global resource, for example "memory/sql/host_cache::hostname", are by definition global. Keeping per thread stats is meaningless. 2) Performances. This avoids keeping track of high/low watermarks, and reduce overhead. Also, a minor bug was fixed in pfs_memory_claim_v1(), which did not honor the PSI_FLAG_ONLY_GLOBAL_STAT flag.
Loading