Compare commits

..

6 Commits

Author SHA1 Message Date
7448a39eef
share iterations among threads 2025-12-20 16:12:34 +08:00
67f7108399
fix rocksdb test code 2025-12-19 19:51:14 +08:00
11ea5a1569
use snapshot for scan in rocksdb 2025-11-23 10:07:30 +08:00
90788721b2
update config 2025-11-22 16:41:22 +08:00
d5a9b1552a
fix rocksdb iteration calc 2025-11-22 16:00:50 +08:00
5917f83af2
change to hot scan 2025-11-21 17:56:07 +08:00
18 changed files with 61 additions and 78 deletions

View File

@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2024"
[dependencies]
mace-kv = "0.0.24"
mace-kv = { git = "https://github.com/abbycin/mace" }
clap = { version = "4.5.48", features = ["derive"] }
rand = "0.9.2"
log = "0.4.22"

View File

@ -1,20 +1,13 @@
# mace 0.0.24 vs rocksdb 10.4.2
# mace 0.0.19
**mace 0.0.24 traded a slight dip in query performance for a 10+% boost in insertion performance.**
## insert performance
![mace_insert](./scripts/mace_insert.png)
## sequential insert
![mace_sequential_insert](./scripts/mace_sequential_insert.png)
![rocksdb_sequential_insert](./scripts/rocksdb_sequential_insert.png)
## random insert
![mace_random_insert](./scripts/mace_random_insert.png)
![rocksdb_random_insert](./scripts/rocksdb_random_insert.png)
![rocksdb_insert](./scripts/rocksdb_insert.png)
---
## random get (warm get)
## random get performance (cold get)
![mace_get](./scripts/mace_get.png)
@ -28,7 +21,7 @@
![rockdb_mixed](./scripts/rocksdb_mixed.png)
# sequential scan (warm scan)
# sequential scan perfomance (cold scan)
![mace_scan](./scripts/mace_scan.png)

View File

