-
Notifications
You must be signed in to change notification settings - Fork 6
Google Cloud n2‐standard‐8 x SSD Benchmarks (K4 v2.1.6 RocksDB v9.7.4
Running a benchmark kind stress test. I ran the go bench program seen here https://github.com/guycipher/k4/blob/main/bench/bench.go With the following parameters
go build -o bench bench.go && ./bench -num_ops 10000000 -num_threads 4 -flush_threshold (1024*1024)*512 -compaction_interval 3600
The results for above test on the VM show
Compaction was not triggered in above bench as it was set to an hour. In my further benchmarks I will do 100 or 200 million operations and set compaction to a less interval so compaction can occur at least once or twice.
I am still benchmarking RocksDB, I'm not too familiar with how I can set it similarly. I'm going to have to read up on this bit.
Example of how RocksDB is being benched, this is the sequential read test, you can see the threshold is set similarly to K4.
#define DB_PATH "testdb"
#define NUM_OPS 10000000
void benchmark_rocksdb(bool no_sync);
void benchmark_lmdb();
void benchmark_k4();
int main() {
benchmark_rocksdb(false);
//benchmark_lmdb();
//benchmark_k4();
return 0;
}
void benchmark_rocksdb(bool no_sync) {
rocksdb_t *db;
rocksdb_options_t *options = rocksdb_options_create();
rocksdb_options_set_create_if_missing(options, 1);
rocksdb_options_set_write_buffer_size(options, 536870912); // 512 MB
char *err = NULL;
db = rocksdb_open(options, DB_PATH, &err);
if (err != NULL) {
fprintf(stderr, "Error opening RocksDB: %s\n", err);
return;
}
rocksdb_writeoptions_t *write_options = rocksdb_writeoptions_create();
rocksdb_writeoptions_set_sync(write_options, !no_sync);
char key[20], value[20];
clock_t start, end;
double cpu_time_used;
// Benchmark Put
start = clock();
for (int i = 0; i < NUM_OPS; i++) {
sprintf(key, "key%d", i);
sprintf(value, "value%d", i);
rocksdb_put(db, write_options, key, strlen(key), value, strlen(value), &err);
}
end = clock();
cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC;
printf("RocksDB Put: %f seconds\n", cpu_time_used);
// Benchmark Get
start = clock();
for (int i = 0; i < NUM_OPS; i++) {
sprintf(key, "key%d", i);
size_t read_len;
char *read_value = rocksdb_get(db, rocksdb_readoptions_create(), key, strlen(key), &read_len, &err);
free(read_value);
}
end = clock();
cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC;
printf("RocksDB Get: %f seconds\n", cpu_time_used);
// Benchmark Delete
start = clock();
for (int i = 0; i < NUM_OPS; i++) {
sprintf(key, "key%d", i);
rocksdb_delete(db, write_options, key, strlen(key), &err);
}
end = clock();
cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC;
printf("RocksDB Delete: %f seconds\n", cpu_time_used);
rocksdb_writeoptions_destroy(write_options);
rocksdb_close(db);
rocksdb_options_destroy(options);
remove(DB_PATH);
}
Above is taking REALLY long. Not sure why.
To add RocksDB isn't utilizing much CPU for these amount of writes.
Whereas K4 definitely was.