From 10ee1b95b80ef1dc2fd3142e04f6031cc8be9e9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 24 Jul 2019 20:02:07 +0300 Subject: Remove ut_usectime(), ut_gettimeofday() Replace ut_usectime() with my_interval_timer(), which is equivalent, but monotonically counting nanoseconds instead of counting the microseconds of real time. os_event_wait_time_low(): Use my_hrtime() instead of ut_usectime(). FIXME: Set a clock attribute on the condition variable that allows a monotonic clock to be chosen as the time base, so that the wait is immune to adjustments of the system clock. --- storage/xtradb/buf/buf0buf.cc | 51 ++++++++++++------------------------------- 1 file changed, 14 insertions(+), 37 deletions(-) (limited to 'storage/xtradb/buf/buf0buf.cc') diff --git a/storage/xtradb/buf/buf0buf.cc b/storage/xtradb/buf/buf0buf.cc index 3326f734e45..0f83e7ce011 100644 --- a/storage/xtradb/buf/buf0buf.cc +++ b/storage/xtradb/buf/buf0buf.cc @@ -2485,10 +2485,6 @@ buf_page_get_zip( ibool discard_attempted = FALSE; ibool must_read; trx_t* trx = NULL; - ulint sec; - ulint ms; - ib_uint64_t start_time; - ib_uint64_t finish_time; buf_pool_t* buf_pool = buf_pool_get(space, offset); if (UNIV_UNLIKELY(innobase_get_slow_log())) { @@ -2607,14 +2603,10 @@ got_block: if (must_read) { /* Let us wait until the read operation completes */ - - if (UNIV_UNLIKELY(trx && trx->take_stats)) - { - ut_usectime(&sec, &ms); - start_time = (ib_uint64_t)sec * 1000000 + ms; - } else { - start_time = 0; - } + const ulonglong start_time = UNIV_UNLIKELY(trx + && trx->take_stats) + ? my_interval_timer() + : 0; for (;;) { enum buf_io_fix io_fix; @@ -2629,11 +2621,9 @@ got_block: break; } } - if (UNIV_UNLIKELY(start_time != 0)) - { - ut_usectime(&sec, &ms); - finish_time = (ib_uint64_t)sec * 1000000 + ms; - trx->io_reads_wait_timer += (ulint)(finish_time - start_time); + if (UNIV_UNLIKELY(start_time != 0)) { + trx->io_reads_wait_timer += ulint( + (my_interval_timer() - start_time) / 1000); } } @@ -3013,21 +3003,13 @@ buf_wait_for_read(buf_block_t* block, trx_t* trx) if (buf_block_get_io_fix_unlocked(block) == BUF_IO_READ) { - ib_uint64_t start_time; - ulint sec; - ulint ms; - /* Wait until the read operation completes */ ib_mutex_t* mutex = buf_page_get_mutex(&block->page); - - if (UNIV_UNLIKELY(trx && trx->take_stats)) - { - ut_usectime(&sec, &ms); - start_time = (ib_uint64_t)sec * 1000000 + ms; - } else { - start_time = 0; - } + const ulonglong start_time = UNIV_UNLIKELY(trx + && trx->take_stats) + ? my_interval_timer() + : 0; for (;;) { buf_io_fix io_fix; @@ -3047,15 +3029,10 @@ buf_wait_for_read(buf_block_t* block, trx_t* trx) } } - if (UNIV_UNLIKELY(start_time != 0)) - { - ut_usectime(&sec, &ms); - ib_uint64_t finish_time - = (ib_uint64_t)sec * 1000000 + ms; - trx->io_reads_wait_timer - += (ulint)(finish_time - start_time); + if (UNIV_UNLIKELY(start_time != 0)) { + trx->io_reads_wait_timer += ulint( + (my_interval_timer() - start_time) / 1000); } - } } -- cgit v1.2.1