@ -111,12 +111,8 @@ int main(int argc, char *argv[]) {
rocksdb::ColumnFamilyOptions cfo{};
cfo.enable_blob_files = true;
cfo.min_blob_size = args.blob_size;
// rocksdb::BlockBasedTableOptions top{};
// top.use_delta_encoding = false;
// cfo.table_factory.reset(rocksdb::NewBlockBasedTableFactory(top));
// use 3GB block cache
auto cache = rocksdb::NewLRUCache(3 << 30);
// 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));
@ -254,7 +250,6 @@ int main(int argc, char *argv[]) {
delete kv;
}
} else if (args.mode == "scan") {
// ropt.pin_data = true;
auto *iter = db->NewIterator(ropt);
iter->Seek(prefix);
size_t n = 0;
@ -282,13 +277,6 @@ int main(int argc, char *argv[]) {
return args.mode == "insert" ? 100 : 0;
}();
uint64_t ops = total_op.load(std::memory_order_relaxed) / b.elapse_sec();
if (args.mode == "insert") {
if (args.random) {
args.mode = "random_insert";
} else {
args.mode = "sequential_insert";
}
}
fmt::println("{},{},{},{},{},{},{}", args.mode, args.threads, args.key_size, args.value_size, ratio, (uint64_t) ops,
(uint64_t) b.elapse_ms());
db->ReleaseSnapshot(snapshot);

View File

@ -2,8 +2,8 @@
if [ "$#" -ne 1 ]
then
printf "\033[m$0 path\033[0m\n"
exit 1
printf "\033[m$0 path\033[0m\n"
exit 1
fi
pushd .
@ -13,7 +13,6 @@ cargo build --release 1>/dev/null 2> /dev/null
function samples() {
export RUST_BACKTRACE=full
kv_sz=(16 16 100 1024 1024 1024 16 10240)
mode=(insert get mixed scan)
# set -x
db_root=$1
@ -22,24 +21,30 @@ function samples() {
do
for ((j = 0; j < ${#kv_sz[@]}; j += 2))
do
for ((k = 0; k < ${#mode[@]}; k += 1))
do
if [ "${mode[k]}" == "insert" ]
then
./target/release/kv_bench --path $db_root --threads $i --iterations $cnt --mode ${mode[k]} --key-size ${kv_sz[j]} --value-size ${kv_sz[j+1]} --random
if test $? -ne 0
then
echo "${mode[k]} threads $i ksz ${kv_sz[j]} vsz ${kv_sz[j+1]} random fail"
exit 1
fi
fi
./target/release/kv_bench --path $db_root --threads $i --iterations $cnt --mode ${mode[k]} --key-size ${kv_sz[j]} --value-size ${kv_sz[j+1]}
if test $? -ne 0
then
echo "${mode[k]} threads $i ksz ${kv_sz[j]} vsz ${kv_sz[j+1]} fail"
exit 1
fi
done
./target/release/kv_bench --path $db_root --threads $i --iterations $cnt --mode insert --key-size ${kv_sz[j]} --value-size ${kv_sz[j+1]}
if test $? -ne 0
then
echo "insert threads $i ksz ${kv_sz[j]} vsz ${kv_sz[j+1]} fail"
exit 1
fi
./target/release/kv_bench --path $db_root --threads $i --iterations $cnt --mode get --key-size ${kv_sz[j]} --value-size ${kv_sz[j+1]}
if test $? -ne 0
then
echo "get threads $i ksz ${kv_sz[j]} vsz ${kv_sz[j+1]} fail"
exit 1
fi
./target/release/kv_bench --path $db_root --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 $db_root --threads $i --iterations $cnt --mode scan --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
done
done
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 137 KiB

After

Width:  |  Height:  |  Size: 134 KiB

BIN
scripts/mace_insert.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 131 KiB

After

Width:  |  Height:  |  Size: 131 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 127 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 151 KiB

After

Width:  |  Height:  |  Size: 149 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 121 KiB

View File

@ -13,7 +13,6 @@ cmake --build --preset release 1>/dev/null 2>/dev/null
function samples() {
kv_sz=(16 16 100 1024 1024 1024 16 10240)
mode=(insert get mixed scan)
# set -x
db_root=$1
cnt=100000
@ -21,24 +20,30 @@ function samples() {
do
for ((j = 0; j < ${#kv_sz[@]}; j += 2))
do
for ((k = 0; k < ${#mode[@]}; k += 1))
do
if [ "${mode[k]}" == "insert" ]
then
./build/release/rocksdb_bench --path $db_root --threads $i --iterations $cnt --mode ${mode[k]} --key-size ${kv_sz[j]} --value-size ${kv_sz[j+1]} --random 1
if test $? -ne 0
then
echo "${mode[k]} threads $i ksz ${kv_sz[j]} vsz ${kv_sz[j+1]} random fail"
exit 1
fi
fi
./build/release/rocksdb_bench --path $db_root --threads $i --iterations $cnt --mode ${mode[k]} --key-size ${kv_sz[j]} --value-size ${kv_sz[j+1]}
if test $? -ne 0
then
echo "${mode[k]} threads $i ksz ${kv_sz[j]} vsz ${kv_sz[j+1]} fail"
exit 1
fi
done
./build/release/rocksdb_bench --path $db_root --threads $i --iterations $cnt --mode insert --key-size ${kv_sz[j]} --value-size ${kv_sz[j+1]}
if test $? -ne 0
then
echo "insert threads $i ksz ${kv_sz[j]} vsz ${kv_sz[j+1]} fail"
exit 1
fi
./build/release/rocksdb_bench --path $db_root --threads $i --iterations $cnt --mode get --key-size ${kv_sz[j]} --value-size ${kv_sz[j+1]}
if test $? -ne 0
then
echo "get threads $i ksz ${kv_sz[j]} vsz ${kv_sz[j+1]} fail"
exit 1
fi
./build/release/rocksdb_bench --path $db_root --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 $db_root --threads $i --iterations $cnt --mode scan --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
done
done
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 135 KiB

After

Width:  |  Height:  |  Size: 138 KiB

BIN
scripts/rocksdb_insert.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 140 KiB

After

Width:  |  Height:  |  Size: 128 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 125 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 115 KiB

After

Width:  |  Height:  |  Size: 116 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 126 KiB

View File

@ -52,7 +52,7 @@ fn main() {
Logger::init().add_file("/tmp/x.log", true);
log::set_max_level(log::LevelFilter::Info);
}
let mut args = Args::parse();
let args = Args::parse();
let path = Path::new(&args.path);
@ -82,7 +82,6 @@ fn main() {
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";
opt.cache_capacity = 3 << 30;
let mut saved = opt.clone();
saved.tmp_store = false;
let mut db = Mace::new(opt.validate().unwrap()).unwrap();
@ -218,13 +217,6 @@ fn main() {
} else {
0
};
if args.mode == "insert" {
if args.random {
args.mode = "random_insert".into();
} else {
args.mode = "sequential_insert".into();
}
}
eprintln!(
"{},{},{},{},{},{},{}",
args.mode,