@@ -33,7 +33,11 @@ use serde::Deserialize;
33
33
use slog:: Level ;
34
34
use slog_scope:: { debug, info, warn} ;
35
35
use thiserror:: Error ;
36
- use tokio:: { select, task:: JoinSet , time:: sleep} ;
36
+ use tokio:: {
37
+ select,
38
+ task:: JoinSet ,
39
+ time:: { sleep, Instant } ,
40
+ } ;
37
41
38
42
macro_rules! spin_while_waiting {
39
43
( $block: block, $timeout: expr, $wait_message: expr, $timeout_message: expr) => { {
@@ -711,9 +715,59 @@ async fn bootstrap_aggregator(
711
715
Ok ( aggregator)
712
716
}
713
717
718
+ struct Timing {
719
+ phase : String ,
720
+ duration : Duration ,
721
+ }
722
+
723
+ struct Reporter {
724
+ number_of_signers : usize ,
725
+ timings : Vec < Timing > ,
726
+ current_timing : Option < ( String , Instant ) > ,
727
+ }
728
+
729
+ impl Reporter {
730
+ fn new ( number_of_signers : usize ) -> Self {
731
+ Self {
732
+ number_of_signers,
733
+ timings : vec ! [ ] ,
734
+ current_timing : None ,
735
+ }
736
+ }
737
+
738
+ fn start ( & mut self , phase : & str ) {
739
+ self . current_timing = Some ( ( phase. to_owned ( ) , Instant :: now ( ) ) ) ;
740
+ }
741
+
742
+ fn stop ( & mut self ) {
743
+ match & self . current_timing {
744
+ Some ( ( phase, instant) ) => {
745
+ let timing = Timing {
746
+ phase : phase. clone ( ) ,
747
+ duration : instant. elapsed ( ) ,
748
+ } ;
749
+
750
+ self . timings . push ( timing) ;
751
+ self . current_timing = None ;
752
+ }
753
+ None => ( ) ,
754
+ }
755
+ }
756
+
757
+ fn print_report ( & self ) {
758
+ println ! ( "number_of_signers\t {}" , self . number_of_signers) ;
759
+ println ! ( "phase\t duration/ms" ) ;
760
+ for t in & self . timings {
761
+ println ! ( "{}\t {}" , t. phase, t. duration. as_millis( ) ) ;
762
+ }
763
+ }
764
+ }
765
+
714
766
#[ tokio:: main( flavor = "multi_thread" ) ]
715
767
async fn main ( ) -> StdResult < ( ) > {
716
768
let opts = MainOpts :: parse ( ) ;
769
+ let mut reporter: Reporter = Reporter :: new ( opts. num_signers ) ;
770
+ reporter. start ( "stress tests bootstrap" ) ;
717
771
// configure a dummy immutable db
718
772
let mut immutable_db = DummyImmutablesDbBuilder :: new ( "load-tester" )
719
773
. with_immutables ( & [ 1 , 2 , 3 ] )
@@ -726,6 +780,7 @@ async fn main() -> StdResult<()> {
726
780
let protocol_parameters = ProtocolParameters :: new ( 2422 , 20973 , 0.20 ) ;
727
781
info ! ( ">> Starting stress test with options: {opts:?}" ) ;
728
782
783
+ reporter. start ( "stress bootstrap" ) ;
729
784
info ! ( ">> Creation of the Signer Key Registrations payloads" ) ;
730
785
let signers_fixture = generate_signer_data ( opts. num_signers , protocol_parameters) ;
731
786
@@ -736,16 +791,19 @@ async fn main() -> StdResult<()> {
736
791
. await ?;
737
792
738
793
let mut aggregator = bootstrap_aggregator ( & args, & signers_fixture, & mut current_epoch) . await ?;
794
+ reporter. stop ( ) ;
739
795
740
796
info ! ( ">> Move one epoch forward in order to start creating certificates" ) ;
741
797
current_epoch += 1 ;
742
798
write_epoch ( & args. mock_epoch_file_path ( ) , current_epoch) ;
743
799
wait_for_epoch_settings_at_epoch ( & aggregator, Duration :: from_secs ( 10 ) , current_epoch) . await ?;
744
800
745
801
info ! ( ">> Send the Signer Key Registrations payloads" ) ;
802
+ reporter. start ( "signers registration" ) ;
746
803
let errors =
747
804
register_signers_to_aggregator ( & aggregator, & signers_fixture. signers ( ) , current_epoch + 1 )
748
805
. await ?;
806
+ reporter. stop ( ) ;
749
807
assert_eq ! ( 0 , errors) ;
750
808
751
809
info ! ( ">> Wait for pending certificate to be available" ) ;
@@ -755,12 +813,14 @@ async fn main() -> StdResult<()> {
755
813
">> Send the Signer Signatures payloads for MithrilStakeDistribution({:?})" ,
756
814
current_epoch
757
815
) ;
816
+ reporter. start ( "signatures registration" ) ;
758
817
let errors = register_signatures_to_aggregator (
759
818
& aggregator,
760
819
& mithril_stake_distribution_signatures,
761
820
SignedEntityType :: MithrilStakeDistribution ( current_epoch) ,
762
821
)
763
822
. await ?;
823
+ reporter. stop ( ) ;
764
824
assert_eq ! ( 0 , errors) ;
765
825
766
826
info ! ( ">> Wait for certificates to be available..." ) ;
@@ -789,12 +849,14 @@ async fn main() -> StdResult<()> {
789
849
">> Send the Signer Signatures payloads for CardanoImmutableFiles({:?})" ,
790
850
current_beacon
791
851
) ;
852
+ reporter. start ( "signatures registration" ) ;
792
853
let errors = register_signatures_to_aggregator (
793
854
& aggregator,
794
855
& immutable_files_signatures,
795
856
SignedEntityType :: CardanoImmutableFilesFull ( current_beacon) ,
796
857
)
797
858
. await ?;
859
+ reporter. stop ( ) ;
798
860
assert_eq ! ( 0 , errors) ;
799
861
800
862
info ! ( ">> Wait for certificates to be available..." ) ;
@@ -803,8 +865,11 @@ async fn main() -> StdResult<()> {
803
865
info ! ( ">> Wait for artifacts to be available..." ) ;
804
866
wait_for_immutable_files_artifacts ( & aggregator, Duration :: from_secs ( 30 ) ) . await ?;
805
867
806
- info ! ( ">> All steps executed successfully, stopping all tasks..." ) ;
868
+ info ! ( ">> Display execution timings:" ) ;
869
+ reporter. print_report ( ) ;
807
870
871
+ info ! ( ">> All steps executed successfully, stopping all tasks..." ) ;
808
872
aggregator. stop ( ) . await . unwrap ( ) ;
873
+
809
874
Ok ( ( ) )
810
875
}
0 commit comments