Potential improvement in server.c
The logic here can be consolidated to run either ustime() or getMonotonicUs() when capturing our start time for measuring command execution duration. We already have split logic when measuring the end time, so it should be a pretty straightforward fix.
https://github.com/valkey-io/valkey/blob/unstable/src/server.c#L3714-L3743
We might be missing out on a downstream call to updateCachedTimeWithUs() if we only call getMonotonicUs(), but intuitively, calling ustime() solely for the purpose of caching the current time doesn't seem add value.
I didn't collect perf, but avoiding an unnecessary gettimeofday system call for each command executed could improve performance on the main thread.
Potential improvement in server.c
The logic here can be consolidated to run either
ustime()orgetMonotonicUs()when capturing our start time for measuring command execution duration. We already have split logic when measuring the end time, so it should be a pretty straightforward fix.https://github.com/valkey-io/valkey/blob/unstable/src/server.c#L3714-L3743
We might be missing out on a downstream call to
updateCachedTimeWithUs()if we only callgetMonotonicUs(), but intuitively, callingustime()solely for the purpose of caching the current time doesn't seem add value.I didn't collect perf, but avoiding an unnecessary
gettimeofdaysystem call for each command executed could improve performance on the main thread.