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

Commit e1b445d

Browse files
committed
Add back in s10 memcached internal, fix memory settings in fxmark and maplat
1 parent 5452293 commit e1b445d

File tree

2 files changed

+184
-9
lines changed

2 files changed

+184
-9
lines changed

kernel/tests/s10_benchmarks.rs

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,171 @@ fn s10_leveldb_benchmark() {
832832
}
833833
}
834834

835+
#[test]
836+
fn s10_memcached_benchmark_internal() {
837+
setup_network(1);
838+
839+
let machine = Machine::determine();
840+
let build = BuildArgs::default()
841+
.module("rkapps")
842+
.user_feature("rkapps:memcached-bench")
843+
.release()
844+
.build();
845+
846+
let threads: Vec<usize> = machine
847+
.thread_defaults_uniform()
848+
.into_iter()
849+
// Throw out everything above 28 since we have some non-deterministic
850+
// bug on larger machines that leads to threads calling sched_yield and
851+
// no readrandom is performed...
852+
.filter(|&t| t <= 28)
853+
.collect();
854+
855+
// memcached arguments // currently not there.
856+
let (qemu_mem, memsize, queries, timeout) = if cfg!(feature = "smoke") {
857+
(16 * 1024 /* MB */, 16 /* MB */, 2000000, 300_000)
858+
} else {
859+
(
860+
128 * 1024, /* MB */
861+
32 * 1024, /* MB */
862+
50000000,
863+
600_000,
864+
)
865+
};
866+
867+
let file_name = "memcached_benchmark_internal.csv";
868+
let _r = std::fs::remove_file(file_name);
869+
870+
print!("threads: ");
871+
for thread in threads.iter() {
872+
print!("{thread} ");
873+
}
874+
println!();
875+
876+
for thread in threads.iter() {
877+
println!("Running memcached internal benchmark with {thread} threads, {queries} GETs and {memsize}MB memory. ");
878+
879+
let kernel_cmdline = format!(
880+
r#"init=memcachedbench.bin initargs={} appcmd='--x-benchmark-mem={} --x-benchmark-queries={}'"#,
881+
*thread, memsize, queries
882+
);
883+
884+
let cmdline = RunnerArgs::new_with_build("userspace-smp", &build)
885+
.timeout(timeout)
886+
.cores(machine.max_cores())
887+
.nodes(2)
888+
.use_virtio()
889+
.memory(qemu_mem)
890+
.setaffinity(Vec::new())
891+
.cmd(kernel_cmdline.as_str())
892+
.no_network_setup();
893+
894+
let mut output = String::new();
895+
let mut qemu_run = || -> Result<WaitStatus> {
896+
let mut dhcp_server = spawn_dhcpd()?;
897+
let mut p = spawn_nrk(&cmdline)?;
898+
899+
output += dhcp_server.exp_string(DHCP_ACK_MATCH)?.as_str();
900+
901+
// match the title
902+
let (prev, matched) = p.exp_regex(r#"INTERNAL BENCHMARK CONFIGURE"#)?;
903+
904+
output += prev.as_str();
905+
output += matched.as_str();
906+
907+
// x_benchmark_mem = 10 MB
908+
let (prev, matched) = p.exp_regex(r#"x_benchmark_mem = (\d+) MB"#)?;
909+
println!("> {}", matched);
910+
let b_mem = matched.replace("x_benchmark_mem = ", "").replace(" MB", "");
911+
912+
output += prev.as_str();
913+
output += matched.as_str();
914+
915+
// number of threads: 3
916+
let (prev, matched) = p.exp_regex(r#"number of threads: (\d+)"#)?;
917+
println!("> {}", matched);
918+
let b_threads = matched.replace("number of threads: ", "");
919+
920+
output += prev.as_str();
921+
output += matched.as_str();
922+
923+
// number of keys: 131072
924+
let (prev, matched) = p.exp_regex(r#"number of keys: (\d+)"#)?;
925+
println!("> {}", matched);
926+
927+
output += prev.as_str();
928+
output += matched.as_str();
929+
930+
let (prev, matched) = p.exp_regex(r#"Executing (\d+) queries with (\d+) threads"#)?;
931+
println!("> {}", matched);
932+
933+
output += prev.as_str();
934+
output += matched.as_str();
935+
936+
// benchmark took 129 seconds
937+
let (prev, matched) = p.exp_regex(r#"benchmark took (\d+) ms"#)?;
938+
println!("> {}", matched);
939+
let b_time = matched.replace("benchmark took ", "").replace(" ms", "");
940+
941+
output += prev.as_str();
942+
output += matched.as_str();
943+
944+
// benchmark took 7937984 queries / second
945+
let (prev, matched) = p.exp_regex(r#"benchmark took (\d+) queries / second"#)?;
946+
println!("> {}", matched);
947+
let b_thpt = matched
948+
.replace("benchmark took ", "")
949+
.replace(" queries / second", "");
950+
951+
output += prev.as_str();
952+
output += matched.as_str();
953+
954+
let (prev, matched) = p.exp_regex(r#"benchmark executed (\d+)"#)?;
955+
println!("> {}", matched);
956+
let b_queries = matched
957+
.replace("benchmark executed ", "")
958+
.split(' ')
959+
.next()
960+
.unwrap()
961+
.to_string();
962+
963+
output += prev.as_str();
964+
output += matched.as_str();
965+
966+
// Append parsed results to a CSV file
967+
let write_headers = !Path::new(file_name).exists();
968+
let mut csv_file = OpenOptions::new()
969+
.append(true)
970+
.create(true)
971+
.open(file_name)
972+
.expect("Can't open file");
973+
if write_headers {
974+
let row = "git_rev,benchmark,nthreads,mem,queries,time,thpt\n";
975+
let r = csv_file.write(row.as_bytes());
976+
assert!(r.is_ok());
977+
}
978+
979+
let r = csv_file.write(format!("{},", env!("GIT_HASH")).as_bytes());
980+
assert!(r.is_ok());
981+
let out = format!(
982+
"memcached,{},{},{},{},{}",
983+
b_threads, b_mem, b_queries, b_time, b_thpt,
984+
);
985+
let r = csv_file.write(out.as_bytes());
986+
assert!(r.is_ok());
987+
let r = csv_file.write("\n".as_bytes());
988+
assert!(r.is_ok());
989+
990+
// cleanup
991+
dhcp_server.send_control('c')?;
992+
p.process.kill(SIGTERM)?;
993+
p.process.exit()
994+
};
995+
996+
check_for_successful_exit(&cmdline, qemu_run(), output);
997+
}
998+
}
999+
8351000
/// Tests that basic pmem allocation support is functional.
8361001
/// TODO: Store persistent data durably and test it.
8371002
#[test]

kernel/tests/s11_rackscale_benchmarks.rs

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ fn rackscale_fxmark_benchmark(transport: RackscaleTransport) {
137137
if is_smoke {
138138
8192
139139
} else {
140-
8192 + 64 * num_cores
140+
2048 * (((num_cores + 3 - 1) / 3) * 3)
141141
}
142142
}
143143
let bench = RackscaleBench {
@@ -296,11 +296,15 @@ fn rackscale_vmops_benchmark(transport: RackscaleTransport, benchtype: VMOpsBenc
296296
fn rackscale_timeout_fn(num_cores: usize) -> u64 {
297297
240_000 + 500 * num_cores as u64
298298
}
299-
fn mem_fn(_num_cores: usize, is_smoke: bool) -> usize {
299+
fn mem_fn(num_cores: usize, is_smoke: bool) -> usize {
300300
if is_smoke {
301301
8192
302302
} else {
303-
24 * 1024
303+
if num_cores < 48 {
304+
24 * 1024
305+
} else {
306+
48 * 1024
307+
}
304308
}
305309
}
306310
let bench = RackscaleBench {
@@ -431,11 +435,13 @@ fn s11_rackscale_shmem_leveldb_benchmark() {
431435
}
432436

433437
fn mem_fn(num_cores: usize, is_smoke: bool) -> usize {
434-
if is_smoke {
438+
let mem_size = if is_smoke {
435439
8192
436440
} else {
437441
512 * num_cores + 4096
438-
}
442+
};
443+
// memory needs to be divisible by # of nodes, but we'll use cores for now
444+
mem_size - (mem_size % num_cores)
439445
}
440446

441447
let bench = RackscaleBench {
@@ -625,11 +631,13 @@ fn rackscale_memcached_benchmark(transport: RackscaleTransport) {
625631
}
626632

627633
fn mem_fn(num_cores: usize, is_smoke: bool) -> usize {
628-
if is_smoke {
634+
let mem_size = if is_smoke {
629635
8192
630636
} else {
631637
512 * num_cores + 8192
632-
}
638+
};
639+
// memory needs to be divisible by # of nodes, but we'll use cores for now
640+
mem_size - (mem_size % num_cores)
633641
}
634642

635643
let bench = RackscaleBench {
@@ -708,11 +716,13 @@ fn rackscale_monetdb_benchmark(transport: RackscaleTransport) {
708716
}
709717

710718
fn mem_fn(num_cores: usize, is_smoke: bool) -> usize {
711-
if is_smoke {
719+
let mem_size = if is_smoke {
712720
8192
713721
} else {
714722
512 * num_cores + 8192
715-
}
723+
};
724+
// memory needs to be divisible by # of nodes, but we'll use cores for now
725+
mem_size - (mem_size % num_cores)
716726
}
717727

718728
let bench = RackscaleBench {

0 commit comments

Comments
 (0)