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

db: remove compaction/flush pacing #1812

Merged
merged 2 commits into from
Jul 15, 2022

Conversation

jbowens
Copy link
Collaborator

@jbowens jbowens commented Jul 14, 2022

@nvanbenschoten uncovered unnecessary compaction-loop contention over in #1808. Since the flush/compaction pacing code has been disabled for 2+ years, I think it's time to rip it out altogether so we're not maintaining dead code.


db: remove compaction.atomicBytesIterated

The atomic bytes-iterated value was used for compaction and flush pacing.
Remove it for now to resolve #1808.

Fix #1808.

db: remove compaction/flush pacing

Compaction and flush pacing have been disabled for several years. Remove the
code to avoid maintaining dead code. If/when we attempt to re-enable pacing, we
can revert this commit.

Informs #687.

The atomic bytes-iterated value was used for compaction and flush pacing.
Remove it for now to resolve cockroachdb#1808.

Fix cockroachdb#1808.
@@ -1654,15 +1607,12 @@ func (d *DB) flush1() (bytesFlushed uint64, err error) {
}
}

bytesFlushed = c.bytesIterated
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@sumeerbhola Is the InternalIntervalMetrics.Flush.WriteThroughput indeed intended to measure the bytes iterated over in the flushables instead of the bytes written to disk? I had assumed the bytesFlushed return value was the latter and was surprised by this.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@jbowens jbowens force-pushed the rm-bytes-iterated branch from 5a630b0 to a8b14c1 Compare July 14, 2022 22:52
Copy link
Contributor

@nicktrav nicktrav left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 7 of 7 files at r1, 11 of 11 files at r2, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @jbowens and @nicktrav)


options.go line 1154 at r3 (raw file):

			case "mem_table_stop_writes_threshold":
				o.MemTableStopWritesThreshold, err = strconv.Atoi(value)
			case "min_compaction_rate":

My understanding is that one can set these manually as options for a Cockroach store. If someone was passing them in, even if they were doing nothing before, do we continue to support them, vs. returning an error (either here, or in the default arm)? Wary of the "may be meaningful again" implying cruft we carry around.

No strong feeling either way.


pacer.go line 29 at r3 (raw file):

}

// compactionInternalPacer contains fields and methods common to compactionPacer

Noice. 📉

Copy link
Collaborator Author

@jbowens jbowens 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: all files reviewed, 2 unresolved discussions (waiting on @nicktrav)


options.go line 1154 at r3 (raw file):

Previously, nicktrav (Nick Travers) wrote…

My understanding is that one can set these manually as options for a Cockroach store. If someone was passing them in, even if they were doing nothing before, do we continue to support them, vs. returning an error (either here, or in the default arm)? Wary of the "may be meaningful again" implying cruft we carry around.

No strong feeling either way.

These options had defaults, so they should appear in all Cockroach stores' OPTIONS files. We need to keep them within this switch statement, because Pebble will error when it observes unrecognized options.

pebble/options.go

Lines 1080 to 1083 in d3484a6

// WARNING: DO NOT remove entries from the switches below because doing so
// causes a key previously written to the OPTIONS file to be considered unknown,
// a backwards incompatible change. Instead, leave in support for parsing the
// key but simply don't parse the value.

@jbowens jbowens requested review from nvanbenschoten and a team July 15, 2022 01:57
Compaction and flush pacing have been disabled for several years. Remove the
code to avoid maintaining dead code. If or when we attempt to re-enable pacing,
we can revert this commit.

Informs cockroachdb#687.
@jbowens jbowens force-pushed the rm-bytes-iterated branch from a8b14c1 to 9219c1a Compare July 15, 2022 01:59
Copy link
Contributor

@nicktrav nicktrav left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 1 files at r4, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @nvanbenschoten)


options.go line 1154 at r3 (raw file):

Previously, jbowens (Jackson Owens) wrote…

These options had defaults, so they should appear in all Cockroach stores' OPTIONS files. We need to keep them within this switch statement, because Pebble will error when it observes unrecognized options.

pebble/options.go

Lines 1080 to 1083 in d3484a6

// WARNING: DO NOT remove entries from the switches below because doing so
// causes a key previously written to the OPTIONS file to be considered unknown,
// a backwards incompatible change. Instead, leave in support for parsing the
// key but simply don't parse the value.

Ah nice. Thanks.

Copy link
Collaborator Author

@jbowens jbowens left a comment

Choose a reason for hiding this comment

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

TFTR!

Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @nvanbenschoten)

@jbowens jbowens merged commit 9f3691a into cockroachdb:master Jul 15, 2022
@jbowens jbowens deleted the rm-bytes-iterated branch July 15, 2022 22:03
Copy link
Collaborator

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

Very glad to see this cleanup.

Reviewable status: all files reviewed, 1 unresolved discussion


compaction.go line 1610 at r2 (raw file):

Previously, jbowens (Jackson Owens) wrote…

@sumeerbhola Is the InternalIntervalMetrics.Flush.WriteThroughput indeed intended to measure the bytes iterated over in the flushables instead of the bytes written to disk? I had assumed the bytesFlushed return value was the latter and was surprised by this.

It is slightly messy either way.

With bytes written to disk, the byte tokens computed based on compactions out of L0 and flushes into L0 are comparable.
But when we look at the size of a pebble batch as a basis for estimating how many tokens, that is uncompressed (this doesn't matter currently since everything is estimated based on the compressed bytes). Also, it is possible for many of the memtable bytes to get deleted (due to raft log truncations).

I think the former is probably better, as you are indicating.

Copy link
Collaborator Author

@jbowens jbowens 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: all files reviewed, 1 unresolved discussion


compaction.go line 1610 at r2 (raw file):

Previously, sumeerbhola wrote…

It is slightly messy either way.

With bytes written to disk, the byte tokens computed based on compactions out of L0 and flushes into L0 are comparable.
But when we look at the size of a pebble batch as a basis for estimating how many tokens, that is uncompressed (this doesn't matter currently since everything is estimated based on the compressed bytes). Also, it is possible for many of the memtable bytes to get deleted (due to raft log truncations).

I think the former is probably better, as you are indicating.

That makes sense.

I was asking partially because if we switch it to use the bytes written to disk, I think we'd remove the last use of the bytes-iterated calculation. We could remove some more code and clean up some internal interfaces.

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.

compaction: contended per-key atomic store limits scalability of concurrent compactions
4 participants