| Bug #81928 | Feature request for sys.profiling | ||
|---|---|---|---|
| Submitted: | 20 Jun 2016 10:19 | Modified: | 22 Jun 2016 1:37 |
| Reporter: | Tsubasa Tanaka (OCA) | Email Updates: | |
| Status: | Verified | Impact on me: | |
| Category: | MySQL Server: SYS Schema | Severity: | S4 (Feature request) |
| Version: | 5.7.13 | OS: | Any |
| Assigned to: | CPU Architecture: | Any | |
| Tags: | profiling, show profile, sys | ||
[20 Jun 2016 10:19]
Tsubasa Tanaka
[20 Jun 2016 10:20]
Tsubasa Tanaka
procedure like show profile (*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.
Contribution: bug81928_show_profile.sql (application/octet-stream, text), 748 bytes.
[20 Jun 2016 10:22]
Tsubasa Tanaka
Procedures use `events_stages_history_long` and `events_statements_history_long`. Need setup_consumers's events_statements_history_long and events_stages_history_long are ENABLED = 'YES'.
[21 Jun 2016 8:34]
MySQL Verification Team
Hello Tanaka-San, Thank you for the reasonable feature request and contribution. Thanks, Umesh
[21 Jun 2016 14:15]
Mark Leith
Hello Tanaka-San, Thanks for the contribution - do you also think it may be worth adding another routine that enables/disables profiling for just a specific thread (i.e. does all of the other configuration steps listed in the documentation page you linked)? It could even turn on/off the history reporting per thread / globally in setup_actors to allow tracing just the one specific thread too, as an option.. Cheers, Mark
[22 Jun 2016 1:37]
Tsubasa Tanaka
Hello Mark,
IMHO, I don't think p_s.setup_actors is enough to control.
Because threads already connected (connection-pooled connections) are not effected by p_s.setup_actors.
If I'd like to turn off such connections'es instrumentation, I would have to update p_s.threads.instrumentation = NO.
After that, I think there are 2 ways to turn on/off profiling by sys.
# Enable profiling and leave all instrumented threads at all
1. Back up p_s settings by sys.ps_setup_save
2. UPDATE setup_instruments and UPDATE setup_consumers
3. Executing query
4. Profiling by sys.show_profiles and sys.show_profile
5. Restore p_s settings by sys.ps_setup_reload_saved
## Problems
- ps_setup_save and ps_setup_reload_saved use temporary table as copying original data. If closing connection without step 5, original p_s settings are lost.
- This may occur performance-hit under heavy workload.
# Enable profiling and turn off instrumented threads without itself
1. Back up p_s settings by sys.ps_setup_save
2. UPDATE setup_instruments and UPDATE setup_consumers and UPDATE setup_consumers
3. UPDATE threads SET instrumented = OFF WHERE thread_id <> @not_my_thread AND type = 'FOREGROUND'
4. Executing query
5. Profiling by sys.show_profiles and sys.show_profile
6. restore p_s settings by sys.ps_setup_reload_saved
7. UPDATE threads SET instrumented = ON WHERE thread_id <> @not_my_thread AND type = 'FOREGROUND'
## Problems
- ps_setup_save and ps_setup_reload_saved use temporary table as copying original data. If closing connection without step 6, original p_s settings are lost(Same as first one)
- Normal traffic's data will not be recorded (lost) between step 3 and step 7 (i.e. events_statements_summary_by_digest)
I think they are too troublesome because I don't decide users will go to final step correctly or not.
If I can use UDF, seal all steps into UDF and I will be able to call it like this.
`SELECT profilling("SELECT .. FROM .. WHERE ..");`
..(query result and profiling result are displayed)
How do you think?
