Skip to content

Commit

Permalink
Merge pull request pmem#47 from karczex/remove_fix
Browse files Browse the repository at this point in the history
Remove fix
  • Loading branch information
lukaszstolarczuk authored Jan 13, 2021
2 parents 1da5630 + 0a6cdeb commit ae0a7e0
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
3 changes: 2 additions & 1 deletion Dockerfile.ubuntu-20.04
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2016-2020, Intel Corporation
# Copyright 2016-2021, Intel Corporation

FROM ubuntu:20.04
MAINTAINER [email protected]

RUN apt update && \
DEBIAN_FRONTEND=noninteractive apt install -y --no-install-recommends \
libpmemkv-dev \
libpmempool-dev \
make \
g++ \
pkg-config \
Expand Down
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright 2017-2020, Intel Corporation
# Copyright 2017-2021, Intel Corporation

.ONESHELL:

bench: CFLAGS = $(shell pkg-config --cflags libpmemkv) -DOS_LINUX -fno-builtin-memcmp -march=native -DNDEBUG -O2 -std=c++11
bench: LDFLAGS = -ldl -lpthread $(shell pkg-config --libs libpmemkv)
bench: CFLAGS = $(shell pkg-config --cflags libpmemkv libpmempool) -DOS_LINUX -fno-builtin-memcmp -march=native -DNDEBUG -O2 -std=c++11
bench: LDFLAGS = -ldl -lpthread $(shell pkg-config --libs libpmemkv libpmempool)
CPP_FILES = $(shell find . -iname "*.h" -o -iname "*.cc" -o -iname "*.cpp" -o -iname "*.hpp")

.PHONY: cppformat $(CPP_FILES)

bench: reset
g++ ./bench/db_bench.cc ./bench/port/port_posix.cc ./bench/util/env.cc ./bench/util/env_posix.cc ./bench/util/histogram.cc ./bench/util/logging.cc ./bench/util/status.cc ./bench/util/testutil.cc -o pmemkv_bench -I./bench/include -I./bench -I./bench/util $(CFLAGS) $(LDFLAGS)

reset:
rm -rf /dev/shm/pmemkv /tmp/pmemkv

clean: reset
rm -rf pmemkv_bench

bench: reset
g++ ./bench/db_bench.cc ./bench/port/port_posix.cc ./bench/util/env.cc ./bench/util/env_posix.cc ./bench/util/histogram.cc ./bench/util/logging.cc ./bench/util/status.cc ./bench/util/testutil.cc -o pmemkv_bench -I./bench/include -I./bench -I./bench/util $(CFLAGS) $(LDFLAGS)

run_bench: bench
PMEM_IS_PMEM_FORCE=1 ./pmemkv_bench --db=/dev/shm/pmemkv --db_size_in_gb=1 --histogram=1

Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ The `pmemkv_bench` utility provides some standard read & write benchmarks. This
based on the `db_bench` utility included with LevelDB and RocksDB, although the
list of supported parameters is slightly different.

The `pmemkv-bench` may clear or remove pool passed in `--db` parameter, so pool, poolset or DAX
device which contain existing data shouldn't be used.

To build `pmemkv_bench`:

```
Expand Down
18 changes: 11 additions & 7 deletions bench/db_bench.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// (found in the LICENSE file in the root directory).

// SPDX-License-Identifier: Apache-2.0
// Copyright 2017-2020, Intel Corporation
// Copyright 2017-2021, Intel Corporation

#include <chrono>
#include <cstdio>
Expand All @@ -24,6 +24,7 @@
#include "histogram.h"
#include "leveldb/env.h"
#include "libpmemkv.hpp"
#include "libpmempool.h"
#include "mutexlock.h"
#include "port/port_posix.h"
#include "random.h"
Expand All @@ -35,7 +36,7 @@ static const std::string USAGE =
"--db=<location> (path to persistent pool, default: /dev/shm/pmemkv)\n"
" (note: file on DAX filesystem, DAX device, or poolset file)\n"
"--db_size_in_gb=<integer> (size of persistent pool to create in GB, default: 0)\n"
" (note: always use 0 with existing poolset or device DAX configs)\n"
" (note: for existing poolset or device DAX configs use 0 or leave default value)\n"
" (note: when pool path is non-existing, value should be > 0)\n"
"--histogram=<0|1> (show histograms when reporting latencies)\n"
"--num=<integer> (number of keys to place in database, default: 1000000)\n"
Expand Down Expand Up @@ -696,12 +697,15 @@ class Benchmark {
delete kv_;
kv_ = NULL;
}
if (FLAGS_db_size_in_gb > 0) {
auto start = g_env->NowMicros();
std::remove(FLAGS_db);
logger.insert(name, "Remove [millis millis/op]",
((g_env->NowMicros() - start) * 1e-3));
auto start = g_env->NowMicros();
/* Remove pool file. This should be
* implemented using libpmempool for backward
* compatibility. */
if (pmempool_rm(FLAGS_db, PMEMPOOL_RM_FORCE) != 0) {
throw std::runtime_error(std::string("Cannot remove pool: ") + FLAGS_db);
}
logger.insert(name, "Remove [millis millis/op]",
((g_env->NowMicros() - start) * 1e-3));
}

kv_ = new pmem::kv::db;
Expand Down

0 comments on commit ae0a7e0

Please sign in to comment.