Skip to content

Unnecessary call to ustime #2143

Description

@nadav-levanoni

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions