Skip to content
This repository was archived by the owner on Jul 17, 2025. It is now read-only.

Commit 0b5cad5

Browse files
committed
tests: wait until clients are up before spawning servers
Signed-off-by: Reto Achermann <achreto@gmail.com>
1 parent dd9c2de commit 0b5cad5

File tree

1 file changed

+51
-17
lines changed

1 file changed

+51
-17
lines changed

kernel/tests/s11_rackscale_benchmarks.rs

Lines changed: 51 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,7 @@ fn rackscale_memcached_benchmark(transport: RackscaleTransport) {
664664
struct MemcachedShardedConfig {
665665
pub num_servers: usize,
666666
pub num_queries: usize,
667+
pub is_local_host: bool,
667668
pub mem_size: usize,
668669
pub protocol: &'static str,
669670
pub num_threads: usize,
@@ -815,6 +816,7 @@ fn rackscale_memcached_benchmark_sharded(is_shmem: bool) {
815816
num_queries: 100_000,
816817
mem_size: 16,
817818
protocol: "tcp",
819+
is_local_host: true,
818820
num_threads: 4,
819821
path: out_dir_path,
820822
}
@@ -825,6 +827,7 @@ fn rackscale_memcached_benchmark_sharded(is_shmem: bool) {
825827
num_queries: 100_000_000,
826828
mem_size: 128 * 1024,
827829
protocol: "tcp",
830+
is_local_host: true,
828831
num_threads: 4,
829832
path: out_dir_path,
830833
}
@@ -863,7 +866,8 @@ fn rackscale_memcached_benchmark_sharded(is_shmem: bool) {
863866
fn spawn_loadbalancer(
864867
config: Option<&MemcachedShardedConfig>,
865868
timeout_ms: u64,
866-
) -> PtySession {
869+
) -> Result<PtySession> {
870+
println!("SPAWN LOADBALANCER!");
867871
let config = config.unwrap();
868872
let mut command = Command::new("./loadbalancer/loadbalancer");
869873
command.args(&["--binary"]);
@@ -876,15 +880,24 @@ fn rackscale_memcached_benchmark_sharded(is_shmem: bool) {
876880
servers.push_str(",");
877881
}
878882
if config.protocol == "tcp" {
879-
servers.push_str(format!("tcp://localhost:{}", 11211 + i).as_str());
883+
if config.is_local_host {
884+
servers.push_str(format!("tcp://localhost:{}", 11211 + i).as_str());
885+
} else {
886+
let ip = 10 + i;
887+
servers.push_str(format!("tcp://172.31.0.{}:{}", ip, 11211).as_str());
888+
}
889+
880890
} else {
881891
servers.push_str(format!("unix://memcached{}.sock", i).as_str());
882892
}
883893
}
884894
command.arg(servers.as_str());
885895
command.current_dir(config.path.as_path());
886896

887-
spawn_command(command, Some(timeout_ms)).expect("failed to spawn load balancer")
897+
// give the servers some time to be spawned
898+
std::thread::sleep(Duration::from_secs(2 * config.num_servers as u64));
899+
900+
spawn_command(command, Some(timeout_ms))
888901
}
889902

890903
let file_name = "memcached_benchmark_sharded.csv";
@@ -896,7 +909,7 @@ fn rackscale_memcached_benchmark_sharded(is_shmem: bool) {
896909
.open(file_name)
897910
.expect("Can't open file");
898911

899-
let row = "git_rev,benchmark,nthreads,protocol,mem,queries,time,thpt\n";
912+
let row = "git_rev,benchmark,os,nthreads,protocol,mem,queries,time,thpt\n";
900913
let r = csv_file.write(row.as_bytes());
901914
assert!(r.is_ok());
902915

@@ -915,7 +928,7 @@ fn rackscale_memcached_benchmark_sharded(is_shmem: bool) {
915928
let r = csv_file.write(format!("{},", env!("GIT_HASH")).as_bytes());
916929
assert!(r.is_ok());
917930
let out = format!(
918-
"memcached_sharded,{},{},{},{},{},{}\n",
931+
"memcached_sharded,linux,{},{},{},{},{},{}\n",
919932
res.b_threads, "internal", res.b_mem, res.b_queries, res.b_time, res.b_thpt,
920933
);
921934
let r = csv_file.write(out.as_bytes());
@@ -934,14 +947,14 @@ fn rackscale_memcached_benchmark_sharded(is_shmem: bool) {
934947
spawn_memcached(i.to_string().as_str(), &config, timeout_ms);
935948
}
936949

937-
let mut pty = spawn_loadbalancer(Some(&config), timeout_ms);
950+
let mut pty = spawn_loadbalancer(Some(&config), timeout_ms).expect("failed to spawn load balancer");
938951
let mut output = String::new();
939952
let res = parse_memcached_output(&mut pty, &mut output);
940953

941954
let r = csv_file.write(format!("{},", env!("GIT_HASH")).as_bytes());
942955
assert!(r.is_ok());
943956
let out = format!(
944-
"memcached_sharded,{},{},{},{},{},{}\n",
957+
"memcached_sharded,linux,{},{},{},{},{},{}\n",
945958
res.b_threads, protocol, res.b_mem, res.b_queries, res.b_time, res.b_thpt,
946959
);
947960
let r = csv_file.write(out.as_bytes());
@@ -963,21 +976,40 @@ fn rackscale_memcached_benchmark_sharded(is_shmem: bool) {
963976
.release()
964977
.build();
965978

966-
fn controller_match_fn(
967-
proc: &mut PtySession,
968-
output: &mut String,
969-
_cores_per_client: usize,
970-
num_clients: usize,
971-
file_name: &str,
972-
is_baseline: bool,
973-
arg: Option<MemcachedShardedConfig>,
974-
) -> Result<()> {
979+
fn controller_run_fun(
980+
config: Option<&MemcachedShardedConfig>,
981+
timeout_ms: u64,
982+
) -> Result<PtySession> {
975983
// here we should wait
976-
Ok(())
984+
std::thread::sleep(Duration::from_secs(5));
985+
spawn_loadbalancer(config, timeout_ms)
977986
}
978987

988+
// fn client_match_fn(
989+
// proc: &mut PtySession,
990+
// output: &mut String,
991+
// cores_per_client: usize,
992+
// num_clients: usize,
993+
// file_name: &str,
994+
// is_baseline: bool,
995+
// arg: Option<T>,
996+
// ) -> Result<()>
997+
// {
998+
// let (prev, matched) = p.exp_regex(r#"x_benchmark_mem = (\d+) MB"#).unwrap();
999+
// println!("> {}", matched);
1000+
// let b_mem = matched.replace("x_benchmark_mem = ", "").replace(" MB", "");
1001+
1002+
// *output += prev.as_str();
1003+
// *output += matched.as_str();
1004+
// Ok(())
1005+
// }
1006+
1007+
config.is_local_host = false;
1008+
9791009
let mut test = RackscaleRun::new("userspace-smp".to_string(), built);
9801010
test.controller_match_fn = controller_match_fn;
1011+
test.controller_run_fn = Some(controller_run_fun);
1012+
// test.client_match_fn = client_match_fn;
9811013
test.use_qemu_huge_pages = cfg!(feature = "affinity-shmem");
9821014
test.file_name = file_name.to_string();
9831015
test.arg = Some(config);
@@ -1009,6 +1041,8 @@ fn rackscale_memcached_benchmark_sharded(is_shmem: bool) {
10091041
}
10101042
}
10111043

1044+
println!("----------------------------------------------------------");
1045+
10121046
// construct bench and run it!
10131047
let bench = RackscaleBench {
10141048
test,

0 commit comments

Comments
 (0)