-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
asim: add randomized range generation #107354
Conversation
d3d5fa2
to
1dec2f8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice stuff! Left some comments - lmk if you have any questions.
Reviewed 8 of 8 files at r1, 4 of 4 files at r2, 8 of 8 files at r3, all commit messages.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @wenyihu6)
-- commits
line 25 at r3:
Just a reminder to fill this out.
pkg/kv/kvserver/asim/state/config_loader.go
line 302 at r1 (raw file):
s.SetNodeLocality(node.NodeID(), locality) storesRequired := z.StoresPerNode if storesRequired < 1 {
Could we unify this with the above addition? It feels error prone to be handling default values in two places. Also consider adding a TODO for moving these defaults to generation and panicing instead.
pkg/kv/kvserver/asim/tests/rand_framework.go
line 58 at r1 (raw file):
func (f randTestingFramework) getCluster() gen.ClusterGen { if !f.s.randOptions["cluster"] {
Convert to using struct fields, like we discussed offline.
pkg/kv/kvserver/asim/tests/rand_framework.go
line 237 at r3 (raw file):
) func convertInt64ToInt(num int64) int {
I'd prefer to just panic if here rather than truncate.
pkg/kv/kvserver/asim/tests/rand_gen.go
line 34 at r3 (raw file):
} func NewRandomizedBasicRanges(
There are quite a few constructor functions but I wonder how much value they are providing? The panic below seems good - but perhaps we could scale back the encapsulation, given the structs are exported anyway?
pkg/kv/kvserver/asim/workload/workload.go
line 194 at r3 (raw file):
} func (g *uniformGenerator) Num() int64 {
From offline - it would be better to keep these as writeKey/readKey for now - then add a comment describing an intention to re-use pkg/workload/(kv|ycsb)
key gens so we test with the same stuff.
pkg/kv/kvserver/asim/tests/rand_test.go
line 30 at r1 (raw file):
// TestRandomized is a randomized testing framework which validates an allocator // simulator by creating randomized configurations, exposing potential edge
nit: allocation simulation. This test is asserting on the expected behavior of allocation, not the simulator.
d2b9399
to
c46e671
Compare
Previously, kvoli (Austen) wrote…
|
Previously, kvoli (Austen) wrote…
Done. |
Previously, kvoli (Austen) wrote…
Done. |
Previously, kvoli (Austen) wrote…
Agreed. Removed some constructors and added panic checks in Generate() instead. |
Previously, kvoli (Austen) wrote…
This wasn't so easy since writeKey/readKey are not exported. I'm considering to mark them as exported from pkg/kv/kvserver/asim/workload/workload.go since we will want to export them when re-using key gens from |
e3ae6ce
to
710e025
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 10 of 10 files at r4.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @wenyihu6)
pkg/kv/kvserver/asim/state/config_loader.go
line 302 at r1 (raw file):
I think both. It should panic, but then we also need to update the existing code.
pkg/kv/kvserver/asim/workload/workload.go
line 194 at r3 (raw file):
Previously, wenyihu6 (Wenyi Hu) wrote…
This wasn't so easy since writeKey/readKey are not exported. I'm considering to mark them as exported from pkg/kv/kvserver/asim/workload/workload.go since we will want to export them when re-using key gens from
pkg/workload/(kv|ycsb)
. Alternatively, we can re-create them here. Wdyt?
Let's go with the re-create here option for now.
f187448
to
18fee8b
Compare
eef4a03
to
ee6b12c
Compare
The first four commits are from #107075. |
Added the comment here. |
Previously, kvoli (Austen) wrote…
Done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a small question re: key generator in the tests
pkg. Looking great!
Reviewed 13 of 13 files at r7, 2 of 2 files at r8, 6 of 6 files at r9, 6 of 6 files at r10, 8 of 8 files at r11, all commit messages.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @wenyihu6)
-- commits
line 65 at r11:
nit: "enables random range configurations to be generated"
pkg/kv/kvserver/asim/tests/rand_framework.go
line 237 at r3 (raw file):
Previously, kvoli (Austen) wrote…
I'd prefer to just panic if here rather than truncate.
Nice, thanks!
pkg/kv/kvserver/asim/tests/rand_gen.go
line 89 at r11 (raw file):
// newUniformKeyGen returns a generator that generates number∈[min, max] with a // uniform distribution. func newUniformKeyGen(min, max int64, rand *rand.Rand) generator {
What is the difference between this key gen, and the asim/workload
key gen?
pkg/kv/kvserver/asim/workload/workload.go
line 167 at r11 (raw file):
Previously, wenyihu6 (Wenyi Hu) wrote…
Added the comment here.
Ack
dd087d3
to
f43274a
Compare
Previously, kvoli (Austen) wrote…
Done. |
Previously, kvoli (Austen) wrote…
I don't think so. I think we discussed in #107354 (review) that we want to re-create them. But I'm not sure if I'm interpreting the question correctly. |
Previously, wenyihu6 (Wenyi Hu) wrote…
I don't think there are any differences* |
Previously, kvoli (Austen) wrote…
Done in #107075 |
f43274a
to
3f9d84e
Compare
3f9d84e
to
05a7c11
Compare
05a7c11
to
5c74f9c
Compare
This patch enables random range configurations to be generated. TestRandomized can now take another setting parameter rangeGen (default: uniform rangeGenType, uniform keySpaceGenType, empty weightedRand). These generators are part of the framework fields which persist across iterations. The numbers produced by the generator shape the distribution across iterations. - rangeKeyGenType: determines range generator type across iterations (default: uniformGenerator, min = 1, max = 1000) - keySpaceGenType: determines key space generator type across iterations (default: uniformGenerator, min = 1000, max = 200000) - weightedRand: if non-empty, enables weighted randomization for range distribution This provides three modes for range generation: 1. Default: currently set to uniform distribution 2. Random: randomly generates range distribution across stores 3. Weighted Randomization: enables weighted randomization for range distribution if and only if given weightedRand is non-empty Part of: cockroachdb#106311 Release note: None
5c74f9c
to
5e55ef7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, apologies for the delay!
Reviewed 5 of 8 files at r13, 4 of 4 files at r14, all commit messages.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @wenyihu6)
TFTR! No need to apologize : ) It was held up by the non-deterministic issue. bors r=kvoli |
Build succeeded: |
This patch enables random range configuration to be generated.
TestRandomized can now take another setting parameter rangeGen (default: uniform
rangeGenType, uniform keySpaceGenType, empty weightedRand).
These generators are part of the framework fields which persist across
iterations. The numbers produced by the generator shape the distribution across
iterations.
rangeKeyGenType: determines range generator type across iterations (default:
uniformGenerator, min = 1, max = 1000)
keySpaceGenType: determines key space generator type across iterations
(default: uniformGenerator, min = 1000, max = 200000)
weightedRand: if non-empty, enables weighted randomization for range
distribution
This provides three modes for range generation:
if and only if given weightedRand is non-empty
Part of: #106311
Release note: None