Skip to content

bench: add separate-process tenant benchmarks#95715

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
yuzefovich:separate-process-tenant
Jan 27, 2023
Merged

bench: add separate-process tenant benchmarks#95715
craig[bot] merged 1 commit intocockroachdb:masterfrom
yuzefovich:separate-process-tenant

Conversation

@yuzefovich
Copy link
Copy Markdown
Member

@yuzefovich yuzefovich commented Jan 24, 2023

Some time ago we merged a change to run all benchmarks in pkg/bench against an in-memory tenant. Recently we introduced a local fastpath for in-process in-memory tenants which will resemble how things will look once we get to UA for single-tenant clusters. However, it is also interesting to measure how we perform with separate-process tenants (which is how we run serverless), so this commit introduces that additional config.

Epic: CRDB-14837

Release note: None

@yuzefovich yuzefovich requested review from a team and knz January 24, 2023 03:24
@blathers-crl
Copy link
Copy Markdown

blathers-crl bot commented Jan 24, 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
Copy Markdown
Member

This change is Reviewable

@yuzefovich yuzefovich force-pushed the separate-process-tenant branch 2 times, most recently from d3e241d to badfb0f Compare January 24, 2023 04:27
Copy link
Copy Markdown
Member Author

@yuzefovich yuzefovich 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: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @knz)


pkg/bench/foreachdb.go line 101 at r1 (raw file):

	_, tenantDB := serverutils.StartTenant(b, s, base.TestTenantArgs{
		TenantName: "benchtenant",
		TenantID:   roachpb.MustMakeTenantID(10),

I initially used UseDatabase option with "cluster:"+tenantName+"/bench" value, but this made BenchmarkPgbench fail. Removing UseDatabase seems to work for all benchmarks.


pkg/bench/foreachdb.go line 105 at r1 (raw file):

	// The benchmarks sometime hit the default span limit, so we increase it.
	// NOTE(andrei): Benchmarks drop the tables they're creating, so I'm not sure

I haven't tried running the benchmarks without this, so I dunno whether it is still relevant.


pkg/bench/bench_test.go line 1195 at r1 (raw file):

	defer log.Scope(b).Close(b)
	ForEachDB(b, func(b *testing.B, db *sqlutils.SQLRunner) {
		db.Exec(b, `CREATE TABLE bench.abc (a INT PRIMARY KEY, b INT, c INT, INDEX(b), UNIQUE INDEX(c))`)

I don't understand why the in-memory tenant cockroach benchmarks didn't fail for the cases where bench. prefix was missing - perhaps it's due to explicitly specifying the DB name for OpenDBConn? If I did use similar value when starting a separate-process tenant via UseDatabase parameter, the benchmarks missing bench. prefix still failed 🤷‍♂️

@yuzefovich yuzefovich force-pushed the separate-process-tenant branch from badfb0f to 00a69e5 Compare January 26, 2023 18:27
@yuzefovich
Copy link
Copy Markdown
Member Author

@knz could you please take a look at this?

Copy link
Copy Markdown
Contributor

@knz knz left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 3 files at r1, 1 of 1 files at r2, all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @yuzefovich)


pkg/bench/bench_test.go line 1195 at r1 (raw file):

perhaps it's due to explicitly specifying the DB name for OpenDBConn?

yes that would be my understanding as well.

If I did use similar value when starting a separate-process tenant via UseDatabase parameter, the benchmarks missing bench. prefix still failed 🤷‍♂️

I'm not sure I understand the operation mode. How do you "start a separate-process tenant with a UseDatabase parameter"?


pkg/bench/bench_test.go line 1198 at r2 (raw file):

	defer log.Scope(b).Close(b)
	ForEachDB(b, func(b *testing.B, db *sqlutils.SQLRunner) {
		db.Exec(b, `CREATE TABLE bench.abc (a INT PRIMARY KEY, b INT, c INT, INDEX(b), UNIQUE INDEX(c))`)

I'm not sure introducing this bench. prefix everywhere is the right way to go. It makes the SQL longer and (slightly) harder to read and update.

If you can't insert the db name in the connection string, you can execute a USE or SET database statement at the beginning of the benchmark.

Some time ago we merged a change to run all benchmarks in `pkg/bench`
against an in-memory tenant. Recently we introduced a local fastpath for
in-process in-memory tenants which will resemble how things will look
once we get to UA for single-tenant clusters. However, it is also
interesting to measure how we perform with separate-process tenants
(which is how we run serverless), so this commit introduces that
additional config.

Release note: None
@yuzefovich yuzefovich force-pushed the separate-process-tenant branch from 00a69e5 to 01a70b0 Compare January 26, 2023 23:57
Copy link
Copy Markdown
Member Author

@yuzefovich yuzefovich 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: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @knz)


pkg/bench/bench_test.go line 1195 at r1 (raw file):

Previously, knz (Raphael 'kena' Poss) wrote…

perhaps it's due to explicitly specifying the DB name for OpenDBConn?

yes that would be my understanding as well.

If I did use similar value when starting a separate-process tenant via UseDatabase parameter, the benchmarks missing bench. prefix still failed 🤷‍♂️

I'm not sure I understand the operation mode. How do you "start a separate-process tenant with a UseDatabase parameter"?

I specified base.TestTenantArgs.UseDatabase argument, but only I included "cluster:"+tenantName+"/bench" in there. The correct way is to just use bench there which is what this commit does. This is probably the way to go. (But it shows that I'm a complete newbie with all of this :) )


pkg/bench/bench_test.go line 1198 at r2 (raw file):

Previously, knz (Raphael 'kena' Poss) wrote…

I'm not sure introducing this bench. prefix everywhere is the right way to go. It makes the SQL longer and (slightly) harder to read and update.

If you can't insert the db name in the connection string, you can execute a USE or SET database statement at the beginning of the benchmark.

Fixed.

Copy link
Copy Markdown
Contributor

@knz knz left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r3, all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @yuzefovich)


pkg/bench/bench_test.go line 1195 at r1 (raw file):

Previously, yuzefovich (Yahor Yuzefovich) wrote…

I specified base.TestTenantArgs.UseDatabase argument, but only I included "cluster:"+tenantName+"/bench" in there. The correct way is to just use bench there which is what this commit does. This is probably the way to go. (But it shows that I'm a complete newbie with all of this :) )

To be honest the idea that TestTenantArgs has a "UseDatabase" field is utterly confusing to me. The database is a property of the client connection, not of the tenant! And the way this particular field is plumbed through obscures that fact.

But yes what you did here is correct.

@yuzefovich
Copy link
Copy Markdown
Member Author

I'm plenty confused too since I had the same mental model that the DB should be specified on the connection, and not instantiating args to create a tenant.

TFTR!

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Jan 27, 2023

Build succeeded:

@craig craig bot merged commit 0b49fa7 into cockroachdb:master Jan 27, 2023
@yuzefovich yuzefovich deleted the separate-process-tenant branch January 27, 2023 17:46
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