-
Marc Alff authored
This is a performance improvement. Before this fix, in the performance schema instrumentation, the execution path was typically, in the instrumented part: PSI_MUTEX_CALL(start_mutex_wait)(...); psi_start_mutex_wait_v1() { ... if (!pfs_mutex->m_enabled) { return nullptr; } ... } In other words, a function call is made to some low level instrumentation APIs first, and then the m_enabled flag is tested. For instrumentation which is both: - invoked very frequently - disabled by default like the MUTEX, RWLOCK, COND and SOCKET instrumentation, this leads to performance overhead. With this fix, the order of operations is reversed: - the m_enabled flag is tested first - if enabled, the low level API is invoked. The performance schema implementation no longer checks for the m_enabled flag, as this is now the responsibility of the caller. The full fix consist of the following changes. 1) The content of header file: include/mysql/psi/psi_base.h has been moved to: include/mysql/components/services/psi_bits.h This resolves a long standing existing issue, as components should build only using services headers, and not depend in server headers. Components do need the various PSI_FLAG definitions. 2) The whole code base has been adjusted to this header file change. 3) In psi_bits.h, the mutex instrumentation was: struct PSI_mutex; PSI_mutex was a totally opaque structure. Now, it is: struct PSI_instr { bool m_enabled; }; struct PSI_mutex : PSI_instr {}; The bool m_enabled flag is now visible to the caller, which must check the flag before making low level calls. 4) Instrumentation helpers api, which expands into low level performance schema calls, have been adjusted, like in inline_mysql_mutex_lock(), to check for the m_enabled flag. For code having it's own helpers (innodb), the code was adjusted also. 5) The RWLOCK instrumentation was changed the same way, and helpers adjusted as a result. 6) The COND instrumentation was changed the same way, and helpers adjusted as a result. 6) The SOCKET instrumentation was changed the same way, and helpers adjusted as a result. 7) Performance schema unit tests have been adjusted. 8) For the LOCK_ORDER tool, which also implements the performance schema instrumentation interface, the same change was implemented. Approved by: Chris Powers <chris.powers@oracle.com> Approved by: Georgi Kodinov <georgi.kodinov@oracle.com>
Marc Alff authoredThis is a performance improvement. Before this fix, in the performance schema instrumentation, the execution path was typically, in the instrumented part: PSI_MUTEX_CALL(start_mutex_wait)(...); psi_start_mutex_wait_v1() { ... if (!pfs_mutex->m_enabled) { return nullptr; } ... } In other words, a function call is made to some low level instrumentation APIs first, and then the m_enabled flag is tested. For instrumentation which is both: - invoked very frequently - disabled by default like the MUTEX, RWLOCK, COND and SOCKET instrumentation, this leads to performance overhead. With this fix, the order of operations is reversed: - the m_enabled flag is tested first - if enabled, the low level API is invoked. The performance schema implementation no longer checks for the m_enabled flag, as this is now the responsibility of the caller. The full fix consist of the following changes. 1) The content of header file: include/mysql/psi/psi_base.h has been moved to: include/mysql/components/services/psi_bits.h This resolves a long standing existing issue, as components should build only using services headers, and not depend in server headers. Components do need the various PSI_FLAG definitions. 2) The whole code base has been adjusted to this header file change. 3) In psi_bits.h, the mutex instrumentation was: struct PSI_mutex; PSI_mutex was a totally opaque structure. Now, it is: struct PSI_instr { bool m_enabled; }; struct PSI_mutex : PSI_instr {}; The bool m_enabled flag is now visible to the caller, which must check the flag before making low level calls. 4) Instrumentation helpers api, which expands into low level performance schema calls, have been adjusted, like in inline_mysql_mutex_lock(), to check for the m_enabled flag. For code having it's own helpers (innodb), the code was adjusted also. 5) The RWLOCK instrumentation was changed the same way, and helpers adjusted as a result. 6) The COND instrumentation was changed the same way, and helpers adjusted as a result. 6) The SOCKET instrumentation was changed the same way, and helpers adjusted as a result. 7) Performance schema unit tests have been adjusted. 8) For the LOCK_ORDER tool, which also implements the performance schema instrumentation interface, the same change was implemented. Approved by: Chris Powers <chris.powers@oracle.com> Approved by: Georgi Kodinov <georgi.kodinov@oracle.com>
Loading