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

base: increase RaftTickInterval from 200 ms to 500 ms #98584

Merged
merged 2 commits into from
Mar 16, 2023

Conversation

erikgrinaker
Copy link
Contributor

@erikgrinaker erikgrinaker commented Mar 14, 2023

base: don't express RaftDelaySplitToSuppressSnapshot in ticks

Expressing this parameter in Raft ticks was just confusing, and changing the Raft tick interval will inadvertently change this value. It had no functional dependence on Raft ticks.

The wall-time value remains roughly the same.

Epic: none
Release note: None

base: increase RaftTickInterval from 200 ms to 500 ms

Tick costs for unquiesced ranges can use a large amount of CPU on nodes with many replicas. Increasing the tick interval from 200 ms to 500 ms reduces this CPU cost by 60%. On a 3-node cluster with 50.000 unquiesced ranges, this reduced the total CPU usage when idle from 54% to 32%.

All derived intervals and timeouts have been adjusted such that they remain the same in wall time.

This increases the latency (from 200 to 500 ms) for tick-driven actions:

  • Transfers of Raft leadership to leaseholders.
  • Follower overload pausing.
  • Updating the node liveness map.
  • Updating the IO thresholds map.

Furthermore, because it reduces the resolution of the randomized Raft election timeout interval from [10-20) ticks to [4-8) ticks, it increases the chance of collisions and thus the chance of unsuccessful elections.

Environment variables have been added to adjust this and any tick-dependant values at runtime in case problems arise.

Epic: none
Release note (performance improvement): The Raft tick interval has been increased from 200 ms to 500 ms in order to reduce per-replica CPU costs, and can now be adjusted via COCKROACH_RAFT_TICK_INTERVAL. Dependant parameters such as the Raft election timeout (COCKROACH_RAFT_ELECTION_TIMEOUT_TICKS), reproposal timeout (COCKROACH_RAFT_REPROPOSAL_TIMEOUT_TICKS), and heartbeat interval (COCKROACH_RAFT_HEARTBEAT_INTERVAL_TICKS) have been adjusted such that their wall-time value remains the same.

@erikgrinaker erikgrinaker requested a review from a team as a code owner March 14, 2023 15:14
@erikgrinaker erikgrinaker self-assigned this Mar 14, 2023
@erikgrinaker erikgrinaker requested a review from a team as a code owner March 14, 2023 15:14
@erikgrinaker erikgrinaker requested a review from a team March 14, 2023 15:14
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@erikgrinaker
Copy link
Contributor Author

I haven't done any testing here beyond benchmarking, will see how the nightlies fare.

@erikgrinaker erikgrinaker changed the title base: increase RaftTickInteval from 200 ms to 500 ms base: increase RaftTickInterval from 200 ms to 500 ms Mar 14, 2023
pkg/kv/kvserver/client_raft_test.go Outdated Show resolved Hide resolved
pkg/kv/kvserver/client_split_test.go Show resolved Hide resolved
Expressing this parameter in Raft ticks was just confusing, and changing
the Raft tick interval will inadvertently change this value. It had no
functional dependence on Raft ticks.

The wall-time value remains roughly the same.

Epic: none
Release note: None
Tick costs for unquiesced ranges can use a large amount of CPU on nodes
with many replicas. Increasing the tick interval from 200 ms to 500 ms
reduces this CPU cost by 60%. On a 3-node cluster with 50.000 unquiesced
ranges, this reduced the total CPU usage when idle from 54% to 32%.

All derived intervals and timeouts have been adjusted such that they
remain the same in wall time.

This increases the latency (from 200 to 500 ms) for tick-driven actions:

* Transfers of Raft leadership to leaseholders.
* Follower overload pausing.
* Updating the node liveness map.
* Updating the IO thresholds map.

Furthermore, because it reduces the resolution of the randomized Raft
election timeout interval from [10-20) ticks to [4-8) ticks, it
increases the chance of collisions and thus the chance of unsuccessful
elections.

Environment variables have been added to adjust this and any
tick-dependant values at runtime in case problems arise.

Epic: none
Release note (performance improvement): The Raft tick interval has been
increased from 200 ms to 500 ms in order to reduce per-replica CPU
costs, and can now be adjusted via `COCKROACH_RAFT_TICK_INTERVAL`.
Dependant parameters such as the Raft election timeout
(`COCKROACH_RAFT_ELECTION_TIMEOUT_TICKS`), reproposal timeout
(`COCKROACH_RAFT_REPROPOSAL_TIMEOUT_TICKS`), and heartbeat interval
(`COCKROACH_RAFT_HEARTBEAT_INTERVAL_TICKS`) have been adjusted such that
their wall-time value remains the same.
@erikgrinaker
Copy link
Contributor Author

bors r+

@craig
Copy link
Contributor

craig bot commented Mar 16, 2023

Build succeeded:

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