revision-id: 7a8c777d4880cde8fd96135f6cc216223371a9f4 (v5.8-1023-g7a8c777d4) parent(s): c0a1babb157b83b1eb41820fd7652e23b81f8c48 author: Sergei Petrunia committer: Sergei Petrunia timestamp: 2019-03-10 20:06:03 +0300 message: Add comments about use of toku_time.h - Which functions are needed - Can we use RocksDB's portability layer instead (yes) --- .../range_locking/portability/toku_time.h | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/utilities/transactions/range_locking/portability/toku_time.h b/utilities/transactions/range_locking/portability/toku_time.h index de0b0c354..dc8e366e5 100644 --- a/utilities/transactions/range_locking/portability/toku_time.h +++ b/utilities/transactions/range_locking/portability/toku_time.h @@ -47,6 +47,7 @@ Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved. # include <sys/platform/ppc.h> #endif +#if 0 static inline float toku_tdiff (struct timeval *a, struct timeval *b) { return (float)((a->tv_sec - b->tv_sec) + 1e-6 * (a->tv_usec - b->tv_usec)); } @@ -61,6 +62,7 @@ typedef int clockid_t; #define CLOCK_REALTIME 0x01867234 #endif int toku_clock_gettime(clockid_t clk_id, struct timespec *ts) __attribute__((__visibility__("default"))); +#endif // *************** Performance timers ************************ // What do you really want from a performance timer: @@ -83,6 +85,7 @@ int toku_clock_gettime(clockid_t clk_id, struct timespec *ts) __attribute__((__v // The decision here is that these times are really accurate only on modern machines with modern OSs. typedef uint64_t tokutime_t; // Time type used in by tokutek timers. +#if 0 // The value of tokutime_t is not specified here. // It might be microseconds since 1/1/1970 (if gettimeofday() is // used), or clock cycles since boot (if rdtsc is used). Or something @@ -100,6 +103,8 @@ typedef uint64_t tokutime_t; // Time type used in by tokutek timers. // double tokutime_to_seconds(tokutime_t) __attribute__((__visibility__("default"))); // Convert tokutime to seconds. +#endif + // Get the value of tokutime for right now. We want this to be fast, so we expose the implementation as RDTSC. static inline tokutime_t toku_time_now(void) { #if defined(__x86_64__) || defined(__i386__) @@ -123,6 +128,7 @@ static inline uint64_t toku_current_time_microsec(void) { return t.tv_sec * (1UL * 1000 * 1000) + t.tv_usec; } +#if 0 // sleep microseconds static inline void toku_sleep_microsec(uint64_t ms) { struct timeval t; @@ -132,3 +138,20 @@ static inline void toku_sleep_microsec(uint64_t ms) { select(0, NULL, NULL, NULL, &t); } +#endif + +/* + PORT: Usage of this file: + + uint64_t toku_current_time_microsec() // uses gettimeoday + is used to track how much time various operations took (for example, lock + escalation). (TODO: it is not clear why these operations are tracked with + microsecond precision while others use nanoseconds) + + tokutime_t toku_time_now() // uses rdtsc + seems to be used for a very similar purpose. This has greater precision + + RocksDB environment provides Env::Default()->NowMicros() and NowNanos() which + should be adequate substitutes. +*/ +