Skip to content

storage: Eliminate use of hlc.Clock in replicaStats#30651

Closed
a-robinson wants to merge 1 commit intocockroachdb:masterfrom
a-robinson:physicalnow
Closed

storage: Eliminate use of hlc.Clock in replicaStats#30651
a-robinson wants to merge 1 commit intocockroachdb:masterfrom
a-robinson:physicalnow

Conversation

@a-robinson
Copy link
Copy Markdown
Contributor

Touches #30520. This was almost certainly the worst offender because it
was getting the hlc physical time in recordCount, which is called once
(or twice for writes) on every replica.Send call.

Release note: None

@a-robinson a-robinson requested review from a team and nvb September 25, 2018 20:52
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
Contributor

@nvb nvb left a comment

Choose a reason for hiding this comment

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

Reviewed 6 of 6 files at r1.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained


pkg/storage/store_pool_test.go, line 475 at r1 (raw file):

	}
	replica.mu.Unlock()
	rs := newReplicaStats(func() time.Time { return clock.PhysicalTime() }, nil)

Can these closures be replaced by method references?


pkg/storage/store_pool_test.go, line 586 at r1 (raw file):

	}
	replica.leaseholderStats = newReplicaStats(
		func() time.Time { return store.Clock().PhysicalTime() }, nil)

Same question.

Touches cockroachdb#30520. This was almost certainly the worst offender because it
was getting the hlc physical time in recordCount, which is called once
(or twice for writes) on every replica.Send call.

Release note: None
Copy link
Copy Markdown
Contributor Author

@a-robinson a-robinson 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


pkg/storage/store_pool_test.go, line 475 at r1 (raw file):

Previously, nvanbenschoten (Nathan VanBenschoten) wrote…

Can these closures be replaced by method references?

Of course, done. Although for this one I can actually replace the hlc entirely since it isn't being used by anything else.


pkg/storage/store_pool_test.go, line 586 at r1 (raw file):

Previously, nvanbenschoten (Nathan VanBenschoten) wrote…

Same question.

Done.

Copy link
Copy Markdown
Contributor

@nvb nvb left a comment

Choose a reason for hiding this comment

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

:lgtm_strong: thanks for fixing this so quickly!

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained


pkg/storage/store_rebalancer_test.go, line 102 at r2 (raw file):

		// rangeInfo code is ripped out of the allocator.
		repl.mu.state.Stats = &enginepb.MVCCStats{}
		repl.leaseholderStats = newReplicaStats(func() time.Time { return s.Clock().PhysicalTime() }, nil)

nit: two more cases for method references.

@nvb
Copy link
Copy Markdown
Contributor

nvb commented Sep 25, 2018

Actually, sorry about this but could you hold off on this for a second? I'm going to update #30520 with the outcome of a discussion I just had with @bdarnell.

@a-robinson a-robinson closed this Jan 11, 2019
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.

3 participants