Bug #118724 optimzie for performance_schema
Submitted: 26 Jul 12:08 Modified: 28 Jul 13:09
Reporter: alex xing (OCA) Email Updates:
Status: Analyzing Impact on me:
None 
Category:MySQL Server: Performance Schema Severity:S5 (Performance)
Version:8.0.42 OS:Any
Assigned to: MySQL Verification Team CPU Architecture:Any

[26 Jul 12:08] alex xing
Description:
Our online service constantly handles a large volume of short-lived connections (5000+). Compared to long-lived connections, we've found that find_thread_by_internal_id consumes a significant amount of CPU.

After analyzing the code, we discovered that find_thread_by_internal_id is invoked for every new connection and performs a traversal over a large array.

How to repeat:
just read the code or test mysqld with a large volume of short-lived connections (5000+)

Suggested fix:
To optimize performance, we could maintain an additional lookup map to reduce the traversal overhead.