Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memcached Benchmark #48

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ RUN apt update -y \
flex \
libelf-dev \
bison \
netcat-openbsd \
nmap \
&& apt clean

# Install MongoDB
Expand All @@ -61,7 +63,11 @@ RUN apt-get update && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*


# Install memcached
RUN apt-get update && \
apt-get install -y \
memcached && \
apt-get clean

# Base development image
FROM ${BUILD_IMAGE} AS dev
Expand Down
28 changes: 28 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ INTERACTIVE ?= i
COLLECTION_BENCHMARK ?= faux
BENCHMARK_DIR ?= /home/${UNAME}/kernmlops-benchmark
YCSB_BENCHMARK_DIR ?= ${BENCHMARK_DIR}/ycsb
MEMCACHED_PORT=11211
anish-palakurthi marked this conversation as resolved.
Show resolved Hide resolved

# Provisioning variables
PROVISIONING_USER ?= ${UNAME}
Expand Down Expand Up @@ -125,6 +126,33 @@ load-mongodb:
-p recordcount=1000000 \
-p mongodb.url=mongodb://localhost:27017/ycsb

start-memcached:
@echo "Starting memcached server..."
@memcached -d -l 0.0.0.0 -p $(MEMCACHED_PORT) -u root
@sleep 2
@echo "Verifying memcached is running..."
@if pgrep memcached > /dev/null; then \
echo "Memcached process found"; \
# netstat -nltp | grep $(MEMCACHED_PORT); \
else \
echo "Failed to start memcached"; \
exit 1; \
fi

benchmark-memcached:
@${MAKE} start-memcached
@python python/kernmlops collect -v \
-c ${KERNMLOPS_CONFIG_FILE} \
--benchmark memcached

load-memcached:
anish-palakurthi marked this conversation as resolved.
Show resolved Hide resolved
@echo "Loading memcached benchmark"
@${MAKE} start-memcached
@python $(YCSB_BENCHMARK_DIR)/ycsb-0.17.0/bin/ycsb load memcached -s \
-P "$(YCSB_BENCHMARK_DIR)/ycsb-0.17.0/workloads/workloada" \
-p recordcount=1000000 \
-p memcached.hosts=localhost:$(MEMCACHED_PORT)

benchmark-linux-build:
@python python/kernmlops collect -v \
-c ${KERNMLOPS_CONFIG_FILE} \
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ make collect
make docker
make load-mongodb # Run this command only the first time you set up the MongoDB benchmark
make benchmark-mongodb
# Run memcached benchmark inside docker
make docker
make load-memcached
make benchmark-memcached

```

Expand Down
4 changes: 4 additions & 0 deletions defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ benchmark_config:
device_0: /dev/nvme0n1
device_1: /dev/nvme1n1
device_2: /dev/nvme2n1
memcached:
operation_count: 1000000
read_proportion: 0.99
update_proportion: 0.01
collector_config:
generic:
poll_rate: 0.5
Expand Down
5 changes: 5 additions & 0 deletions python/kernmlops/kernmlops_benchmark/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from kernmlops_benchmark.gap import GapBenchmark
from kernmlops_benchmark.linnos import LinnosBenchmark
from kernmlops_benchmark.linux_build import LinuxBuildBenchmark
from kernmlops_benchmark.memcached import MemcachedBenchmark
from kernmlops_benchmark.mongodb import MongoDbBenchmark
from kernmlops_config import ConfigBase

Expand All @@ -24,6 +25,8 @@
GapBenchmark.name(): GapBenchmark,
MongoDbBenchmark.name(): MongoDbBenchmark,
LinnosBenchmark.name(): LinnosBenchmark,
MemcachedBenchmark.name(): MemcachedBenchmark,

}

BenchmarkConfig = make_dataclass(
Expand Down Expand Up @@ -54,5 +57,7 @@
"LinnosBenchmark",
"LinuxBuildBenchmark",
"GapBenchmark",
"MongoDbBenchmark",
"MemcachedBenchmark",
"benchmarks",
]
104 changes: 104 additions & 0 deletions python/kernmlops/kernmlops_benchmark/memcached.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
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 MemcachedConfig(ConfigBase):
operation_count: int = 1000000
read_proportion: float = 0.99
update_proportion: float = 0.01


class MemcachedBenchmark(Benchmark):
anish-palakurthi marked this conversation as resolved.
Show resolved Hide resolved

@classmethod
def name(cls) -> str:
return "memcached"

@classmethod
def default_config(cls) -> ConfigBase:
return MemcachedConfig()

@classmethod
def from_config(cls, config: ConfigBase) -> "Benchmark":
generic_config = cast(GenericBenchmarkConfig, getattr(config, "generic"))
memcached_config = cast(MemcachedConfig, getattr(config, cls.name()))
return MemcachedBenchmark(generic_config=generic_config, config=memcached_config)

def __init__(self, *, generic_config: GenericBenchmarkConfig, config: MemcachedConfig):
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",
"memcached",
"-s",
"-P",
f"{self.benchmark_dir}/ycsb-0.17.0/workloads/workloada",
"-p",
f"operationcount={self.config.operation_count}",
"-p",
"memcached.hosts=localhost:11211",
"-p",
f"readproportion={self.config.read_proportion}",
"-p",
f"updateproportion={self.config.update_proportion}",
"-p",
"insertproportion=0",
"-p",
"scanproportion=0",
"-p",
"readmodifywriteproportion=0",
"-p",
"requestdistribution=zipfian"

],
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()