workload: move sampledataccl abstraction and add query workloads#21097
workload: move sampledataccl abstraction and add query workloads#21097danhhz merged 4 commits intocockroachdb:masterfrom
Conversation
|
The code LGTM, but could you expand a bit on the vision? My worry right now is that we're introducing something that will compete with the old-style kv (which also runs against cassandra and mongo, or rather did at some point when that was desired). That said, I like that you're removing friction for adding new types of load generators, I'm just not sure how it fits into the overall picture. I'm also particularly interested in making large test fixtures. Is the plan here to just run the load generator for x ops and then use the resulting data dump? That's fine, but you had at some point talked about making a DistSQL processor that just pulls data out of thin air and which can then be backed up, which sounded geeky but also generally useful, especially to get some low-level control. It's fine if that's out of scope here (having a good SQL-level loadgen driver is great), but a lot of workloads I have in mind need low-level control, and I'm curious if you had anything in mind in this string of commits. Also, don't you think we should make Reviewed 13 of 13 files at r1, 2 of 2 files at r2, 6 of 6 files at r3. pkg/ccl/sqlccl/backup_test.go, line 107 at r1 (raw file):
Wanna at least log them though? Or perhaps just retry? Nevermind if it really doesn't matter for this test pkg/testutils/workload/opts.go, line 41 at r3 (raw file):
Nit: overflow check (but perhaps we can just use int64 for everything). Feel free to ignore, this is obviously very minor. pkg/testutils/workload/workload.go, line 93 at r1 (raw file):
name := g.Name()
if _, ok := registered[name]; ok {
panic(name + " is already registered")
}
registered[name] = fnpkg/testutils/workload/workload.go, line 127 at r1 (raw file):
Is something wrong here? I thought you'd use pkg/testutils/workload/workload.go, line 133 at r1 (raw file):
This measures the size of the encoded SQL values, so inserting a one-char string would count as three ( pkg/testutils/workload/bank/bank.go, line 99 at r1 (raw file):
This is generally a lot longer than pkg/testutils/workload/bank/bank.go, line 112 at r1 (raw file):
remove one pkg/testutils/workload/bank/bank.go, line 115 at r1 (raw file):
This method is now kinda in between: looks very general, is very specialized. I assume it won't stay like that long, so fine by me. pkg/testutils/workload/bank/bank_test.go, line 28 at r1 (raw file):
? pkg/testutils/workload/bank/bank_test.go, line 35 at r1 (raw file):
I feel silly even nitting this, but inline comments start lowercase and no trailing dot. pkg/testutils/workload/cmd/workload/main.go, line 209 at r3 (raw file):
Is this right? I would've expected pkg/testutils/workload/cmd/workload/main.go, line 300 at r3 (raw file):
Nit: may want to output those in sorted order, at which point you're better of grabbing them from the map. pkg/testutils/workload/kv/kv.go, line 89 at r3 (raw file):
Comments from Reviewable |
The sampledataccl package was started to centralize logic for testdata generation in BACKUP/RESTORE, as well as provide comparable benchmarks between operations running at the sql and kv layers. It has proven useful and is ready to graduate out of ccl. Before sampledataccl, many ccl/... tests rolled their own test data in one of various forms: sql INSERTS, csv, []string, []engine.MVCCKeyValue, ssts, RocksDB batch reprs. Insidiously the kv testdata generation was different from test to test and recreated just enough of our sql key encoding to get that test to pass. The sampledataccl.Bank abstraction was built to provide exactly the same schema in all of these forms, converting between them using actual production code, so nothing rotted. This had the wonderful side benefit of making the throughput measurement of benchmarks at the sql and kv layers comparable, which helped considerably during BACKUP/RESTORE performance tuning work. This problem is not exclusive to ccl; many places in the codebase do this recreation of just enough of our key encoding to get a particular test to pass, which is often subtly incorrect and requires boilerplate that detracts from what the test is doing. This commit moves the abstraction out of ccl so it can start to be used more widely. This opportunity is also taken to add support for more than one table as well as the ability to run query workloads (hence the new workload package name). Upcoming commits will add tooling to run these workloads against clusters (think of the loadgen/kv tool), with significantly less effort than is currently required to add a new loadgen. We'll also be able to have a single tool for making large test fixtures and to keep this tool tested so it doesn't rot. This has traditionally been done ad-hoc and was a huge obstruction in BACKUP/RESTORE production testing. Still TODO is teasing the final ccl deps out of the remaining sampledataccl features. Release note: None
Copied exactly. All changes will be made in the next commit. Release note: None
Attempt to change as little as possible. There's definitely future work
moving the concurrent workload runner into generator.
workload -generator kv -drop -duration 2s
Still TODO is creating initial splits and cleaning up the UX of how
Generator options are passed from the commandline.
Release note: None
|
Thanks for the review! The mongo/cassandra stuff is a good question, ycsb does that too. I doubt it makes sense to add the deps on the mongo/cassandra drivers here. The kv code I took is mostly unchanged, there's no reason it couldn't be exported and used by the crdb vs mongo vs cassandra tool, so the impl only lives in one place. I don't love the idea of multiple very similar tools, but I think on the whole this lowered friction (and upcoming ecosystem) is worth it. As for what's next, I wasn't really sure where to put this information. I wanted to get the general idea signed off on and merged before making github issues for it. For now, I'll stick it here in response to your comment, but soon I should find somewhere more discoverable. Large test fixtures and individual kvs are very soon on my mental roadmap. The distsql processor stuff works in a branch, but it's not ready to merge (that code is very tightly coupled right now to what it does, so my branch duplicates far too much). I think there's some reasonable interim solution that writes out CSVs from the generator and then literally calls Thoughts I've had:
Can you describe some of the low level workloads you're talking about? I made a note of #18661 but I assume there are others.
If you don't mind, I'd like to wait on this until I get the splits stuff sorted out so this can be a full replacement for kv (module mongo/cassandra). Review status: 8 of 18 files reviewed at latest revision, 13 unresolved discussions, all commit checks successful. pkg/ccl/sqlccl/backup_test.go, line 107 at r1 (raw file): Previously, tschottdorf (Tobias Schottdorf) wrote…
Done. pkg/testutils/workload/opts.go, line 41 at r3 (raw file): Previously, tschottdorf (Tobias Schottdorf) wrote…
Done. pkg/testutils/workload/workload.go, line 93 at r1 (raw file): Previously, tschottdorf (Tobias Schottdorf) wrote…
Oh nice, good call. pkg/testutils/workload/workload.go, line 127 at r1 (raw file): Previously, tschottdorf (Tobias Schottdorf) wrote…
eek, this was all off pkg/testutils/workload/workload.go, line 133 at r1 (raw file): Previously, tschottdorf (Tobias Schottdorf) wrote…
Done. Also definitely accepting suggestions for better things to do here pkg/testutils/workload/bank/bank.go, line 99 at r1 (raw file): Previously, tschottdorf (Tobias Schottdorf) wrote…
It wasn't for the backup/restore tests but this is a good time to fix it. Done. pkg/testutils/workload/bank/bank.go, line 112 at r1 (raw file): Previously, tschottdorf (Tobias Schottdorf) wrote…
Done. pkg/testutils/workload/bank/bank.go, line 115 at r1 (raw file): Previously, tschottdorf (Tobias Schottdorf) wrote…
Yeah, ycsb and kv both also do splits. I haven't thought through what the generalization is yet pkg/testutils/workload/bank/bank_test.go, line 28 at r1 (raw file): Previously, tschottdorf (Tobias Schottdorf) wrote…
I was testing the go:generate line that enforces these. (TIL this isn't even sufficient because it matches the literal string, which is still here. when i added something else it failed in the way i was expecting) pkg/testutils/workload/bank/bank_test.go, line 35 at r1 (raw file): Previously, tschottdorf (Tobias Schottdorf) wrote…
Done. pkg/testutils/workload/cmd/workload/main.go, line 209 at r3 (raw file): Previously, tschottdorf (Tobias Schottdorf) wrote…
this file definitely wants tests, but they'll be easier once it's moved out of one big main (which I'd like to save for another PR) pkg/testutils/workload/cmd/workload/main.go, line 300 at r3 (raw file): Previously, tschottdorf (Tobias Schottdorf) wrote…
I don't feel strongly at all, but I'd probably expect them to come out in the order I specify, so that they can have some meaningful order. But maybe a stable order makes more sense. I'm going to leave this as a TODO if you don't mind pkg/testutils/workload/kv/kv.go, line 89 at r3 (raw file): Previously, tschottdorf (Tobias Schottdorf) wrote…
Done. Comments from Reviewable |
|
Nice to see an attempt to remove some of the common boilerplate from load generators. Is there a reason you structured this as a single Review status: 8 of 18 files reviewed at latest revision, 14 unresolved discussions, all commit checks successful. pkg/testutils/workload/cmd/workload/main.go, line 48 at r6 (raw file):
This seems like it could get awkward. Is there a problem with letting workloads define their own flags? If you're worried about name space pollution, I think the solution to that is to use a more advanced command line interface such as
Comments from Reviewable |
|
I left it as a binary to minimize the change from the existing kv code. Ditto for cobra, and I agree we should be using that instead (I've already started to reinvent the wheel more than I'd like in opts.go). The options were originally a |
|
Reviewed 10 of 10 files at r4, 2 of 2 files at r5, 6 of 6 files at r6. pkg/testutils/workload/workload.go, line 133 at r1 (raw file): Previously, danhhz (Daniel Harrison) wrote…
The main problem seems to be that pkg/testutils/workload/workload.go, line 119 at r4 (raw file):
pkg/testutils/workload/bank/bank.go, line 104 at r4 (raw file):
pkg/testutils/workload/cmd/workload/main.go, line 300 at r3 (raw file): Previously, danhhz (Daniel Harrison) wrote…
No, I don't mind. My argument for ordering is that it decides the test name, and that should be stable w.r.t permutation of the opts. Comments from Reviewable |
|
Yup, using cobra and switching to a Review status: 13 of 17 files reviewed at latest revision, 5 unresolved discussions. pkg/testutils/workload/workload.go, line 133 at r1 (raw file): Previously, tschottdorf (Tobias Schottdorf) wrote…
I had pkg/testutils/workload/workload.go, line 119 at r4 (raw file): Previously, tschottdorf (Tobias Schottdorf) wrote…
Done. pkg/testutils/workload/bank/bank.go, line 104 at r4 (raw file): Previously, tschottdorf (Tobias Schottdorf) wrote…
Done. pkg/testutils/workload/cmd/workload/main.go, line 300 at r3 (raw file): Previously, tschottdorf (Tobias Schottdorf) wrote…
It's now printed in stable order via Visit (happens to be alphabetical) pkg/testutils/workload/cmd/workload/main.go, line 48 at r6 (raw file): Previously, petermattis (Peter Mattis) wrote…
I was planning on doing this later, but I'm glad you prodded me into doing it now. The cli interface is MUCH nicer Comments from Reviewable |
|
The flag change is super nice. Still Reviewed 5 of 5 files at r7. pkg/testutils/workload/cmd/workload/main.go, line 303 at r7 (raw file):
but don't eat CI for this. Comments from Reviewable |
|
Review status: all files reviewed at latest revision, 4 unresolved discussions, all commit checks successful. pkg/testutils/workload/cmd/workload/main.go, line 53 at r7 (raw file):
Many of these lines should be wrapped at 100 columns. pkg/testutils/workload/cmd/workload/main.go, line 56 at r7 (raw file):
I would have thought this a workload specific flag. Update: perhaps this is detritus. pkg/testutils/workload/cmd/workload/main.go, line 122 at r7 (raw file):
The Comments from Reviewable |
This allows for a vastly superior cli interface, help text for each
configuration option, and removes the options parsing library that was
a wheel starting to be re-invented.
workload kv --drop --batch 10 --max-ops 5 --concurrency 5 --max-block-bytes 4
Also address some code review feedback that I didn't feel like carefully
rebasing back into the relevant commits.
Release note: None
|
Thanks for the reviews! Review status: 16 of 17 files reviewed at latest revision, 4 unresolved discussions, all commit checks successful. pkg/testutils/workload/cmd/workload/main.go, line 53 at r7 (raw file): Previously, petermattis (Peter Mattis) wrote…
I don't find that more readable in this case, but I'll defer to my reviewer. Done here and elsewhere. pkg/testutils/workload/cmd/workload/main.go, line 56 at r7 (raw file): Previously, petermattis (Peter Mattis) wrote…
Yeah, this is awkward because it's used for max-ops. I've been waiting to port the TPCC query loads over before cleaning this up too much because I think they'll be instructive in which generalizations I'll need pkg/testutils/workload/cmd/workload/main.go, line 122 at r7 (raw file): Previously, petermattis (Peter Mattis) wrote…
Done. pkg/testutils/workload/cmd/workload/main.go, line 303 at r7 (raw file): Previously, tschottdorf (Tobias Schottdorf) wrote…
Done. Comments from Reviewable |
|
Review status: 16 of 17 files reviewed at latest revision, 2 unresolved discussions, all commit checks successful. pkg/testutils/workload/cmd/workload/main.go, line 53 at r7 (raw file): Previously, danhhz (Daniel Harrison) wrote…
Reviewable wraps into unreadability at 100 columns. Comments from Reviewable |
The sampledataccl package was started to centralize logic for testdata generation in BACKUP/RESTORE, as well as provide comparable benchmarks between operations running at the sql and kv layers. It has proven useful and is ready to graduate out of ccl.
Before sampledataccl, many ccl/... tests rolled their own test data in one of various forms: sql INSERTS, csv, []string, []engine.MVCCKeyValue, ssts, RocksDB batch reprs. Insidiously the kv testdata generation was different from test to test and recreated just enough of our sql key encoding to get that test to pass. The sampledataccl.Bank abstraction was built to provide exactly the same schema in all of these forms, converting between them using actual production code, so nothing rotted.
This had the wonderful side benefit of making the throughput measurement of benchmarks at the sql and kv layers comparable, which helped considerably during BACKUP/RESTORE performance tuning work.
This problem is not exclusive to ccl; many places in the codebase do this recreation of just enough of our key encoding to get a particular test to pass, which is often subtly incorrect and requires boilerplate that detracts from what the test is doing.
This moves the abstraction out of ccl so it can start to be used more widely. This opportunity is also taken to add support for more than one table as well as the ability to run query workloads (hence the new workload package name).
Upcoming commits will add tooling to run these workloads against clusters (think of the loadgen/kv tool), with significantly less effort than is currently required to add a new loadgen.
We'll also be able to have a single tool for making large test fixtures and to keep this tool tested so it doesn't rot. This has traditionally been done ad-hoc and was a huge obstruction in BACKUP/RESTORE production testing.
Still TODO is teasing the final ccl deps out of the remaining sampledataccl features.
Also port https://github.com/cockroachdb/loadgen/tree/master/kv to be a Generator and add the driver program as a
workloadcli command.