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

grunning: add grunning.Elapsed() #95536

Merged
merged 1 commit into from
Jan 19, 2023

Conversation

irfansharif
Copy link
Contributor

Elapsed returns the running time spent doing some piece of work, with grunning.Time() measurements from the start and end. This only exists due to grunning.Time()'s non-monotonicity, a bug in our runtime patch: #95529. We can get rid of this, keeping just grunning.Difference(), if that bug is fixed. The bug results in slight {over,under}-estimation of the running time (the latter breaking monotonicity), but is livable with our current uses of this library.

Release note: None

Elapsed returns the running time spent doing some piece of work, with
grunning.Time() measurements from the start and end.

NB: This only exists due to grunning.Time()'s non-monotonicity, a bug in
our runtime patch: cockroachdb#95529. We can get rid of this, keeping just
grunning.Difference(), if that bug is fixed. The bug results in slight
{over,under}-estimation of the running time (the latter breaking
monotonicity), but is livable with our current uses of this library.

Release note: None
@irfansharif irfansharif requested review from a team as code owners January 19, 2023 19:26
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Collaborator

@kvoli kvoli left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 4 of 4 files at r1, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @sumeerbhola)

Copy link
Collaborator

@sumeerbhola sumeerbhola left a comment

Choose a reason for hiding this comment

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

Reviewed 3 of 4 files at r1.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @irfansharif)


pkg/util/admission/elastic_cpu_work_handle.go line 63 at r1 (raw file):

		return override()
	}
	return grunning.Difference(grunning.Time(), h.cpuStart)

was this ordering change a bug in the old code?


pkg/util/grunning/grunning.go line 38 at r1 (raw file):

//
// NB: This only exists due to grunning.Time()'s non-monotonicity, a bug in our
// runtime patch: https://github.com/cockroachdb/cockroach/issues/95529. We can

Can we not fix the patch and backport it, instead of working around it?

Copy link
Collaborator

@kvoli kvoli left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @irfansharif and @sumeerbhola)


pkg/util/admission/elastic_cpu_work_handle.go line 63 at r1 (raw file):

Previously, sumeerbhola wrote…

was this ordering change a bug in the old code?

I also thought so but Difference takes the abs so the order didn't matter previously.

Copy link
Contributor Author

@irfansharif irfansharif left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @sumeerbhola)


pkg/util/admission/elastic_cpu_work_handle.go line 63 at r1 (raw file):

Previously, kvoli (Austen) wrote…

I also thought so but Difference takes the abs so the order didn't matter previously.

It's no changing the order, it's changing it from .Difference() to .Elapsed(). The latter takes in the start time as the first parameter. Using .Difference() doesn't make sense now that we know of the non-monotonicity, since it'll give you a value for how far back grunning.Time() jumped. Instead of 0-ing it out since it was non-monotonic.


pkg/util/grunning/grunning.go line 38 at r1 (raw file):

Previously, sumeerbhola wrote…

Can we not fix the patch and backport it, instead of working around it?

We can, but the last time we patched the runtime I ran a slew of {micro,macro}benchmarks which took time. I don't think there's a need to backport these, the errors are minor and we're not relying on monotonicity. So it was a preference to work around it for now and make time for the go patch soon afterwards.

Copy link
Collaborator

@sumeerbhola sumeerbhola left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 1 of 4 files at r1, all commit messages.
Reviewable status: :shipit: complete! 2 of 0 LGTMs obtained (waiting on @irfansharif)

@irfansharif
Copy link
Contributor Author

bors r+

@craig
Copy link
Contributor

craig bot commented Jan 19, 2023

Build succeeded:

@craig craig bot merged commit ba572fc into cockroachdb:master Jan 19, 2023
@irfansharif irfansharif deleted the 230119.grunning-elapsed branch January 20, 2023 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants