Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
32 changes: 32 additions & 0 deletions packages/ucache_bench/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import os
import pathlib
import subprocess
import threading
from typing import List, Optional


Expand Down Expand Up @@ -144,6 +145,19 @@ def run_cmd(
return ""


def profile_server() -> None:
"""Record a system-wide perf profile for 5 seconds.

Skips if perf.data already exists.
"""
if os.path.exists("perf.data"):
return
print("DCPERF_PERF_RECORD=1, starting perf record...")
subprocess.run(
["perf", "record", "-a", "-g", "-o", "perf.data", "--", "sleep", "5"]
)


def run_server(args: argparse.Namespace) -> None:
"""Run the UcacheBench server.

Expand Down Expand Up @@ -255,9 +269,18 @@ def run_server(args: argparse.Namespace) -> None:
if args.verbose:
server_cmd.append("--verbose=true")

if "DCPERF_PERF_RECORD" in os.environ and os.environ["DCPERF_PERF_RECORD"] == "1":
delay = args.perf_record_delay
print(f"DCPERF_PERF_RECORD=1, will start perf record after {delay}s delay")
t_prof = threading.Timer(delay, profile_server)
t_prof.start()

stdout = run_cmd(server_cmd, timeout=None, for_real=args.real)
print(stdout)

if "DCPERF_PERF_RECORD" in os.environ and os.environ["DCPERF_PERF_RECORD"] == "1":
t_prof.cancel()


def run_client(args: argparse.Namespace) -> None:
"""Run the UcacheBench client.
Expand Down Expand Up @@ -541,6 +564,15 @@ def init_parser() -> argparse.ArgumentParser:
help="Timeout in seconds for waiting for clients (0 = no timeout)",
)

# Profiling configuration
server_parser.add_argument(
"--perf-record-delay",
type=int,
default=120,
help="Delay in seconds before starting perf record (when DCPERF_PERF_RECORD=1). "
"Should account for client startup and warmup time.",
)

server_parser.add_argument(
"--verbose", action="store_true", help="Enable verbose logging"
)
Expand Down
5 changes: 5 additions & 0 deletions packages/ucache_bench/server/UcacheBenchServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ void UcacheBenchServer::setupCacheLib() {
cacheConfig.setAccessConfig(
{config_.hash_power, config_.hashtable_lock_power});

// Configure number of CacheLib shards if specified
if (config_.cachelib_num_shards > 0) {
cacheConfig.setNumShards(config_.cachelib_num_shards);
}

// Generate alloc sizes (factor 1.25, min allocation size)
// This provides a good distribution of allocation classes for cache items
// Max alloc size increased to 64KB to support production traffic distribution
Expand Down
Loading