-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6afab53
commit 45c8f56
Showing
9 changed files
with
538 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import subprocess | ||
from dataclasses import dataclass | ||
from typing import cast | ||
|
||
from data_schema import GraphEngine, demote | ||
from kernmlops_benchmark.benchmark import Benchmark, GenericBenchmarkConfig | ||
from kernmlops_benchmark.errors import ( | ||
BenchmarkNotInCollectionData, | ||
BenchmarkNotRunningError, | ||
BenchmarkRunningError, | ||
) | ||
from kernmlops_config import ConfigBase | ||
|
||
|
||
@dataclass(frozen=True) | ||
class MongoDbConfig(ConfigBase): | ||
operation_count: int = 1000000 | ||
read_proportion: float = 0.25 | ||
update_proportion: float = 0.75 | ||
|
||
|
||
class MongoDbBenchmark(Benchmark): | ||
|
||
@classmethod | ||
def name(cls) -> str: | ||
return "mongodb" | ||
|
||
@classmethod | ||
def default_config(cls) -> ConfigBase: | ||
return MongoDbConfig() | ||
|
||
@classmethod | ||
def from_config(cls, config: ConfigBase) -> "Benchmark": | ||
generic_config = cast(GenericBenchmarkConfig, getattr(config, "generic")) | ||
mongodb_config = cast(MongoDbConfig, getattr(config, cls.name())) | ||
return MongoDbBenchmark(generic_config=generic_config, config=mongodb_config) | ||
|
||
def __init__(self, *, generic_config: GenericBenchmarkConfig, config: MongoDbConfig): | ||
self.generic_config = generic_config | ||
self.config = config | ||
self.benchmark_dir = self.generic_config.get_benchmark_dir() / "ycsb" | ||
self.process: subprocess.Popen | None = None | ||
|
||
def is_configured(self) -> bool: | ||
return self.benchmark_dir.is_dir() | ||
|
||
def setup(self) -> None: | ||
if self.process is not None: | ||
raise BenchmarkRunningError() | ||
self.generic_config.generic_setup() | ||
|
||
def run(self) -> None: | ||
if self.process is not None: | ||
raise BenchmarkRunningError() | ||
|
||
self.process = subprocess.Popen( | ||
[ | ||
f"{self.benchmark_dir}/ycsb-0.17.0/bin/ycsb", | ||
"run", | ||
"mongodb", | ||
"-s", | ||
"-P", | ||
f"{self.benchmark_dir}/ycsb-0.17.0/workloads/workloada", | ||
"-p", | ||
f"operationcount={self.config.operation_count}", | ||
"-p", | ||
"mongodb.url=mongodb://localhost:27017/ycsb", | ||
"-p", | ||
f"readproportion={self.config.read_proportion}", | ||
"-p", | ||
f"updateproportion={self.config.update_proportion}", | ||
"-p", | ||
"mongodb.writeConcern=acknowledged" | ||
], | ||
preexec_fn=demote(), | ||
stdout=subprocess.DEVNULL, | ||
) | ||
|
||
def poll(self) -> int | None: | ||
if self.process is None: | ||
raise BenchmarkNotRunningError() | ||
return self.process.poll() | ||
|
||
def wait(self) -> None: | ||
if self.process is None: | ||
raise BenchmarkNotRunningError() | ||
self.process.wait() | ||
|
||
def kill(self) -> None: | ||
if self.process is None: | ||
raise BenchmarkNotRunningError() | ||
self.process.terminate() | ||
|
||
@classmethod | ||
def plot_events(cls, graph_engine: GraphEngine) -> None: | ||
if graph_engine.collection_data.benchmark != cls.name(): | ||
raise BenchmarkNotInCollectionData() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#Specify destination for benchmark | ||
YCSB_BENCHMARK_NAME="ycsb" | ||
BENCHMARK_DIR_NAME="kernmlops-benchmark" | ||
|
||
BENCHMARK_DIR="${BENCHMARK_DIR:-$HOME/$BENCHMARK_DIR_NAME}" | ||
YCSB_BENCHMARK_DIR="$BENCHMARK_DIR/$YCSB_BENCHMARK_NAME" | ||
|
||
if [ -d $YCSB_BENCHMARK_DIR ]; then | ||
echo "Benchmark already installed at: $YCSB_BENCHMARK_DIR" | ||
exit 0 | ||
fi | ||
|
||
# Setup | ||
mkdir -p "$YCSB_BENCHMARK_DIR" | ||
|
||
# Download YCSB | ||
curl -o "$YCSB_BENCHMARK_DIR/ycsb-0.17.0.tar.gz" --location https://github.com/brianfrankcooper/YCSB/releases/download/0.17.0/ycsb-0.17.0.tar.gz | ||
|
||
tar xfvz "$YCSB_BENCHMARK_DIR/ycsb-0.17.0.tar.gz" -C "$YCSB_BENCHMARK_DIR" | ||
|
||
pwd | ||
|
||
# Copy contents of ycsb_runner.py to bin/ycsb | ||
cp scripts/setup-benchmarks/ycsb_runner.py $YCSB_BENCHMARK_DIR/ycsb-0.17.0/bin/ycsb | ||
|
||
# Make the ycsb script executable | ||
chmod +x $YCSB_BENCHMARK_DIR/ycsb-0.17.0/bin/ycsb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
# Define variables first | ||
YCSB_BENCHMARK_NAME="ycsb" | ||
BENCHMARK_DIR_NAME="kernmlops-benchmark" | ||
BENCHMARK_DIR="${BENCHMARK_DIR:-$HOME/$BENCHMARK_DIR_NAME}" | ||
YCSB_BENCHMARK_DIR="$BENCHMARK_DIR/$YCSB_BENCHMARK_NAME" | ||
|
||
# Then use them | ||
if [ -d "$YCSB_BENCHMARK_DIR/mongo_db" ]; then | ||
echo "Directory $YCSB_BENCHMARK_DIR/mongo_db already exists." | ||
exit 0 | ||
fi | ||
mkdir -p "$YCSB_BENCHMARK_DIR/mongo_db" |
Oops, something went wrong.