Skip to content

row: set TargetBytes for kvfetcher#45323

Merged
craig[bot] merged 4 commits intocockroachdb:masterfrom
tbg:kvfetcher-limit-really
Feb 28, 2020
Merged

row: set TargetBytes for kvfetcher#45323
craig[bot] merged 4 commits intocockroachdb:masterfrom
tbg:kvfetcher-limit-really

Conversation

@tbg
Copy link
Copy Markdown
Member

@tbg tbg commented Feb 24, 2020

This finishes up the work in #44925 and completes the TargetBytes functionality. This is then used in kvfetcher, which henceforth aims to return no more than ~1mb per request. Additional commits restore the hotspotsplits roachtest and fix it. Reverting the relevant commit from this PR, the test failed nine out of ten times). With all commits, it passed ten times.

The one question I have whether TargetBytes should be set to a value higher than 1mb to avoid a performance regression (where should I look?).

Fixes #33660.

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@tbg tbg requested review from RaduBerinde and nvb February 24, 2020 15:28
@jordanlewis
Copy link
Copy Markdown
Member

I think the query type that's most sensitive to fiddling with the request batch sizes is something like COUNT on a large table. This minimizes CPU and maximizes data transfer.

@tbg
Copy link
Copy Markdown
Member Author

tbg commented Feb 24, 2020

SG. Can you give me a large table (tpcc.x?) that you find representative (enough), just so that I have something concrete to work with?

@jordanlewis
Copy link
Copy Markdown
Member

tpch.lineitem or maybe tpcc.order_line? something that takes seconds to return, I don't think it matters much.

@tbg
Copy link
Copy Markdown
Member Author

tbg commented Feb 26, 2020

tpch.lineitem or maybe tpcc.order_line? something that takes seconds to return, I don't think it matters much.

I just tried this via select count(*) from tpcc.order_line; on a four-node large tpcc cluster (~50gb order_line). The results are... not clear? I tested my binary first, the results kept getting better over time (probably RocksDB cleaning up in the background), best I got right before starting into the master binary was 1m22s. The master binary got pretty consistently 1m15s.

Looking at this again though, for this query I would like the 10k rows limit to be the one taking effect, not the 1mb limit. 1mb ~ 10k rows at an average row size of 100b, which is too small. So I'm just going to bump the limit up to 10mb - I'm mostly trying not to get in the way of "reasonable" scans, all I want to do is curb pathological ones.

Copy link
Copy Markdown
Contributor

@nvb nvb 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, 1 of 1 files at r2, 1 of 1 files at r3, 1 of 1 files at r4.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @RaduBerinde and @tbg)


pkg/server/server_test.go, line 469 at r1 (raw file):

				// Iterate through MaxSpanRequestKeys=1..n and TargetBytes=1..m
				// and (where n and m are chosen to reveal the full result set
				// in one page). At each(*) combination, paginate

nit: the comment wrapping here is strange


pkg/storage/replica_evaluate.go, line 339 at r1 (raw file):

				baHeader.TargetBytes -= retBytes
			} else {
				baHeader.TargetBytes = -1

Could you add a comment like we have above for this?

@tbg tbg force-pushed the kvfetcher-limit-really branch from 847b2e6 to 8080741 Compare February 27, 2020 14:49
@tbg
Copy link
Copy Markdown
Member Author

tbg commented Feb 27, 2020

bors r=nvanbenschoten

tbg added 4 commits February 28, 2020 09:11
This PR finishes up the work initiated in cockroachdb#44925 to allow (forward and
reverse) scans to specify a TargetBytes hint which (mod overshooting by
one row) restricts the size of the responses.

The plan is to use it in kvfetcher, however this is left as a separate
commit - here we focus on testing the functionality only.

Release note: None
Fixes cockroachdb#33660.

Release note (bug fix): Significantly reduce the amount of memory
allocated while scanning tables with a large average row size.
We had lowered this because the lack of kvfetcher-level result size
limiting caused OOMs (the lower limit still caused OOMs, though more
rarely). Now kvfetcher does bound the size of its result sets, so
this should just work.

Release note: None
660b3e7 bumped the default range size
by a factor of 8. Do the same in this test.

Addresses one failure mode of cockroachdb#33660.

Release note: None
@tbg tbg force-pushed the kvfetcher-limit-really branch from 15a38a5 to de24cbd Compare February 28, 2020 08:14
@tbg
Copy link
Copy Markdown
Member Author

tbg commented Feb 28, 2020

bors r=nvanbenschoten

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Feb 28, 2020

Build succeeded

@craig craig bot merged commit dcf8c44 into cockroachdb:master Feb 28, 2020
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.

roachtest: hotspotsplits/nodes=4 failed

4 participants