Skip to content

Conversation

@stevendanna
Copy link
Collaborator

This changes util.EveryN to a generic function and then

  • modifies log.EveryN to allow use a crtime.Mono instead of a time.Time.
  • updates most callers that were easy to update to use util.EveryMono

We might consider removing the time.Time version of EveryN, but it is still useful in a couple of places.

Epic: none
Release note: None

This changes util.EveryN to a generic function and then

- modifies log.EveryN to allow use a crtime.Mono instead of a time.Time.
- updates most callers that were easy to update to use util.EveryMono

We might consider removing the time.Time version of EveryN, but it is still
useful in a couple of places.

Epic: none
Release note: None
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@stevendanna stevendanna marked this pull request as ready for review November 12, 2025 14:14
@stevendanna stevendanna requested review from a team as code owners November 12, 2025 14:14
@stevendanna stevendanna removed the request for review from rharding6373 November 12, 2025 14:32
Copy link
Member

@yuzefovich yuzefovich left a comment

Choose a reason for hiding this comment

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

@yuzefovich reviewed 27 of 27 files at r1, all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @Abhinav1299, @arjunmahishi, @herkolategan, and @kev-cao)


pkg/util/every_n.go line 55 at r1 (raw file):

	var zero T
	e.Lock()
	if e.lastProcessed == zero || now.Sub(e.lastProcessed) >= e.N {

The change to always return true on the first call to ShouldProcess is a behavior change, and although it seems reasonable to me, it'd probably be worth extracting it into a separate commit with explanation for why.

Copy link
Member

@yuzefovich yuzefovich 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! 0 of 0 LGTMs obtained (waiting on @Abhinav1299, @arjunmahishi, @herkolategan, @kev-cao, and @stevendanna)


pkg/util/every_n.go line 55 at r1 (raw file):

Previously, yuzefovich (Yahor Yuzefovich) wrote…

The change to always return true on the first call to ShouldProcess is a behavior change, and although it seems reasonable to me, it'd probably be worth extracting it into a separate commit with explanation for why.

Or, actually, it's not a behavior change, right? nvm then

Copy link
Collaborator Author

@stevendanna stevendanna 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! 0 of 0 LGTMs obtained (waiting on @Abhinav1299, @arjunmahishi, @herkolategan, @kev-cao, and @yuzefovich)


pkg/util/every_n.go line 55 at r1 (raw file):

Previously, yuzefovich (Yahor Yuzefovich) wrote…

Or, actually, it's not a behavior change, right? nvm then

Right, shouldn't be a behaviour change, at least for all real callers. The code change is a result of the fact that when using a time.Time, now.Sub(e.lastProcessed) would be >= e.N since now was a relatively large value. When using a crtime.Mono, now represents the times since the crtime package's initialisation, which is a very small value.

@stevendanna
Copy link
Collaborator Author

TFRT!

bors r=yuzefovich

@craig
Copy link
Contributor

craig bot commented Nov 14, 2025

@craig craig bot merged commit a59328e into cockroachdb:master Nov 14, 2025
24 checks passed
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.

3 participants