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

raft: fix Ready.MustSync logic #10106

Merged
merged 1 commit into from
Sep 19, 2018

Conversation

petermattis
Copy link
Contributor

The previous logic was erroneously setting Ready.MustSync to true when
the hard state had not changed because we were comparing an empty hard
state to the previous hard state. In combination with another misfeature
in CockroachDB (unnecessary writing of empty batches), this was causing
a steady stream of synchronous writes to disk.

@xiang90
Copy link
Contributor

xiang90 commented Sep 19, 2018

lgtm.

The commit title needs to be changed to "raft: fix ..."

benesch added a commit to benesch/cockroach that referenced this pull request Sep 19, 2018
Committing an empty batch previously wrote an empty entry to the RocksDB
WAL file. Coupled with a bug in Raft (etcd-io/etcd#10106), this was
causing unnecessary synchronous writes to disk during Raft heartbeats.

A non-rigorous benchmark shows that this yields a nearly 10% performance
improvement on a three node cluster under a write-heavy workload (kv5%).

Release note: None
@petermattis petermattis changed the title Fix Ready.MustSync logic raft: fix Ready.MustSync logic Sep 19, 2018
@petermattis
Copy link
Contributor Author

The commit title needs to be changed to "raft: fix ..."

Done. Thanks for the quick review.

benesch added a commit to benesch/cockroach that referenced this pull request Sep 19, 2018
Committing an empty batch previously wrote an empty entry to the RocksDB
WAL file. Coupled with a bug in Raft (etcd-io/etcd#10106), this was
causing unnecessary synchronous writes to disk during Raft heartbeats.

A non-rigorous benchmark shows that this yields a nearly 10% performance
improvement on a three node cluster under a write-heavy workload (kv5%).

Release note: None
craig bot pushed a commit to cockroachdb/cockroach that referenced this pull request Sep 19, 2018
30398: engine: avoid committing empty batches r=nvanbenschoten,petermattis,bdarnell a=benesch

Committing an empty batch previously wrote an empty entry to the RocksDB
WAL file. Coupled with a bug in Raft (etcd-io/etcd#10106), this was
causing unnecessary synchronous writes to disk during Raft heartbeats.

A non-rigorous benchmark shows that this yields a nearly 10% performance
improvement on a three node cluster under a write-heavy workload (kv5%).

^ @nvanbenschoten can this be right??? I don't trust my numbers, but I don't have time to run another benchmark tonight.

Note that the explosion of C++ is just to get at the RocksDB WAL's file size in a unit test. It's not a code path exercised anywhere but tests.

Release note: None

Co-authored-by: Nikhil Benesch <nikhil.benesch@gmail.com>
@xiang90
Copy link
Contributor

xiang90 commented Sep 19, 2018

@petermattis

CI failed with raft/rawnode_test.go:60: declaration of "rd" shadows declaration at raft/rawnode_test.go:56

The previous logic was erroneously setting Ready.MustSync to true when
the hard state had not changed because we were comparing an empty hard
state to the previous hard state. In combination with another misfeature
in CockroachDB (unnecessary writing of empty batches), this was causing
a steady stream of synchronous writes to disk.
@petermattis
Copy link
Contributor Author

Fixed the shadow warning.

@xiang90 xiang90 merged commit b9b75f8 into etcd-io:master Sep 19, 2018
@petermattis petermattis deleted the pmattis/ready-must-sync branch September 19, 2018 23:45
petermattis added a commit to cockroachdb/vendored that referenced this pull request Sep 19, 2018
petermattis added a commit to cockroachdb/vendored that referenced this pull request Sep 19, 2018
petermattis added a commit to cockroachdb/vendored that referenced this pull request Sep 20, 2018
petermattis added a commit to petermattis/cockroach that referenced this pull request Sep 20, 2018
This picks up etcd-io/etcd#10106 which fixes an issue where
`raft.Ready.MustSync` was being set too frequently resulting in
unnecessary synchronous writes to the RocksDB WAL.

Release note (performance improvement): Remove unnecessary synchronous
disk writes caused by erroneous logic in the Raft implementation.
craig bot pushed a commit to cockroachdb/cockroach that referenced this pull request Sep 20, 2018
30443: vendor: bump go.etcd.io/etcd r=nvanbenschoten,benesch a=petermattis

This picks up etcd-io/etcd#10106 which fixes an issue where
`raft.Ready.MustSync` was being set too frequently resulting in
unnecessary synchronous writes to the RocksDB WAL.

Release note (performance improvement): Remove unnecessary synchronous
disk writes caused by erroneous logic in the Raft implementation.

Co-authored-by: Peter Mattis <petermattis@gmail.com>
petermattis added a commit to petermattis/cockroach that referenced this pull request Sep 20, 2018
This picks up etcd-io/etcd#10106 which fixes an issue where
`raft.Ready.MustSync` was being set too frequently resulting in
unnecessary synchronous writes to the RocksDB WAL.

Release note (performance improvement): Remove unnecessary synchronous
disk writes caused by erroneous logic in the Raft implementation.
petermattis added a commit to cockroachdb/vendored that referenced this pull request Sep 20, 2018
benesch added a commit to benesch/cockroach that referenced this pull request Sep 24, 2018
Committing an empty batch previously wrote an empty entry to the RocksDB
WAL file. Coupled with a bug in Raft (etcd-io/etcd#10106), this was
causing unnecessary synchronous writes to disk during Raft heartbeats.

A non-rigorous benchmark shows that this yields a nearly 10% performance
improvement on a three node cluster under a write-heavy workload (kv5%).

Release note: None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants