Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vreplication: fix vreplication timing metrics #8024

Merged
merged 1 commit into from
May 3, 2021

Conversation

dyv
Copy link
Contributor

@dyv dyv commented May 3, 2021

Description

  • Bug Fix

Several of the vreplication metrics were recently updated to no longer be
correct. Specifically time.Now() is no longer executed when the function
starts and is instead executed when the defer statement is called after the end
of the function.

This updates the metrics to properly execute time.Now() at the start
of the functions.

@dyv dyv requested a review from rohit-nayak-ps as a code owner May 3, 2021 14:08
Several of the vreplication metrics were recently updated to no longer be
correct. Specifically time.Now() is no longer executed when the function
starts and is instead executed when the defer statement is called after the end
of the function.

This updates the metrics to properly execute time.Now() at the start
of the functions.

Signed-off-by: Dylan Visher <dvisher@figma.com>
@dyv dyv force-pushed the dvisher/vreplication-metrics branch from 25a52f5 to d93ee91 Compare May 3, 2021 14:09
Copy link
Contributor

@shlomi-noach shlomi-noach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Just to explain it a bit in golang terms:

in

defer func() {
  vc.vr.stats.PhaseTimings.Record("catchup", time.Now())
}()

the value of time.Now() is evaluated when the code inside the defer function runs, which is at the end of the catchup function.

In:

defer vc.vr.stats.PhaseTimings.Record("catchup", time.Now())

the value of time.Now() is evaluated immediately, and cached until the deferred function is actually invoked.

Copy link
Contributor

@rohit-nayak-ps rohit-nayak-ps left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants