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

workload/tpcc: support replicated indexes and lease partitioning #36855

Merged
merged 3 commits into from
May 20, 2019

Conversation

nvanbenschoten
Copy link
Member

@nvanbenschoten nvanbenschoten commented Apr 15, 2019

This PR adds support for a new geo-replicated configuration of TPC-C. Instead of partitioning replication, the PR allows us to partition leases while maintaining cross-region replication. It exposes this through a new --partition-strategy option, which can be set to replication or leases. The former is the only strategy we supported before and constrains replication for a given partition to within a single zone. The latter is new and collocates read leases for a given partition to within a single zone.

In order to get optimal performance out of this configuration, the PR also switches to a "replicated index" configuration for the item table. This table is the only part of TPC-C that cannot be segmented on warehouse boundaries. Luckily, it is read-only, so replicated indexes are a perfect fit to reduce cross-zone communication.

cc. @robert-s-lee I think this is a better configuration for testing geo-replicated TPC-C than the one we had before. Once this is merged I think it will make a great demo.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@nvanbenschoten nvanbenschoten force-pushed the nvanbenschoten/geoTpcc3 branch 2 times, most recently from 3ebed10 to 1c9b8dd Compare April 16, 2019 14:50
Copy link
Contributor

@ajwerner ajwerner left a comment

Choose a reason for hiding this comment

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

Neat. I did not do any meaningful inspection of the testdata files in opt. The workload code lgtm

Reviewed 6 of 6 files at r1, 4 of 4 files at r2, 1 of 1 files at r3, 6 of 6 files at r4, 3 of 3 files at r5, 1 of 1 files at r6, 2 of 2 files at r7, 1 of 1 files at r8, 2 of 2 files at r10.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @nvanbenschoten)


pkg/workload/tpcc/partition.go, line 264 at r7 (raw file):

	// The stock_item_fk_idx can't be partitioned because it doesn't have a
	// warehouse prefix. It's an all-around unfortunate index that we only
	// need because of a restriction in SQL.

Just out of curiousity, what's the restriction in SQL?

Copy link
Contributor

@andy-kimball andy-kimball left a comment

Choose a reason for hiding this comment

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

opt changes :lgtm:

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

craig bot pushed a commit that referenced this pull request May 20, 2019
36854: workload/tpcc: improve indexing to permit better partitioning r=nvanbenschoten a=nvanbenschoten

This PR contains a number of incremental improvements to TPC-C that allow it to be more effectively partitioned. The changes focus on migrating indexes to all be partitionable by warehouse and removing indexes that are only needed for foreign keys when fks are not enabled. This is all a precursor to a follow-up PR: #36855.

I'm assigning @jordanlewis and @danhhz as reviewers because between the two of you most of the changes here have already been agreed upon.

This PR will require me to regenerate all TPC-C fixtures. I intend to do so before it is merged.

Co-authored-by: Nathan VanBenschoten <[email protected]>
@nvanbenschoten nvanbenschoten force-pushed the nvanbenschoten/geoTpcc3 branch from 1c9b8dd to 93cdb43 Compare May 20, 2019 21:03
The table is immutable, so we can use a "replicated index" configuration
to ensure that all lookups into it are local and never cross zones.

Release note: None
This breaks compatibility with 2.0 nodes, but that's far enough back
that we don't care anymore.

Release note: None
This commit adds support for two different partitioning strategies:
replication partitioning and lease partitioning. The former is the
only strategy we supported before and constrains replication for a
given partition to within a single zone. The latter is new and
collocates read leases for a given partition to within a single
zone.

Release note: None
@nvanbenschoten nvanbenschoten force-pushed the nvanbenschoten/geoTpcc3 branch from 93cdb43 to ebb68aa Compare May 20, 2019 21:09
Copy link
Member Author

@nvanbenschoten nvanbenschoten left a comment

Choose a reason for hiding this comment

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

TFTRs!

bors r+

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


pkg/workload/tpcc/partition.go, line 264 at r7 (raw file):

Previously, ajwerner wrote…

Just out of curiousity, what's the restriction in SQL?

#36859/#37255. I added to the comment.

@nvanbenschoten
Copy link
Member Author

Bors didn't seem to pick this up. Let's try again.

bors r+

craig bot pushed a commit that referenced this pull request May 20, 2019
36855: workload/tpcc: support replicated indexes and lease partitioning r=nvanbenschoten a=nvanbenschoten

This PR adds support for a new geo-replicated configuration of TPC-C. Instead of partitioning replication, the PR allows us to partition leases while maintaining cross-region replication. It exposes this through a new `--partition-strategy` option, which can be set to `replication` or `leases`. The former is the only strategy we supported before and constrains replication for a given partition to within a single zone. The latter is new and collocates read leases for a given partition to within a single zone.

In order to get optimal performance out of this configuration, the PR also switches to a "replicated index" configuration for the `item` table. This table is the only part of TPC-C that cannot be segmented on warehouse boundaries. Luckily, it is read-only, so replicated indexes are a perfect fit to reduce cross-zone communication.

cc. @robert-s-lee I think this is a better configuration for testing geo-replicated TPC-C than the one we had before. Once this is merged I think it will make a great demo.

Co-authored-by: Nathan VanBenschoten <[email protected]>
@craig
Copy link
Contributor

craig bot commented May 20, 2019

Build succeeded

@craig craig bot merged commit ebb68aa into cockroachdb:master May 20, 2019
danhhz added a commit to danhhz/cockroach that referenced this pull request May 22, 2019
In cockroachdb#36855, we bumped the workload-version of tpcc from 2.0.1 to 2.1.0.
The IMPORT commands generated by `fixtures import` include the version
built in so that all the nodes processing the IMPORT (which internally
synthesize the data) can check against their internal version. This
prevents nodes from generating incompatible data, but an unfortunate
side effect of this is that the tpcc version in the workload binary must
match the one in the cockroach nodes.

This works for roachtests in master, but not for release branches, which
use a workload binary built from master. Instead, use the `cockroach
workload fixtures import` subcommand, which is guaranteed to match.

Release note: None
craig bot pushed a commit that referenced this pull request May 22, 2019
37719: kv: finish and enable parallel commits r=nvanbenschoten a=nvanbenschoten

The majority of this PR is addressing the final work item for parallel commits - splitting pre-commit QueryIntents from parallel committing EndTransaction requests.

If a batch is performing a parallel commit and the transaction has previously pipelined writes that have yet to be proven successful then the EndTransaction request will be preceded by a series of QueryIntent requests (see txn_pipeliner.go). Before evaluating, each of these QueryIntent requests will grab latches and wait for their corresponding write to finish. This is how the QueryIntent requests synchronize with the write they are trying to verify.

If these QueryIntents remained in the same batch as the EndTransaction request then they would force the EndTransaction request to wait for the previous write before evaluating itself. This "pipeline stall" would effectively negate the benefit of the parallel commit. To avoid this, we make sure that these "pre-commit" QueryIntent requests are split from and issued concurrently with the rest of the parallel commit batch.

With this complete, parallel commits is then able to be enabled.

### Benchmarks

One of my recent experiments was to run the `indexes` benchmark at varying numbers of secondary indexes on a 3-node geo-distributed cluster. Below are plots with and without parallel commits enabled. We can see that without parallel commits, the introduction of the first secondary index doubles p50 latency and reduces throughput (at a fixed concurrency) by 56%. With parallel commits, the introduction of the secondary index has almost no noticeable effect on p50 latency and reduces throughput by only 29%.

![Secondary Indexes Throughput With Parallel Commits (1)](https://user-images.githubusercontent.com/5438456/58153546-50aee800-7c3d-11e9-9845-ca5ddf9e0779.png)

![Secondary Indexes p50 Latency With Parallel Commits (1)](https://user-images.githubusercontent.com/5438456/58153550-5278ab80-7c3d-11e9-8b9f-bcc1d702e39f.png)

I expect I'll polish off more comparison benchmarks over the next few weeks to further demonstrate the effect of parallel commits.

37726: roachtest: fix `fixtures import` on release branches r=tbg,nvanbenschoten a=danhhz

In #36855, we bumped the workload-version of tpcc from 2.0.1 to 2.1.0.
The IMPORT commands generated by `fixtures import` include the version
built in so that all the nodes processing the IMPORT (which internally
synthesize the data) can check against their internal version. This
prevents nodes from generating incompatible data, but an unfortunate
side effect of this is that the tpcc version in the workload binary must
match the one in the cockroach nodes.

This works for roachtests in master, but not for release branches, which
use a workload binary built from master. Instead, use the `cockroach
workload fixtures import` subcommand, which is guaranteed to match.

Release note: None

Co-authored-by: Nathan VanBenschoten <[email protected]>
Co-authored-by: Daniel Harrison <[email protected]>
@nvanbenschoten nvanbenschoten deleted the nvanbenschoten/geoTpcc3 branch May 23, 2019 21:10
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.

4 participants