Skip to content

Commit b51c94b

Browse files
YCSB: customizable zipfian constant (#321)
Co-authored-by: Andy Pavlo <[email protected]>
1 parent 73e5d64 commit b51c94b

File tree

10 files changed

+40
-2
lines changed

10 files changed

+40
-2
lines changed

config/cockroachdb/sample_ycsb_config.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
<!-- Optional: Override the field size for each column in USERTABLE -->
1717
<!-- <fieldSize>8</fieldSize> -->
1818

19+
<!-- Optional: Override the zipfian constant to modify the skew -->
20+
<!-- <skewFactor>0.99</skewFactor> -->
21+
1922
<!-- The workload -->
2023
<terminals>1</terminals>
2124
<works>

config/mariadb/sample_ycsb_config.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
<!-- Optional: Override the field size for each column in USERTABLE -->
1717
<!-- <fieldSize>8</fieldSize> -->
1818

19+
<!-- Optional: Override the zipfian constant to modify the skew -->
20+
<!-- <skewFactor>0.99</skewFactor> -->
21+
1922
<!-- The workload -->
2023
<terminals>1</terminals>
2124
<works>

config/mysql/sample_ycsb_config.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212

1313
<!-- Scalefactor in YCSB is *1000 the number of rows in the USERTABLE-->
1414
<scalefactor>1</scalefactor>
15+
16+
<!-- Optional: Override the zipfian constant to modify the skew -->
17+
<!-- <skewFactor>0.99</skewFactor> -->
1518

1619
<!-- The workload -->
1720
<terminals>1</terminals>

config/noisepage/sample_ycsb_config.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
<!-- Scalefactor in YCSB is *1000 the number of rows in the USERTABLE-->
1414
<scalefactor>1</scalefactor>
1515

16+
<!-- Optional: Override the zipfian constant to modify the skew -->
17+
<!-- <skewFactor>0.99</skewFactor> -->
18+
1619
<!-- The workload -->
1720
<terminals>1</terminals>
1821
<works>

config/postgres/sample_ycsb_config.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
<!-- Optional: Override the field size for each column in USERTABLE -->
1717
<!-- <fieldSize>8</fieldSize> -->
1818

19+
<!-- Optional: Override the zipfian constant to modify the skew -->
20+
<!-- <skewFactor>0.99</skewFactor> -->
21+
1922
<!-- The workload -->
2023
<terminals>1</terminals>
2124
<works>

config/spanner/sample_ycsb_config.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
<!-- Optional: Override the field size for each column in USERTABLE -->
1515
<!-- <fieldSize>8</fieldSize> -->
1616

17+
<!-- Optional: Override the zipfian constant to modify the skew -->
18+
<!-- <skewFactor>0.99</skewFactor> -->
19+
1720
<!-- The workload -->
1821
<terminals>1</terminals>
1922
<works>

config/sqlite/sample_ycsb_config.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010

1111
<!-- Scalefactor in YCSB is *1000 the number of rows in the USERTABLE-->
1212
<scalefactor>1</scalefactor>
13+
14+
<!-- Optional: Override the zipfian constant to modify the skew -->
15+
<!-- <skewFactor>0.99</skewFactor> -->
1316

1417
<!-- SQLITE only supports one writer thread -->
1518
<loaderThreads>1</loaderThreads>

config/sqlserver/sample_ycsb_config.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
<!-- Optional: Override the field size for each column in USERTABLE -->
1717
<!-- <fieldSize>8</fieldSize> -->
1818

19+
<!-- Optional: Override the zipfian constant to modify the skew -->
20+
<!-- <skewFactor>0.99</skewFactor> -->
21+
1922
<!-- The workload -->
2023
<terminals>1</terminals>
2124
<works>

src/main/java/com/oltpbenchmark/benchmarks/ycsb/YCSBBenchmark.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ public class YCSBBenchmark extends BenchmarkModule {
4343
*/
4444
protected final int fieldSize;
4545

46+
/**
47+
* The constant used in the zipfian distribution (to modify the skew)
48+
*/
49+
protected final double skewFactor;
50+
4651
public YCSBBenchmark(WorkloadConfiguration workConf) {
4752
super(workConf);
4853

@@ -54,6 +59,15 @@ public YCSBBenchmark(WorkloadConfiguration workConf) {
5459
if (this.fieldSize <= 0) {
5560
throw new RuntimeException("Invalid YCSB fieldSize '" + this.fieldSize + "'");
5661
}
62+
63+
double skewFactor = 0.99;
64+
if (workConf.getXmlConfig() != null && workConf.getXmlConfig().containsKey("skewFactor")) {
65+
skewFactor = workConf.getXmlConfig().getDouble("skewFactor");
66+
if (skewFactor <= 0 || skewFactor >= 1) {
67+
throw new RuntimeException("Invalid YCSB skewFactor '" + skewFactor + "'");
68+
}
69+
}
70+
this.skewFactor = skewFactor;
5771
}
5872

5973
@Override

src/main/java/com/oltpbenchmark/benchmarks/ycsb/YCSBWorker.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ class YCSBWorker extends Worker<YCSBBenchmark> {
5858
public YCSBWorker(YCSBBenchmark benchmarkModule, int id, int init_record_count) {
5959
super(benchmarkModule, id);
6060
this.data = new char[benchmarkModule.fieldSize];
61-
this.readRecord = new ZipfianGenerator(rng(), init_record_count);// pool for read keys
62-
this.randScan = new ZipfianGenerator(rng(), YCSBConstants.MAX_SCAN);
61+
this.readRecord = new ZipfianGenerator(rng(), init_record_count, benchmarkModule.skewFactor);// pool for read keys
62+
this.randScan = new ZipfianGenerator(rng(), YCSBConstants.MAX_SCAN, benchmarkModule.skewFactor);
6363

6464
synchronized (YCSBWorker.class) {
6565
// We must know where to start inserting

0 commit comments

Comments
 (0)