@@ -25,8 +25,9 @@ use testutils::rackscale_runner::{RackscaleBench, RackscaleRun};
2525use testutils:: runner_args:: RackscaleTransport ;
2626
2727use testutils:: memcached:: {
28- parse_memcached_output, rackscale_memcached_checkout, MemcachedShardedConfig ,
29- MEMCACHED_MEM_SIZE_MB , MEMCACHED_NUM_QUERIES ,
28+ linux_spawn_memcached, parse_memcached_output, rackscale_memcached_checkout,
29+ MemcachedShardedConfig , MEMCACHED_MEM_SIZE_MB , MEMCACHED_NUM_QUERIES ,
30+ RACKSCALE_MEMCACHED_CSV_COLUMNS ,
3031} ;
3132
3233#[ test]
@@ -476,12 +477,12 @@ struct MemcachedInternalConfig {
476477
477478#[ test]
478479#[ cfg( not( feature = "baremetal" ) ) ]
479- fn s11_rackscale_memcached_benchmark_internal ( ) {
480- rackscale_memcached_benchmark ( RackscaleTransport :: Shmem ) ;
480+ fn s11_rackscale_shmem_memcached_internal_benchmark ( ) {
481+ rackscale_memcached_internal_benchmark ( RackscaleTransport :: Shmem ) ;
481482}
482483
483484#[ cfg( not( feature = "baremetal" ) ) ]
484- fn rackscale_memcached_benchmark ( transport : RackscaleTransport ) {
485+ fn rackscale_memcached_internal_benchmark ( transport : RackscaleTransport ) {
485486 let is_smoke = cfg ! ( feature = "smoke" ) ;
486487
487488 let file_name = format ! (
@@ -490,6 +491,11 @@ fn rackscale_memcached_benchmark(transport: RackscaleTransport) {
490491 ) ;
491492 let _ignore = std:: fs:: remove_file ( file_name. clone ( ) ) ;
492493
494+ let baseline_file_name = "rackscale_baseline_memcached_benchmark.csv" ;
495+ if cfg ! ( feature = "baseline" ) {
496+ let _ignore = std:: fs:: remove_file ( baseline_file_name. clone ( ) ) ;
497+ }
498+
493499 let built = BuildArgs :: default ( )
494500 . module ( "rkapps" )
495501 . user_feature ( "rkapps:memcached-bench" )
@@ -524,24 +530,32 @@ fn rackscale_memcached_benchmark(transport: RackscaleTransport) {
524530 . open ( file_name)
525531 . expect ( "Can't open file" ) ;
526532 if write_headers {
527- let row = "git_rev,benchmark,nthreads,mem,queries,time,thpt,num_clients,num_replicas\n " ;
528- let r = csv_file. write ( row. as_bytes ( ) ) ;
533+ let r = csv_file. write ( RACKSCALE_MEMCACHED_CSV_COLUMNS . as_bytes ( ) ) ;
529534 assert ! ( r. is_ok( ) ) ;
530535 }
531536
532- let actual_num_clients = if is_baseline { 0 } else { num_clients } ;
537+ let os_name = if is_baseline { "nros" } else { "dinos" } ;
538+ let protocol = if is_baseline {
539+ "internal"
540+ } else if file_name. contains ( & RackscaleTransport :: Ethernet . to_string ( ) ) {
541+ "tcp"
542+ } else {
543+ "shmem"
544+ } ;
533545
534546 let r = csv_file. write ( format ! ( "{}," , env!( "GIT_HASH" ) ) . as_bytes ( ) ) ;
535547 assert ! ( r. is_ok( ) ) ;
548+
536549 let out = format ! (
537- "memcached_internal,{},{},{},{},{},{},{}" ,
550+ "memcached_internal,{},{},{},{},{},{},{},{}" ,
551+ os_name,
552+ protocol,
553+ num_clients,
538554 ret. b_threads,
539555 ret. b_mem,
540556 ret. b_queries,
541557 ret. b_time,
542- ret. b_thpt,
543- actual_num_clients,
544- num_clients
558+ ret. b_thpt
545559 ) ;
546560 let r = csv_file. write ( out. as_bytes ( ) ) ;
547561 assert ! ( r. is_ok( ) ) ;
@@ -618,25 +632,25 @@ fn rackscale_memcached_benchmark(transport: RackscaleTransport) {
618632 }
619633 }
620634
621- let bench = RackscaleBench {
635+ let mut bench = RackscaleBench {
622636 test,
623637 cmd_fn,
624638 baseline_timeout_fn,
625639 rackscale_timeout_fn,
626640 mem_fn,
627641 } ;
628642
643+ bench. run_bench ( false , is_smoke) ;
644+
629645 if cfg ! ( feature = "baseline" ) {
646+ bench. test . file_name = baseline_file_name. to_string ( ) ;
630647 bench. run_bench ( true , is_smoke) ;
631648 }
632- bench. run_bench ( false , is_smoke) ;
633649}
634650
635651#[ test]
636652#[ cfg( not( feature = "baremetal" ) ) ]
637- fn s11_rackscale_memcached_benchmark_sharded_linux ( ) {
638- use std:: fs:: remove_file;
639-
653+ fn s11_linux_memcached_sharded_benchmark ( ) {
640654 use rexpect:: process:: signal:: Signal :: SIGKILL ;
641655
642656 let machine = Machine :: determine ( ) ;
@@ -684,86 +698,7 @@ fn s11_rackscale_memcached_benchmark_sharded_linux() {
684698 spawn_command ( command, Some ( timeout_ms) ) . expect ( "failed to spawn memcached" )
685699 }
686700
687- fn spawn_memcached (
688- id : usize ,
689- config : & MemcachedShardedConfig ,
690- timeout_ms : u64 ,
691- ) -> Result < PtySession > {
692- let con_info = if config. protocol == "tcp" {
693- format ! ( "tcp://localhost:{}" , 11212 + id)
694- } else {
695- let pathname = config. path . join ( format ! ( "memcached{id}.sock" ) ) ;
696- if pathname. is_file ( ) {
697- remove_file ( pathname. clone ( ) ) . expect ( "Failed to remove path" ) ; // make sure the socket file is removed
698- }
699- format ! ( "unix://{}" , pathname. display( ) )
700- } ;
701-
702- let mut command = Command :: new ( "bash" ) ;
703-
704- command. args ( & [
705- "scripts/spawn-memcached-process.sh" ,
706- id. to_string ( ) . as_str ( ) ,
707- con_info. as_str ( ) ,
708- ( 2 * config. mem_size ) . to_string ( ) . as_str ( ) ,
709- config. num_threads . to_string ( ) . as_str ( ) ,
710- ] ) ;
711- command. current_dir ( config. path . as_path ( ) ) ;
712-
713- println ! ( "Spawning memcached:\n $ `{:?}`" , command) ;
714-
715- let mut res = spawn_command ( command, Some ( timeout_ms) ) ?;
716- std:: thread:: sleep ( Duration :: from_secs ( 1 ) ) ;
717-
718- match res. exp_regex ( r#"INTERNAL BENCHMARK CONFIGURE"# ) {
719- Ok ( ( _prev, _matched) ) => {
720- println ! ( " $ OK." ) ;
721- Ok ( res)
722- }
723- Err ( e) => {
724- println ! ( " $ FAILED. {}" , e) ;
725- Err ( e)
726- }
727- }
728- }
729-
730- fn spawn_loadbalancer ( config : & MemcachedShardedConfig , timeout_ms : u64 ) -> Result < PtySession > {
731- let mut command = Command :: new ( "./loadbalancer/loadbalancer" ) ;
732- command. args ( & [ "--binary" ] ) ;
733- command. arg ( format ! ( "--num-queries={}" , config. num_queries) . as_str ( ) ) ;
734- command. arg ( format ! ( "--num-threads={}" , config. num_threads) . as_str ( ) ) ;
735- command. arg ( format ! ( "--max-memory={}" , config. mem_size) . as_str ( ) ) ;
736- let mut servers = String :: from ( "--servers=" ) ;
737- for i in 0 ..config. num_servers {
738- if i > 0 {
739- servers. push_str ( "," ) ;
740- }
741- if config. protocol == "tcp" {
742- if config. is_local_host {
743- servers. push_str ( format ! ( "tcp://localhost:{}" , 11212 + i) . as_str ( ) ) ;
744- } else {
745- // +1 because tap0 is reserved for the controller.
746- let ip = 10 + i + 1 ;
747- servers. push_str ( format ! ( "tcp://172.31.0.{}:{}" , ip, 11211 ) . as_str ( ) ) ;
748- }
749- } else {
750- servers. push_str (
751- format ! ( "unix://{}/memcached{}.sock" , config. path. display( ) , i) . as_str ( ) ,
752- ) ;
753- }
754- }
755- command. arg ( servers. as_str ( ) ) ;
756- command. current_dir ( config. path . as_path ( ) ) ;
757-
758- // give the servers some time to be spawned
759- std:: thread:: sleep ( Duration :: from_secs ( 5 ) ) ;
760-
761- println ! ( "Spawning Loadbalancer: \n $ `{:?}`" , command) ;
762-
763- spawn_command ( command, Some ( timeout_ms) )
764- }
765-
766- let file_name = "memcached_benchmark_sharded_linux.csv" ;
701+ let file_name = "linux_memcached_sharded_benchmark.csv" ;
767702 let _r = std:: fs:: remove_file ( file_name) ;
768703
769704 let mut csv_file = OpenOptions :: new ( )
@@ -772,8 +707,7 @@ fn s11_rackscale_memcached_benchmark_sharded_linux() {
772707 . open ( file_name)
773708 . expect ( "Can't open file" ) ;
774709
775- let row = "git_rev,benchmark,os,nthreads,protocol,mem,queries,time,thpt\n " ;
776- let r = csv_file. write ( row. as_bytes ( ) ) ;
710+ let r = csv_file. write ( RACKSCALE_MEMCACHED_CSV_COLUMNS . as_bytes ( ) ) ;
777711 assert ! ( r. is_ok( ) ) ;
778712
779713 let max_threads_per_node = if is_smoke {
@@ -806,9 +740,11 @@ fn s11_rackscale_memcached_benchmark_sharded_linux() {
806740 parse_memcached_output ( & mut pty, & mut output) . expect ( "could not parse output!" ) ;
807741 let r = csv_file. write ( format ! ( "{}," , env!( "GIT_HASH" ) ) . as_bytes ( ) ) ;
808742 assert ! ( r. is_ok( ) ) ;
743+
744+ //git_rev,benchmark,os,protocol,npieces,nthreads,mem,queries,time,thpt
809745 let out = format ! (
810- "memcached_sharded,linux,{},{},{},{},{},{}\n " ,
811- res . b_threads , "internal" , res. b_mem, res. b_queries, res. b_time, res. b_thpt,
746+ "memcached_sharded,linux,{},{},{},{},{},{},{} \n " ,
747+ "internal" , 1 , res . b_threads , res. b_mem, res. b_queries, res. b_time, res. b_thpt,
812748 ) ;
813749 let r = csv_file. write ( out. as_bytes ( ) ) ;
814750 assert ! ( r. is_ok( ) ) ;
@@ -834,22 +770,24 @@ fn s11_rackscale_memcached_benchmark_sharded_linux() {
834770 let mut memcached_ctrls = Vec :: new ( ) ;
835771 for i in 0 ..num_nodes {
836772 memcached_ctrls. push (
837- spawn_memcached ( i, & config, timeout_ms) . expect ( "could not spawn memcached" ) ,
773+ linux_spawn_memcached ( i, & config, timeout_ms)
774+ . expect ( "could not spawn memcached" ) ,
838775 ) ;
839776 }
840777
841- let mut pty =
842- spawn_loadbalancer ( & config , timeout_ms ) . expect ( "failed to spawn load balancer" ) ;
778+ let mut pty = testutils :: memcached :: spawn_loadbalancer ( & config , timeout_ms )
779+ . expect ( "failed to spawn load balancer" ) ;
843780 let mut output = String :: new ( ) ;
844781 use rexpect:: errors:: ErrorKind :: Timeout ;
845782 match parse_memcached_output ( & mut pty, & mut output) {
846783 Ok ( res) => {
847784 let r = csv_file. write ( format ! ( "{}," , env!( "GIT_HASH" ) ) . as_bytes ( ) ) ;
848785 assert ! ( r. is_ok( ) ) ;
849786 let out = format ! (
850- "memcached_sharded,linux,{},{},{},{},{},{}\n " ,
851- res. b_threads,
787+ "memcached_sharded,linux,{},{},{},{},{},{},{}\n " ,
852788 protocol,
789+ config. num_servers,
790+ res. b_threads,
853791 res. b_mem,
854792 res. b_queries,
855793 res. b_time,
@@ -876,8 +814,12 @@ fn s11_rackscale_memcached_benchmark_sharded_linux() {
876814 let r = csv_file. write ( format ! ( "{}," , env!( "GIT_HASH" ) ) . as_bytes ( ) ) ;
877815 assert ! ( r. is_ok( ) ) ;
878816 let out = format ! (
879- "memcached_sharded,linux,{},{},failure,failure,failure,failure\n " ,
880- config. num_servers, protocol,
817+ "memcached_sharded,linux,{},{},{},{},{},failure,failure\n " ,
818+ protocol,
819+ config. num_servers,
820+ config. num_threads * config. num_servers,
821+ config. mem_size,
822+ config. num_queries,
881823 ) ;
882824 let r = csv_file. write ( out. as_bytes ( ) ) ;
883825 assert ! ( r. is_ok( ) ) ;
@@ -940,6 +882,7 @@ fn s11_rackscale_memcached_benchmark_sharded_nros() {
940882 }
941883 } ;
942884
885+ // TODO: consolidate code with testutils::memcached::spawn_loadbalancer
943886 fn spawn_loadbalancer ( config : & MemcachedShardedConfig , timeout_ms : u64 ) -> Result < PtySession > {
944887 let mut command = Command :: new ( "./loadbalancer/loadbalancer" ) ;
945888 command. args ( & [ "--binary" ] ) ;
0 commit comments