summaryrefslogtreecommitdiff
path: root/src/monotonic.c
diff options
context:
space:
mode:
authorfilipe oliveira <filipecosta.90@gmail.com>2022-04-20 12:00:30 +0100
committerGitHub <noreply@github.com>2022-04-20 14:00:30 +0300
commit3cd8baf61610416aab45e0bcedcaab9beae80184 (patch)
treed76e5c0c23f96c0f9939bdf2a833d5a26b334a51 /src/monotonic.c
parentee220599b0481cf4b10e8a5293691258fd6f35a6 (diff)
downloadredis-3cd8baf61610416aab45e0bcedcaab9beae80184.tar.gz
Optimization: Use either monotonic or wall-clock to measure command execution time, to regain up to 4% execution time (#10502)
In #7491 (part of redis 6.2), we started using the monotonic timer instead of mstime to measure command execution time for stats, apparently this meant sampling the clock 3 times per command rather than two (wince we also need the wall-clock time). In some cases this causes a significant overhead. This PR fixes that by avoiding the use of monotonic timer, except for the cases were we know it should be extremely fast. This PR also adds a new INFO field called `monotonic_clock` that shows which clock redis is using. Co-authored-by: Oran Agra <oran@redislabs.com>
Diffstat (limited to 'src/monotonic.c')
-rw-r--r--src/monotonic.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/monotonic.c b/src/monotonic.c
index 5bb4f03bf..608fa351c 100644
--- a/src/monotonic.c
+++ b/src/monotonic.c
@@ -168,3 +168,13 @@ const char * monotonicInit() {
return monotonic_info_string;
}
+
+const char *monotonicInfoString() {
+ return monotonic_info_string;
+}
+
+monotonic_clock_type monotonicGetType() {
+ if (getMonotonicUs == getMonotonicUs_posix)
+ return MONOTONIC_CLOCK_POSIX;
+ return MONOTONIC_CLOCK_HW;
+}