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

kvserver: do lazy map allocations in replicaFlowControl #113150

Merged
merged 1 commit into from
Oct 27, 2023

Conversation

sumeerbhola
Copy link
Collaborator

These methods will typically return empty maps, so we can avoid the allocations.

Informs #111561

Epic: none

Release note: None

@sumeerbhola sumeerbhola requested a review from a team as a code owner October 26, 2023 15:18
@blathers-crl
Copy link

blathers-crl bot commented Oct 26, 2023

It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR?

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@sumeerbhola sumeerbhola added the backport-23.2.x Flags PRs that need to be backported to 23.2. label Oct 26, 2023
Copy link
Collaborator

@pav-kv pav-kv left a comment

Choose a reason for hiding this comment

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

Nice simple fix, thanks.

Could also store the maps in replicaFlowControl, and reuse them across the runs. Or, to avoid the sticky overhead, draw them from a sync.Pool and release after use. These strategies are less simple and possibly unnecessary. Feel free to leave a TODO though.

pkg/kv/kvserver/flow_control_replica.go Show resolved Hide resolved
These methods will typically return empty maps, so we can avoid the
allocations.

Informs cockroachdb#111561

Epic: none

Release note: None
Copy link
Collaborator Author

@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.

TFTR!

Could also store the maps in replicaFlowControl, and reuse them across the runs. Or, to avoid the sticky overhead, draw them from a sync.Pool and release after use. These strategies are less simple and possibly unnecessary. Feel free to leave a TODO though.

I've left a comment in replicaFlowControlIntegrationImpl.notActivelyReplicatingTo for one of these possible optimizations. I didn't frame it as a TODO since I suspect we may never need to do it.

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


pkg/kv/kvserver/flow_control_replica.go line 63 at r1 (raw file):

Previously, pavelkalinnikov (Pavel Kalinnikov) wrote…

Could do with a comment why initialization is lazy here. Same below.

Done

@sumeerbhola
Copy link
Collaborator Author

test failure is unrelated #113112

Copy link
Collaborator

@aadityasondhi aadityasondhi left a comment

Choose a reason for hiding this comment

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

thanks for the quick fix!

:lgtm:

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

@sumeerbhola
Copy link
Collaborator Author

bors r=pavelkalinnikov,aadityasondhi

@craig
Copy link
Contributor

craig bot commented Oct 27, 2023

Build succeeded:

@craig craig bot merged commit 2979ac2 into cockroachdb:master Oct 27, 2023
6 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-23.2.x Flags PRs that need to be backported to 23.2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants