Skip to content

Bug #77577: setup_timers initialization assumes CYCLE timer is always available #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions mysql-test/suite/perfschema/r/query_cache.result
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ spins
NULL
select * from performance_schema.setup_timers where name='wait';
NAME TIMER_NAME
wait CYCLE
wait {CYCLE_OR_NANOSECOND}
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 1
Expand All @@ -53,7 +53,7 @@ spins
NULL
select * from performance_schema.setup_timers where name='wait';
NAME TIMER_NAME
wait CYCLE
wait {CYCLE_OR_NANOSECOND}
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 1
Expand Down
2 changes: 2 additions & 0 deletions mysql-test/suite/perfschema/t/query_cache.test
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ show status like "Qcache_hits";

select spins from performance_schema.events_waits_current order by event_name limit 1;

--replace_result CYCLE {CYCLE_OR_NANOSECOND} NANOSECOND {CYCLE_OR_NANOSECOND}
select * from performance_schema.setup_timers where name='wait';

show status like "Qcache_queries_in_cache";
Expand All @@ -42,6 +43,7 @@ show status like "Qcache_hits";

select spins from performance_schema.events_waits_current order by event_name limit 1;

--replace_result CYCLE {CYCLE_OR_NANOSECOND} NANOSECOND {CYCLE_OR_NANOSECOND}
select * from performance_schema.setup_timers where name='wait';

show status like "Qcache_queries_in_cache";
Expand Down
35 changes: 35 additions & 0 deletions storage/perfschema/pfs_timer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,41 @@ void init_timers(void)
/* Robustness, no known cases. */
idle_timer= TIMER_NAME_CYCLE;
}

/*
For WAIT, the cycle timer is used by default. However, it is not available
on all architectures. Fall back to the nanosecond timer in this case. It is
unlikely that neither cycle nor nanosecond are available, but we continue
probing less resolution timers anyway for considency with other events.
*/
if (cycle_to_pico != 0)
{
/* Normal case. */
wait_timer= TIMER_NAME_CYCLE;
}
else if (nanosec_to_pico != 0)
{
/* Robustness, no known cases. */
wait_timer= TIMER_NAME_NANOSEC;
}
else if (microsec_to_pico != 0)
{
/* Robustness, no known cases. */
wait_timer= TIMER_NAME_MICROSEC;
}
else if (millisec_to_pico != 0)
{
/* Robustness, no known cases. */
wait_timer= TIMER_NAME_MILLISEC;
}
else
{
/*
Will never be reached on any architecture, but must provide a default if
no other timers are available.
*/
wait_timer= TIMER_NAME_TICK;
}
}

ulonglong get_timer_raw_value(enum_timer_name timer_name)
Expand Down