Bug #80979 Doublewrite buffer event waits should be annotated for Performance Schema
Submitted: 6 Apr 2016 14:25 Modified: 7 Apr 2016 11:13
Reporter: Laurynas Biveinis (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Performance Schema Severity:S3 (Non-critical)
Version:5.7 OS:Any
Assigned to: CPU Architecture:Any
Tags: doublewrite, innodb, performance schema
Triage: Needs Triage: D5 (Feature request)

[6 Apr 2016 14:25] Laurynas Biveinis
Description:
Event waits are not accounted by Performance Schema as any kind of wait. Most of the time, this is correct, as event waits tend to be used when i.e. there is no work to do, or some time has to pass. But some waits are blocking useful work from proceeding. As they are invisible in PFS, they make PFS wait data incomplete.

Two such events are the doublewrite buffer s_event and b_event. s_event is waited for when there is no free single page flush slot in the doublewrite buffer, and the caller thread has to wait for one to appear. b_event is waited for when a doublewrite buffer batch is in progress of being flushed, and a thread wanting to add a page to the doublewrite buffer has to wait for that batch to complete.

In PMP they look as follows, s_event:

631 pthread_cond_wait,buf_dblwr_write_single_page(buf0dblwr.cc:1213),buf_flush_write_block_low(buf0flu.cc:1096),buf_flush_page(buf0flu.cc:1096),buf_flush_single_page_from_LRU(buf0flu.cc:2217),buf_LRU_get_free_block(buf0lru.cc:1401),...

b_event:

56 pthread_cond_wait,...,os_event_wait_low(os0event.cc:534),buf_dblwr_add_to_batch(buf0dblwr.cc:1111),...,buf_flush_LRU_list_batch(buf0flu.cc:1555),

How to repeat:
See above

Suggested fix:
Add API to PFS for event wait annotation. Annotate these two doublewrite buffer events, review the rest of server code for other events needing annotation.
[7 Apr 2016 11:13] Umesh Shastry
Hello Laurynas,

Thank you for the feature request!

Thanks,
Umesh
[4 May 2016 9:35] Mark Leith
Note that the correct interfaces already exist within Performance Schema, this is the "wait/sync/cond" class, and "mysql_cond_wait" rather than "pthread_cond_wait".