Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 75e8b90cb9 | |||
| 6c1ea2f56a | |||
| 9f6434dba1 | |||
| 08b1fcec9a |
1
.gitignore
vendored
@ -5,7 +5,6 @@
|
|||||||
/scripts/lib64
|
/scripts/lib64
|
||||||
/scripts/share/
|
/scripts/share/
|
||||||
/scripts/.gitignore
|
/scripts/.gitignore
|
||||||
*.png
|
|
||||||
*.csv
|
*.csv
|
||||||
pyvenv.cfg
|
pyvenv.cfg
|
||||||
Cargo.lock
|
Cargo.lock
|
||||||
|
|||||||
@ -4,7 +4,7 @@ version = "0.1.0"
|
|||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
mace = { git = "https://github.com/abbycin/mace" }
|
mace-kv = { git = "https://github.com/abbycin/mace" }
|
||||||
clap = { version = "4.5.48", features = ["derive"] }
|
clap = { version = "4.5.48", features = ["derive"] }
|
||||||
rand = "0.9.2"
|
rand = "0.9.2"
|
||||||
log = "0.4.22"
|
log = "0.4.22"
|
||||||
|
|||||||
28
README.md
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
# mace 0.0.19
|
||||||
|
|
||||||
|
## insert performance
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## random get performance (cold get)
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# mixed perfomance (hot get)
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
# sequential scan perfomance (cold scan)
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
@ -1,10 +1,16 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <fmt/base.h>
|
||||||
#include <fmt/format.h>
|
#include <fmt/format.h>
|
||||||
|
#include <memory>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <rocksdb/cache.h>
|
#include <rocksdb/cache.h>
|
||||||
#include <rocksdb/db.h>
|
#include <rocksdb/db.h>
|
||||||
|
#include <rocksdb/env.h>
|
||||||
#include <rocksdb/options.h>
|
#include <rocksdb/options.h>
|
||||||
|
#include <rocksdb/table.h>
|
||||||
#include <rocksdb/utilities/optimistic_transaction_db.h>
|
#include <rocksdb/utilities/optimistic_transaction_db.h>
|
||||||
#include <rocksdb/utilities/transaction.h>
|
#include <rocksdb/utilities/transaction.h>
|
||||||
#include <rocksdb/utilities/transaction_db.h>
|
#include <rocksdb/utilities/transaction_db.h>
|
||||||
@ -40,7 +46,7 @@ int main(int argc, char *argv[]) {
|
|||||||
.path = "/tmp/rocksdb_tmp",
|
.path = "/tmp/rocksdb_tmp",
|
||||||
};
|
};
|
||||||
|
|
||||||
app.add_option("-m,--mode", args.mode, "Mode: insert, get, mixed");
|
app.add_option("-m,--mode", args.mode, "Mode: insert, get, mixed, scan");
|
||||||
app.add_option("-t,--threads", args.threads, "Threads");
|
app.add_option("-t,--threads", args.threads, "Threads");
|
||||||
app.add_option("-k,--key-size", args.key_size, "Key Size");
|
app.add_option("-k,--key-size", args.key_size, "Key Size");
|
||||||
app.add_option("-v,--value-size", args.value_size, "Value Size");
|
app.add_option("-v,--value-size", args.value_size, "Value Size");
|
||||||
@ -61,7 +67,7 @@ int main(int argc, char *argv[]) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.mode != "insert" && args.mode != "get" && args.mode != "mixed") {
|
if (args.mode != "insert" && args.mode != "get" && args.mode != "mixed" && args.mode != "scan") {
|
||||||
fmt::println("Error: Invalid mode");
|
fmt::println("Error: Invalid mode");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -76,17 +82,30 @@ int main(int argc, char *argv[]) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
rocksdb::Options options;
|
rocksdb::ColumnFamilyOptions cfo{};
|
||||||
|
cfo.enable_blob_files = true;
|
||||||
|
cfo.min_blob_size = 8192;
|
||||||
|
// use 1GB block cache
|
||||||
|
auto cache = rocksdb::NewLRUCache(1 << 30);
|
||||||
|
rocksdb::BlockBasedTableOptions table_options{};
|
||||||
|
table_options.block_cache = cache;
|
||||||
|
cfo.table_factory.reset(NewBlockBasedTableFactory(table_options));
|
||||||
|
// the following three options makes it not trigger GC in test
|
||||||
|
cfo.level0_file_num_compaction_trigger = 10000;
|
||||||
|
cfo.write_buffer_size = 64 << 20;
|
||||||
|
cfo.max_write_buffer_number = 16;
|
||||||
|
|
||||||
|
std::vector<rocksdb::ColumnFamilyDescriptor> cfd{};
|
||||||
|
cfd.push_back(rocksdb::ColumnFamilyDescriptor("default", cfo));
|
||||||
|
|
||||||
|
rocksdb::DBOptions options;
|
||||||
options.create_if_missing = true;
|
options.create_if_missing = true;
|
||||||
options.allow_concurrent_memtable_write = true;
|
options.allow_concurrent_memtable_write = true;
|
||||||
options.enable_pipelined_write = true;
|
options.enable_pipelined_write = true;
|
||||||
// the following three options makes it not trigger GC in test
|
options.env->SetBackgroundThreads(4, rocksdb::Env::Priority::HIGH);
|
||||||
options.level0_file_num_compaction_trigger = 1000;
|
|
||||||
options.write_buffer_size = 1 << 30;
|
|
||||||
options.max_write_buffer_number = 5;
|
|
||||||
|
|
||||||
auto ropt = rocksdb::ReadOptions();
|
|
||||||
auto wopt = rocksdb::WriteOptions();
|
auto wopt = rocksdb::WriteOptions();
|
||||||
|
wopt.no_slowdown = true;
|
||||||
// wopt.disableWAL = true;
|
// wopt.disableWAL = true;
|
||||||
std::vector<std::thread> wg;
|
std::vector<std::thread> wg;
|
||||||
std::vector<std::vector<std::string>> keys{};
|
std::vector<std::vector<std::string>> keys{};
|
||||||
@ -94,7 +113,8 @@ int main(int argc, char *argv[]) {
|
|||||||
rocksdb::OptimisticTransactionDB *db;
|
rocksdb::OptimisticTransactionDB *db;
|
||||||
auto b = nm::Instant::now();
|
auto b = nm::Instant::now();
|
||||||
std::mutex mtx{};
|
std::mutex mtx{};
|
||||||
auto s = rocksdb::OptimisticTransactionDB::Open(options, args.path, &db);
|
std::vector<rocksdb::ColumnFamilyHandle *> handles{};
|
||||||
|
auto s = rocksdb::OptimisticTransactionDB::Open(options, args.path, cfd, &handles, &db);
|
||||||
assert(s.ok());
|
assert(s.ok());
|
||||||
std::barrier barrier{static_cast<ptrdiff_t>(args.threads)};
|
std::barrier barrier{static_cast<ptrdiff_t>(args.threads)};
|
||||||
|
|
||||||
@ -111,33 +131,41 @@ int main(int argc, char *argv[]) {
|
|||||||
tmp.resize(args.key_size, 'x');
|
tmp.resize(args.key_size, 'x');
|
||||||
key.emplace_back(std::move(tmp));
|
key.emplace_back(std::move(tmp));
|
||||||
}
|
}
|
||||||
if (args.random) {
|
if (args.mode == "get" || args.random) {
|
||||||
std::shuffle(keys.begin(), keys.end(), gen);
|
std::shuffle(keys.begin(), keys.end(), gen);
|
||||||
}
|
}
|
||||||
keys.emplace_back(std::move(key));
|
keys.emplace_back(std::move(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (args.mode == "get") {
|
auto *handle = handles[0];
|
||||||
|
|
||||||
|
if (args.mode == "get" || args.mode == "scan") {
|
||||||
auto *kv = db->BeginTransaction(wopt);
|
auto *kv = db->BeginTransaction(wopt);
|
||||||
for (size_t tid = 0; tid < args.threads; ++tid) {
|
for (size_t tid = 0; tid < args.threads; ++tid) {
|
||||||
auto *tk = &keys[tid];
|
auto *tk = &keys[tid];
|
||||||
for (auto &key: *tk) {
|
for (auto &key: *tk) {
|
||||||
kv->Put(key, val);
|
kv->Put(handle, key, val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
kv->Commit();
|
kv->Commit();
|
||||||
delete kv;
|
delete kv;
|
||||||
|
delete handle;
|
||||||
delete db;
|
delete db;
|
||||||
|
handles.clear();
|
||||||
// re-open db
|
// re-open db
|
||||||
s = rocksdb::OptimisticTransactionDB::Open(options, args.path, &db);
|
s = rocksdb::OptimisticTransactionDB::Open(options, args.path, cfd, &handles, &db);
|
||||||
assert(s.ok());
|
assert(s.ok());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handle = handles[0];
|
||||||
for (size_t tid = 0; tid < args.threads; ++tid) {
|
for (size_t tid = 0; tid < args.threads; ++tid) {
|
||||||
auto *tk = &keys[tid];
|
auto *tk = &keys[tid];
|
||||||
wg.emplace_back([&] {
|
wg.emplace_back([&, tid] {
|
||||||
std::string rval(args.value_size, '0');
|
std::string rval(args.value_size, '0');
|
||||||
|
auto prefix = std::format("key_{}", tid);
|
||||||
|
auto ropt = rocksdb::ReadOptions();
|
||||||
|
|
||||||
barrier.arrive_and_wait();
|
barrier.arrive_and_wait();
|
||||||
if (mtx.try_lock()) {
|
if (mtx.try_lock()) {
|
||||||
b = nm::Instant::now();
|
b = nm::Instant::now();
|
||||||
@ -147,7 +175,7 @@ int main(int argc, char *argv[]) {
|
|||||||
if (args.mode == "insert") {
|
if (args.mode == "insert") {
|
||||||
for (auto &key: *tk) {
|
for (auto &key: *tk) {
|
||||||
auto *kv = db->BeginTransaction(wopt);
|
auto *kv = db->BeginTransaction(wopt);
|
||||||
kv->Put(key, val);
|
kv->Put(handle, key, val);
|
||||||
kv->Commit();
|
kv->Commit();
|
||||||
delete kv;
|
delete kv;
|
||||||
}
|
}
|
||||||
@ -155,7 +183,7 @@ int main(int argc, char *argv[]) {
|
|||||||
} else if (args.mode == "get") {
|
} else if (args.mode == "get") {
|
||||||
for (auto &key: *tk) {
|
for (auto &key: *tk) {
|
||||||
auto *kv = db->BeginTransaction(wopt);
|
auto *kv = db->BeginTransaction(wopt);
|
||||||
kv->Get(ropt, key, &rval);
|
kv->Get(ropt, handle, key, &rval);
|
||||||
kv->Commit();
|
kv->Commit();
|
||||||
delete kv;
|
delete kv;
|
||||||
}
|
}
|
||||||
@ -164,13 +192,20 @@ int main(int argc, char *argv[]) {
|
|||||||
auto is_insert = dist(gen) < args.insert_ratio;
|
auto is_insert = dist(gen) < args.insert_ratio;
|
||||||
auto *kv = db->BeginTransaction(wopt);
|
auto *kv = db->BeginTransaction(wopt);
|
||||||
if (is_insert) {
|
if (is_insert) {
|
||||||
kv->Put(key, val);
|
kv->Put(handle, key, val);
|
||||||
} else {
|
} else {
|
||||||
kv->Get(ropt, key, &rval); // not found
|
kv->Get(ropt, handle, key, &rval); // not found
|
||||||
}
|
}
|
||||||
kv->Commit();
|
kv->Commit();
|
||||||
delete kv;
|
delete kv;
|
||||||
}
|
}
|
||||||
|
} else if (args.mode == "scan") {
|
||||||
|
auto *iter = db->NewIterator(ropt);
|
||||||
|
iter->Seek(prefix);
|
||||||
|
while (iter->Valid()) {
|
||||||
|
iter->Next();
|
||||||
|
}
|
||||||
|
delete iter;
|
||||||
}
|
}
|
||||||
total_op.fetch_add(args.iterations, std::memory_order::relaxed);
|
total_op.fetch_add(args.iterations, std::memory_order::relaxed);
|
||||||
});
|
});
|
||||||
@ -184,9 +219,10 @@ int main(int argc, char *argv[]) {
|
|||||||
return args.insert_ratio;
|
return args.insert_ratio;
|
||||||
return args.mode == "insert" ? 100 : 0;
|
return args.mode == "insert" ? 100 : 0;
|
||||||
}();
|
}();
|
||||||
double ops = static_cast<double>(total_op.load(std::memory_order_relaxed)) / b.elapse_sec();
|
uint64_t ops = total_op.load(std::memory_order_relaxed) / b.elapse_sec();
|
||||||
fmt::println("{},{},{},{},{},{:.2f},{}", args.mode, args.threads, args.key_size, args.value_size, ratio, ops,
|
fmt::println("{},{},{},{},{},{},{}", args.mode, args.threads, args.key_size, args.value_size, ratio, (uint64_t) ops,
|
||||||
b.elapse_ms());
|
(uint64_t) b.elapse_ms());
|
||||||
|
delete handle;
|
||||||
delete db;
|
delete db;
|
||||||
std::filesystem::remove_all(args.path);
|
std::filesystem::remove_all(args.path);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,26 +5,34 @@ cd ..
|
|||||||
cargo build --release 1>/dev/null 2> /dev/null
|
cargo build --release 1>/dev/null 2> /dev/null
|
||||||
|
|
||||||
function samples() {
|
function samples() {
|
||||||
kv_sz=(16 16 100 1024 1024 1024)
|
export RUST_BACKTRACE=full
|
||||||
|
kv_sz=(16 16 100 1024 1024 1024 16 10240)
|
||||||
# set -x
|
# set -x
|
||||||
|
|
||||||
|
cnt=10000
|
||||||
for ((i = 1; i <= $(nproc); i *= 2))
|
for ((i = 1; i <= $(nproc); i *= 2))
|
||||||
do
|
do
|
||||||
for ((j = 0; j < ${#kv_sz[@]}; j += 2))
|
for ((j = 0; j < ${#kv_sz[@]}; j += 2))
|
||||||
do
|
do
|
||||||
./target/release/kv_bench --path /home/abby/mace_bench --threads $i --iterations 100000 --mode insert --key-size ${kv_sz[j]} --value-size ${kv_sz[j+1]}
|
./target/release/kv_bench --path /home/abby/mace_bench --threads $i --iterations $cnt --mode insert --key-size ${kv_sz[j]} --value-size ${kv_sz[j+1]}
|
||||||
if test $? -ne 0
|
if test $? -ne 0
|
||||||
then
|
then
|
||||||
echo "insert threads $i ksz ${kv_sz[j]} vsz ${kv_sz[j+1]} fail"
|
echo "insert threads $i ksz ${kv_sz[j]} vsz ${kv_sz[j+1]} fail"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
./target/release/kv_bench --path /home/abby/mace_bench --threads $i --iterations 100000 --mode get --key-size ${kv_sz[j]} --value-size ${kv_sz[j+1]}
|
./target/release/kv_bench --path /home/abby/mace_bench --threads $i --iterations $cnt --mode get --key-size ${kv_sz[j]} --value-size ${kv_sz[j+1]}
|
||||||
if test $? -ne 0
|
if test $? -ne 0
|
||||||
then
|
then
|
||||||
echo "get threads $i ksz ${kv_sz[j]} vsz ${kv_sz[j+1]} fail"
|
echo "get threads $i ksz ${kv_sz[j]} vsz ${kv_sz[j+1]} fail"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
./target/release/kv_bench --path /home/abby/mace_bench --threads $i --iterations 100000 --mode mixed --key-size ${kv_sz[j]} --value-size ${kv_sz[j+1]} --insert-ratio 30
|
./target/release/kv_bench --path /home/abby/mace_bench --threads $i --iterations $cnt --mode mixed --key-size ${kv_sz[j]} --value-size ${kv_sz[j+1]} --insert-ratio 30
|
||||||
|
if test $? -ne 0
|
||||||
|
then
|
||||||
|
echo "mixed threads $i ksz ${kv_sz[j]} vsz ${kv_sz[j+1]} fail"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
./target/release/kv_bench --path /home/abby/mace_bench --threads $i --iterations $cnt --mode scan --key-size ${kv_sz[j]} --value-size ${kv_sz[j+1]} --insert-ratio 30
|
||||||
if test $? -ne 0
|
if test $? -ne 0
|
||||||
then
|
then
|
||||||
echo "mixed threads $i ksz ${kv_sz[j]} vsz ${kv_sz[j+1]} fail"
|
echo "mixed threads $i ksz ${kv_sz[j]} vsz ${kv_sz[j+1]} fail"
|
||||||
|
|||||||
BIN
scripts/mace_get.png
Normal file
|
After Width: | Height: | Size: 108 KiB |
BIN
scripts/mace_insert.png
Normal file
|
After Width: | Height: | Size: 131 KiB |
BIN
scripts/mace_mixed.png
Normal file
|
After Width: | Height: | Size: 133 KiB |
BIN
scripts/mace_scan.png
Normal file
|
After Width: | Height: | Size: 97 KiB |
@ -5,8 +5,12 @@ import sys
|
|||||||
|
|
||||||
def real_mode(m):
|
def real_mode(m):
|
||||||
if m == "mixed":
|
if m == "mixed":
|
||||||
return "MIXED (70% Get, 30% Insert)"
|
return "Mixed (70% Get, 30% Insert)"
|
||||||
return m.upper()
|
elif m == "get":
|
||||||
|
return "Random Get"
|
||||||
|
elif m == "scan":
|
||||||
|
return "Sequential Scan"
|
||||||
|
return m.capitalize()
|
||||||
|
|
||||||
name = sys.argv[1]
|
name = sys.argv[1]
|
||||||
prefix = name.split(".")[0]
|
prefix = name.split(".")[0]
|
||||||
|
|||||||
@ -6,26 +6,32 @@ cmake --preset release 1>/dev/null 2>/dev/null
|
|||||||
cmake --build --preset release 1>/dev/null 2>/dev/null
|
cmake --build --preset release 1>/dev/null 2>/dev/null
|
||||||
|
|
||||||
function samples() {
|
function samples() {
|
||||||
kv_sz=(16 16 100 1024 1024 1024)
|
kv_sz=(16 16 100 1024 1024 1024 16 10240)
|
||||||
# set -x
|
# set -x
|
||||||
|
cnt=10000
|
||||||
for ((i = 1; i <= $(nproc); i *= 2))
|
for ((i = 1; i <= $(nproc); i *= 2))
|
||||||
do
|
do
|
||||||
for ((j = 0; j < ${#kv_sz[@]}; j += 2))
|
for ((j = 0; j < ${#kv_sz[@]}; j += 2))
|
||||||
do
|
do
|
||||||
./build/release/rocksdb_bench --path /home/abby/rocksdb_tmp --threads $i --iterations 100000 --mode insert --key-size ${kv_sz[j]} --value-size ${kv_sz[j+1]}
|
./build/release/rocksdb_bench --path /home/abby/rocksdb_tmp --threads $i --iterations $cnt --mode insert --key-size ${kv_sz[j]} --value-size ${kv_sz[j+1]}
|
||||||
if test $? -ne 0
|
if test $? -ne 0
|
||||||
then
|
then
|
||||||
echo "insert threads $i ksz ${kv_sz[j]} vsz ${kv_sz[j+1]} fail"
|
echo "insert threads $i ksz ${kv_sz[j]} vsz ${kv_sz[j+1]} fail"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
./build/release/rocksdb_bench --path /home/abby/rocksdb_tmp --threads $i --iterations 100000 --mode get --key-size ${kv_sz[j]} --value-size ${kv_sz[j+1]}
|
./build/release/rocksdb_bench --path /home/abby/rocksdb_tmp --threads $i --iterations $cnt --mode get --key-size ${kv_sz[j]} --value-size ${kv_sz[j+1]}
|
||||||
if test $? -ne 0
|
if test $? -ne 0
|
||||||
then
|
then
|
||||||
echo "get threads $i ksz ${kv_sz[j]} vsz ${kv_sz[j+1]} fail"
|
echo "get threads $i ksz ${kv_sz[j]} vsz ${kv_sz[j+1]} fail"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
./build/release/rocksdb_bench --path /home/abby/rocksdb_tmp --threads $i --iterations 100000 --mode mixed --key-size ${kv_sz[j]} --value-size ${kv_sz[j+1]} --insert-ratio 30
|
./build/release/rocksdb_bench --path /home/abby/rocksdb_tmp --threads $i --iterations $cnt --mode mixed --key-size ${kv_sz[j]} --value-size ${kv_sz[j+1]} --insert-ratio 30
|
||||||
|
if test $? -ne 0
|
||||||
|
then
|
||||||
|
echo "mixed threads $i ksz ${kv_sz[j]} vsz ${kv_sz[j+1]} fail"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
./build/release/rocksdb_bench --path /home/abby/rocksdb_tmp --threads $i --iterations $cnt --mode scan --key-size ${kv_sz[j]} --value-size ${kv_sz[j+1]} --insert-ratio 30
|
||||||
if test $? -ne 0
|
if test $? -ne 0
|
||||||
then
|
then
|
||||||
echo "mixed threads $i ksz ${kv_sz[j]} vsz ${kv_sz[j+1]} fail"
|
echo "mixed threads $i ksz ${kv_sz[j]} vsz ${kv_sz[j+1]} fail"
|
||||||
|
|||||||
BIN
scripts/rocksdb_get.png
Normal file
|
After Width: | Height: | Size: 147 KiB |
BIN
scripts/rocksdb_insert.png
Normal file
|
After Width: | Height: | Size: 115 KiB |
BIN
scripts/rocksdb_mixed.png
Normal file
|
After Width: | Height: | Size: 128 KiB |
BIN
scripts/rocksdb_scan.png
Normal file
|
After Width: | Height: | Size: 105 KiB |
24
src/main.rs
@ -41,12 +41,15 @@ struct Args {
|
|||||||
|
|
||||||
#[arg(long, default_value = "false")]
|
#[arg(long, default_value = "false")]
|
||||||
random: bool,
|
random: bool,
|
||||||
|
|
||||||
|
#[arg(long, default_value = "8192")]
|
||||||
|
blob_size: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
{
|
{
|
||||||
Logger::init().add_file("/Data/x.log", true);
|
Logger::init().add_file("/tmp/x.log", true);
|
||||||
log::set_max_level(log::LevelFilter::Info);
|
log::set_max_level(log::LevelFilter::Info);
|
||||||
}
|
}
|
||||||
let args = Args::parse();
|
let args = Args::parse();
|
||||||
@ -76,10 +79,11 @@ fn main() {
|
|||||||
let mut keys: Vec<Vec<Vec<u8>>> = Vec::with_capacity(args.threads);
|
let mut keys: Vec<Vec<Vec<u8>>> = Vec::with_capacity(args.threads);
|
||||||
let mut opt = Options::new(path);
|
let mut opt = Options::new(path);
|
||||||
opt.sync_on_write = false;
|
opt.sync_on_write = false;
|
||||||
opt.tmp_store = args.mode != "get";
|
opt.over_provision = true; // large value will use lots of memeory
|
||||||
|
opt.inline_size = args.blob_size;
|
||||||
|
opt.tmp_store = args.mode != "get" && args.mode != "scan";
|
||||||
let mut saved = opt.clone();
|
let mut saved = opt.clone();
|
||||||
saved.tmp_store = false;
|
saved.tmp_store = false;
|
||||||
// opt.cache_capacity = 3 << 30; // this is very important for large key-value store
|
|
||||||
let mut db = Mace::new(opt.validate().unwrap()).unwrap();
|
let mut db = Mace::new(opt.validate().unwrap()).unwrap();
|
||||||
db.disable_gc();
|
db.disable_gc();
|
||||||
|
|
||||||
@ -92,13 +96,13 @@ fn main() {
|
|||||||
key.resize(args.key_size, b'x');
|
key.resize(args.key_size, b'x');
|
||||||
tk.push(key);
|
tk.push(key);
|
||||||
}
|
}
|
||||||
if args.random {
|
if args.random || args.mode == "get" {
|
||||||
tk.shuffle(&mut rng);
|
tk.shuffle(&mut rng);
|
||||||
}
|
}
|
||||||
keys.push(tk);
|
keys.push(tk);
|
||||||
}
|
}
|
||||||
|
|
||||||
if args.mode == "get" {
|
if args.mode == "get" || args.mode == "scan" {
|
||||||
let pre_tx = db.begin().unwrap();
|
let pre_tx = db.begin().unwrap();
|
||||||
(0..args.threads).for_each(|tid| {
|
(0..args.threads).for_each(|tid| {
|
||||||
for i in 0..args.iterations {
|
for i in 0..args.iterations {
|
||||||
@ -126,6 +130,7 @@ fn main() {
|
|||||||
let insert_ratio = args.insert_ratio;
|
let insert_ratio = args.insert_ratio;
|
||||||
let st = start_time.clone();
|
let st = start_time.clone();
|
||||||
let val = value.clone();
|
let val = value.clone();
|
||||||
|
let prefix = format!("key_{tid}");
|
||||||
|
|
||||||
std::thread::spawn(move || {
|
std::thread::spawn(move || {
|
||||||
// coreid::bind_core(tid);
|
// coreid::bind_core(tid);
|
||||||
@ -165,6 +170,13 @@ fn main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
"scan" => {
|
||||||
|
let view = db.view().unwrap();
|
||||||
|
let iter = view.seek(prefix);
|
||||||
|
for x in iter {
|
||||||
|
std::hint::black_box(x);
|
||||||
|
}
|
||||||
|
}
|
||||||
_ => panic!("Invalid mode"),
|
_ => panic!("Invalid mode"),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,7 +192,7 @@ fn main() {
|
|||||||
let test_start = start_time.lock().unwrap();
|
let test_start = start_time.lock().unwrap();
|
||||||
let duration = test_start.elapsed();
|
let duration = test_start.elapsed();
|
||||||
let total = total_ops.load(std::sync::atomic::Ordering::Relaxed);
|
let total = total_ops.load(std::sync::atomic::Ordering::Relaxed);
|
||||||
let ops = total as f64 / duration.as_secs_f64();
|
let ops = (total as f64 / duration.as_secs_f64()) as usize;
|
||||||
|
|
||||||
// println!("{:<20} {}", "Test Mode:", args.mode);
|
// println!("{:<20} {}", "Test Mode:", args.mode);
|
||||||
// println!("{:<20} {}", "Threads:", args.threads);
|
// println!("{:<20} {}", "Threads:", args.threads);
|
||||||
|
|||||||