summaryrefslogtreecommitdiff
path: root/storage/xtradb
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2019-07-24 19:43:37 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2019-07-24 21:21:54 +0300
commitab6dd774082c57f48d998e03655c06b672799b2d (patch)
tree25c14f24e255a1480a97960005e415a43a52f3d1 /storage/xtradb
parent86767f4ac15db953c85a94ed81cd374c653e79dd (diff)
downloadmariadb-git-ab6dd774082c57f48d998e03655c06b672799b2d.tar.gz
MDEV-14154: Remove ut_time_us()
Use microsecond_interval_timer() or my_interval_timer() [in nanoseconds] instead.
Diffstat (limited to 'storage/xtradb')
-rw-r--r--storage/xtradb/buf/buf0buddy.cc7
-rw-r--r--storage/xtradb/fil/fil0crypt.cc21
-rw-r--r--storage/xtradb/handler/ha_innodb.cc15
-rw-r--r--storage/xtradb/include/srv0mon.h4
-rw-r--r--storage/xtradb/include/ut0ut.h26
-rw-r--r--storage/xtradb/page/page0cur.cc10
-rw-r--r--storage/xtradb/page/page0zip.cc12
-rw-r--r--storage/xtradb/srv/srv0srv.cc10
-rw-r--r--storage/xtradb/trx/trx0i_s.cc37
-rw-r--r--storage/xtradb/ut/ut0ut.cc20
10 files changed, 47 insertions, 115 deletions
diff --git a/storage/xtradb/buf/buf0buddy.cc b/storage/xtradb/buf/buf0buddy.cc
index a06d56a8d72..68629844067 100644
--- a/storage/xtradb/buf/buf0buddy.cc
+++ b/storage/xtradb/buf/buf0buddy.cc
@@ -612,7 +612,7 @@ buf_buddy_relocate(
if (buf_page_can_relocate(bpage)) {
/* Relocate the compressed page. */
- ullint usec = ut_time_us(NULL);
+ const ulonglong ns = my_interval_timer();
ut_a(bpage->zip.data == src);
@@ -630,11 +630,8 @@ buf_buddy_relocate(
reinterpret_cast<buf_buddy_free_t*>(src), i);
buf_buddy_stat_t* buddy_stat = &buf_pool->buddy_stat[i];
-
++buddy_stat->relocated;
-
- buddy_stat->relocated_usec += ut_time_us(NULL) - usec;
-
+ buddy_stat->relocated_usec+= (my_interval_timer() - ns) / 1000;
return(true);
}
diff --git a/storage/xtradb/fil/fil0crypt.cc b/storage/xtradb/fil/fil0crypt.cc
index 4c1608d8788..43a3bd8ff29 100644
--- a/storage/xtradb/fil/fil0crypt.cc
+++ b/storage/xtradb/fil/fil0crypt.cc
@@ -1,6 +1,6 @@
/*****************************************************************************
Copyright (C) 2013, 2015, Google Inc. All Rights Reserved.
-Copyright (c) 2014, 2018, MariaDB Corporation. All Rights Reserved.
+Copyright (c) 2014, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -1698,19 +1698,18 @@ fil_crypt_get_page_throttle_func(
state->crypt_stat.pages_read_from_disk++;
- ullint start = ut_time_us(NULL);
+ const ulonglong start = my_interval_timer();
block = buf_page_get_gen(space->id, zip_size, offset,
RW_X_LATCH,
NULL, BUF_GET_POSSIBLY_FREED,
file, line, mtr);
- ullint end = ut_time_us(NULL);
-
- if (end < start) {
- end = start; // safety...
- }
+ const ulonglong end = my_interval_timer();
state->cnt_waited++;
- state->sum_waited_us += (end - start);
+
+ if (end > start) {
+ state->sum_waited_us += (end - start) / 1000;
+ }
/* average page load */
ulint add_sleeptime_ms = 0;
@@ -2032,7 +2031,7 @@ fil_crypt_flush_space(
bool success = false;
ulint n_pages = 0;
ulint sum_pages = 0;
- ullint start = ut_time_us(NULL);
+ const ulonglong start = my_interval_timer();
do {
success = buf_flush_list(ULINT_MAX, end_lsn, &n_pages);
@@ -2040,11 +2039,11 @@ fil_crypt_flush_space(
sum_pages += n_pages;
} while (!success && !space->is_stopping());
- ullint end = ut_time_us(NULL);
+ const ulonglong end = my_interval_timer();
if (sum_pages && end > start) {
state->cnt_waited += sum_pages;
- state->sum_waited_us += (end - start);
+ state->sum_waited_us += (end - start) / 1000;
/* statistics */
state->crypt_stat.pages_flushed += sum_pages;
diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc
index 495bf729744..2a0f1d5535b 100644
--- a/storage/xtradb/handler/ha_innodb.cc
+++ b/storage/xtradb/handler/ha_innodb.cc
@@ -1948,13 +1948,14 @@ innobase_srv_conc_enter_innodb(
} else if (trx->mysql_thd != NULL
&& thd_is_replication_slave_thread(trx->mysql_thd)) {
-
- UT_WAIT_FOR(
- srv_conc_get_active_threads()
- < srv_thread_concurrency,
- srv_replication_delay * 1000);
-
- } else {
+ const ulonglong end = my_interval_timer()
+ + ulonglong(srv_replication_delay) * 1000000;
+ while (srv_conc_get_active_threads()
+ >= srv_thread_concurrency
+ || my_interval_timer() >= end) {
+ os_thread_sleep(2000 /* 2 ms */);
+ }
+ } else {
srv_conc_enter_innodb(trx);
}
}
diff --git a/storage/xtradb/include/srv0mon.h b/storage/xtradb/include/srv0mon.h
index 8d5bfad6f50..7a7902c3083 100644
--- a/storage/xtradb/include/srv0mon.h
+++ b/storage/xtradb/include/srv0mon.h
@@ -2,7 +2,7 @@
Copyright (c) 2010, 2013, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc.
-Copyright (c) 2013, 2017, MariaDB Corporation.
+Copyright (c) 2013, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
@@ -761,7 +761,7 @@ monitor counter
MONITOR_CHECK_DEFINED(value); \
if (MONITOR_IS_ON(monitor)) { \
ullint old_time = (value); \
- value = ut_time_us(NULL); \
+ value = microsecond_interval_timer(); \
MONITOR_VALUE(monitor) += (mon_type_t) (value - old_time);\
}
diff --git a/storage/xtradb/include/ut0ut.h b/storage/xtradb/include/ut0ut.h
index 1a378815c95..c5168acf3b2 100644
--- a/storage/xtradb/include/ut0ut.h
+++ b/storage/xtradb/include/ut0ut.h
@@ -109,22 +109,6 @@ private:
# define UT_LOW_PRIORITY_CPU() ((void)0)
# define UT_RESUME_PRIORITY_CPU() ((void)0)
# endif
-
-/*********************************************************************//**
-Delays execution for at most max_wait_us microseconds or returns earlier
-if cond becomes true.
-@param cond in: condition to wait for; evaluated every 2 ms
-@param max_wait_us in: maximum delay to wait, in microseconds */
-#define UT_WAIT_FOR(cond, max_wait_us) \
-do { \
- ullint start_us; \
- start_us = ut_time_us(NULL); \
- while (!(cond) \
- && ut_time_us(NULL) - start_us < (max_wait_us)) {\
- \
- os_thread_sleep(2000 /* 2 ms */); \
- } \
-} while (0)
#endif /* !UNIV_HOTBACKUP */
template <class T> T ut_min(T a, T b) { return(a < b ? a : b); }
@@ -266,16 +250,6 @@ ut_usectime(
ulint* ms); /*!< out: microseconds since the Epoch+*sec */
/**********************************************************//**
-Returns the number of microseconds since epoch. Similar to
-time(3), the return value is also stored in *tloc, provided
-that tloc is non-NULL.
-@return us since epoch */
-UNIV_INTERN
-ullint
-ut_time_us(
-/*=======*/
- ullint* tloc); /*!< out: us since epoch, if non-NULL */
-/**********************************************************//**
Returns the number of milliseconds since some epoch. The
value may wrap around. It should only be used for heuristic
purposes.
diff --git a/storage/xtradb/page/page0cur.cc b/storage/xtradb/page/page0cur.cc
index 767ae5cbf88..e9ac4b4bb04 100644
--- a/storage/xtradb/page/page0cur.cc
+++ b/storage/xtradb/page/page0cur.cc
@@ -48,7 +48,7 @@ number between 0 and 2^64-1 inclusive. The formula and the constants
being used are:
X[n+1] = (a * X[n] + c) mod m
where:
-X[0] = ut_time_us(NULL)
+X[0] = my_interval_timer()
a = 1103515245 (3^5 * 5 * 7 * 129749)
c = 12345 (3 * 5 * 823)
m = 18446744073709551616 (2^64)
@@ -61,12 +61,10 @@ page_cur_lcg_prng(void)
{
#define LCG_a 1103515245
#define LCG_c 12345
- static ib_uint64_t lcg_current = 0;
- static ibool initialized = FALSE;
+ static uint64_t lcg_current;
- if (!initialized) {
- lcg_current = (ib_uint64_t) ut_time_us(NULL);
- initialized = TRUE;
+ if (!lcg_current) {
+ lcg_current = my_interval_timer();
}
/* no need to "% 2^64" explicitly because lcg_current is
diff --git a/storage/xtradb/page/page0zip.cc b/storage/xtradb/page/page0zip.cc
index 852807dc239..0c7f9b6feff 100644
--- a/storage/xtradb/page/page0zip.cc
+++ b/storage/xtradb/page/page0zip.cc
@@ -2,7 +2,7 @@
Copyright (c) 2005, 2016, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2012, Facebook Inc.
-Copyright (c) 2014, 2018, MariaDB Corporation.
+Copyright (c) 2014, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -1240,7 +1240,7 @@ page_zip_compress(
ulint n_blobs = 0;
byte* storage;/* storage of uncompressed columns */
#ifndef UNIV_HOTBACKUP
- ullint usec = ut_time_us(NULL);
+ const ulonglong ns = my_interval_timer();
#endif /* !UNIV_HOTBACKUP */
#ifdef PAGE_ZIP_COMPRESS_DBG
FILE* logfile = NULL;
@@ -1489,7 +1489,7 @@ err_exit:
dict_index_zip_failure(index);
}
- ullint time_diff = ut_time_us(NULL) - usec;
+ const ullint time_diff = (my_interval_timer() - ns) / 1000;
page_zip_stat[page_zip->ssize - 1].compressed_usec
+= time_diff;
if (cmp_per_index_enabled) {
@@ -1557,7 +1557,7 @@ err_exit:
}
#endif /* PAGE_ZIP_COMPRESS_DBG */
#ifndef UNIV_HOTBACKUP
- ullint time_diff = ut_time_us(NULL) - usec;
+ const ullint time_diff = (my_interval_timer() - ns) / 1000;
page_zip_stat[page_zip->ssize - 1].compressed_ok++;
page_zip_stat[page_zip->ssize - 1].compressed_usec += time_diff;
if (cmp_per_index_enabled) {
@@ -3006,7 +3006,7 @@ page_zip_decompress(
mem_heap_t* heap;
ulint* offsets;
#ifndef UNIV_HOTBACKUP
- ullint usec = ut_time_us(NULL);
+ const ulonglong ns = my_interval_timer();
#endif /* !UNIV_HOTBACKUP */
ut_ad(page_zip_simple_validate(page_zip));
@@ -3192,7 +3192,7 @@ err_exit:
page_zip_fields_free(index);
mem_heap_free(heap);
#ifndef UNIV_HOTBACKUP
- ullint time_diff = ut_time_us(NULL) - usec;
+ const uint64_t time_diff = (my_interval_timer() - ns) / 1000;
page_zip_stat[page_zip->ssize - 1].decompressed++;
page_zip_stat[page_zip->ssize - 1].decompressed_usec += time_diff;
diff --git a/storage/xtradb/srv/srv0srv.cc b/storage/xtradb/srv/srv0srv.cc
index 2ea0d4ec110..f6e69618313 100644
--- a/storage/xtradb/srv/srv0srv.cc
+++ b/storage/xtradb/srv/srv0srv.cc
@@ -2903,7 +2903,7 @@ srv_master_do_active_tasks(void)
/*============================*/
{
ib_time_t cur_time = ut_time();
- ullint counter_time = ut_time_us(NULL);
+ ulonglong counter_time = microsecond_interval_timer();
ulint n_evicted = 0;
/* First do the tasks that we are suppose to do at each
@@ -2932,7 +2932,7 @@ srv_master_do_active_tasks(void)
/* Do an ibuf merge */
srv_main_thread_op_info = "doing insert buffer merge";
- counter_time = ut_time_us(NULL);
+ counter_time = microsecond_interval_timer();
ibuf_merge_in_background(false);
MONITOR_INC_TIME_IN_MICRO_SECS(
MONITOR_SRV_IBUF_MERGE_MICROSECOND, counter_time);
@@ -2994,9 +2994,7 @@ void
srv_master_do_idle_tasks(void)
/*==========================*/
{
- ullint counter_time;
ulint n_evicted = 0;
-
++srv_main_idle_loops;
MONITOR_INC(MONITOR_MASTER_IDLE_LOOPS);
@@ -3005,7 +3003,7 @@ srv_master_do_idle_tasks(void)
/* ALTER TABLE in MySQL requires on Unix that the table handler
can drop tables lazily after there no longer are SELECT
queries to them. */
- counter_time = ut_time_us(NULL);
+ ulonglong counter_time = microsecond_interval_timer();
srv_main_thread_op_info = "doing background drop tables";
row_drop_tables_for_mysql_in_background();
MONITOR_INC_TIME_IN_MICRO_SECS(
@@ -3022,7 +3020,7 @@ srv_master_do_idle_tasks(void)
log_free_check();
/* Do an ibuf merge */
- counter_time = ut_time_us(NULL);
+ counter_time = microsecond_interval_timer();
srv_main_thread_op_info = "doing insert buffer merge";
ibuf_merge_in_background(true);
MONITOR_INC_TIME_IN_MICRO_SECS(
diff --git a/storage/xtradb/trx/trx0i_s.cc b/storage/xtradb/trx/trx0i_s.cc
index fc6a1a1919a..16b91a6b2a8 100644
--- a/storage/xtradb/trx/trx0i_s.cc
+++ b/storage/xtradb/trx/trx0i_s.cc
@@ -1,6 +1,7 @@
/*****************************************************************************
Copyright (c) 2007, 2012, Oracle and/or its affiliates. All Rights Reserved.
+Copyright (c) 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -152,9 +153,8 @@ struct i_s_table_cache_t {
struct trx_i_s_cache_t {
rw_lock_t rw_lock; /*!< read-write lock protecting
the rest of this structure */
- ullint last_read; /*!< last time the cache was read;
- measured in microseconds since
- epoch */
+ ulonglong last_read; /*!< last time the cache was read;
+ measured in nanoseconds */
ib_mutex_t last_read_mutex;/*!< mutex protecting the
last_read member - it is updated
inside a shared lock of the
@@ -479,7 +479,7 @@ fill_trx_row(
ut_ad(lock_mutex_own());
row->trx_id = trx->id;
- row->trx_started = (ib_time_t) trx->start_time;
+ row->trx_started = trx->start_time;
row->trx_state = trx_get_que_state_str(trx);
row->requested_lock_row = requested_lock_row;
ut_ad(requested_lock_row == NULL
@@ -488,7 +488,7 @@ fill_trx_row(
if (trx->lock.wait_lock != NULL) {
ut_a(requested_lock_row != NULL);
- row->trx_wait_started = (ib_time_t) trx->lock.wait_started;
+ row->trx_wait_started = trx->lock.wait_started;
} else {
ut_a(requested_lock_row == NULL);
row->trx_wait_started = 0;
@@ -1221,22 +1221,16 @@ add_trx_relevant_locks_to_cache(
}
/** The minimum time that a cache must not be updated after it has been
-read for the last time; measured in microseconds. We use this technique
+read for the last time; measured in nanoseconds. We use this technique
to ensure that SELECTs which join several INFORMATION SCHEMA tables read
the same version of the cache. */
-#define CACHE_MIN_IDLE_TIME_US 100000 /* 0.1 sec */
+#define CACHE_MIN_IDLE_TIME_NS 100000000 /* 0.1 sec */
/*******************************************************************//**
Checks if the cache can safely be updated.
-@return TRUE if can be updated */
-static
-ibool
-can_cache_be_updated(
-/*=================*/
- trx_i_s_cache_t* cache) /*!< in: cache */
+@return whether the cache can be updated */
+static bool can_cache_be_updated(trx_i_s_cache_t* cache)
{
- ullint now;
-
/* Here we read cache->last_read without acquiring its mutex
because last_read is only updated when a shared rw lock on the
whole cache is being held (see trx_i_s_cache_end_read()) and
@@ -1247,14 +1241,7 @@ can_cache_be_updated(
#ifdef UNIV_SYNC_DEBUG
ut_a(rw_lock_own(&cache->rw_lock, RW_LOCK_EX));
#endif
-
- now = ut_time_us(NULL);
- if (now - cache->last_read > CACHE_MIN_IDLE_TIME_US) {
-
- return(TRUE);
- }
-
- return(FALSE);
+ return my_interval_timer() - cache->last_read > CACHE_MIN_IDLE_TIME_NS;
}
/*******************************************************************//**
@@ -1497,14 +1484,12 @@ trx_i_s_cache_end_read(
/*===================*/
trx_i_s_cache_t* cache) /*!< in: cache */
{
- ullint now;
-
#ifdef UNIV_SYNC_DEBUG
ut_a(rw_lock_own(&cache->rw_lock, RW_LOCK_SHARED));
#endif
/* update cache last read time */
- now = ut_time_us(NULL);
+ const ulonglong now = my_interval_timer();
mutex_enter(&cache->last_read_mutex);
cache->last_read = now;
mutex_exit(&cache->last_read_mutex);
diff --git a/storage/xtradb/ut/ut0ut.cc b/storage/xtradb/ut/ut0ut.cc
index 2aca4d4a3e0..0cdc618a8c4 100644
--- a/storage/xtradb/ut/ut0ut.cc
+++ b/storage/xtradb/ut/ut0ut.cc
@@ -180,26 +180,6 @@ ut_usectime(
}
/**********************************************************//**
-Returns the number of microseconds since epoch. Similar to
-time(3), the return value is also stored in *tloc, provided
-that tloc is non-NULL.
-@return us since epoch */
-UNIV_INTERN
-ullint
-ut_time_us(
-/*=======*/
- ullint* tloc) /*!< out: us since epoch, if non-NULL */
-{
- ullint us = my_interval_timer() / 1000;
-
- if (tloc != NULL) {
- *tloc = us;
- }
-
- return(us);
-}
-
-/**********************************************************//**
Returns the number of milliseconds since some epoch. The
value may wrap around. It should only be used for heuristic
purposes.