Skip to content

Commit

Permalink
[LevelDB] Add freshdb_for_each_run variable (open-s4c#51)
Browse files Browse the repository at this point in the history
Add `freshdb_for_each_run` bool variable. If False, has same behavior as
previously. Otherwise, on each run the database is reset and refilled
with data.

Additionally, changes the `num` variable for certain benchmarks
(fillseq, overwrite, etc), in order to avoid durations too variable
according to number of threads.
`num` now refers to the total number of operations done by *all
threads*. I.e., each thread runs `num // nb_threads` operations.

Signed-off-by: Rafael Chehab <[email protected]>
  • Loading branch information
rchehab authored Jul 17, 2024
1 parent 3476514 commit d917b2c
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions examples/leveldb/kit/leveldb.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def get_run_var_names() -> List[str]:
"lock",
"atomics",
"use_lse",
"freshdb_foreach_run",
]

@staticmethod
Expand Down Expand Up @@ -160,9 +161,23 @@ def single_run( # pylint: disable=arguments-differ
atomics: Optional[str] = None,
bench_name: str = "readrandom",
master_thread_core: Optional[int] = None,
num: int = 40000,
num: int = 1000000,
freshdb_foreach_run: bool = False,
**kwargs,
) -> str:
if freshdb_foreach_run:
db_init_command = [
"./db_bench",
"--threads=1",
"--benchmarks=fillseq",
f"--db={self._tmpdb_dir}",
]
self.platform.comm.shell(
command=db_init_command,
current_dir=self._build_dir,
print_output=False
)

environment = self._preload_env(
lock=lock,
use_lse=use_lse,
Expand All @@ -175,20 +190,19 @@ def single_run( # pylint: disable=arguments-differ
if bench_name in ["readrandom", "readmissing", "readhot", "seekrandom"]:
duration_num = f"--duration={benchmark_duration_seconds}"
else:
duration_num = f"--num={num}"
duration_num = f"--num={num // nb_threads}"


if bench_name in [
"fillseq",
"fillrandom",
"fillsync",
"fill100K",
]:
# TODO these benchmarks require different logic for the previously created database
raise NotImplementedError(
f'LevelDB benchmark named "{bench_name}" is not currently supported.'
)
use_existing_db = False
else:
use_existing_db = True

use_existing_db = True

run_command = [
"./db_bench",
Expand Down Expand Up @@ -248,6 +262,7 @@ def leveldb_campaign(
use_lse: Iterable[bool] = (),
atomics: Iterable[str] = (),
nb_threads: Iterable[int] = (1,),
freshdb_foreach_run: Iterable[bool] = (False,),
debug: bool = False,
gdb: bool = False,
enable_data_dir: bool = False,
Expand All @@ -264,6 +279,7 @@ def leveldb_campaign(
"atomics": atomics,
"nb_threads": nb_threads,
"bench_name": bench_name,
"freshdb_foreach_run": freshdb_foreach_run,
}
if pretty is not None:
pretty = {"lock": pretty}
Expand Down

0 comments on commit d917b2c

Please sign in to comment.