diff options
author | William R. Otte <wotte@dre.vanderbilt.edu> | 2006-07-24 15:50:21 +0000 |
---|---|---|
committer | William R. Otte <wotte@dre.vanderbilt.edu> | 2006-07-24 15:50:21 +0000 |
commit | 3aff90f4a822fcf5d902bbfbcc9fa931d6191a8c (patch) | |
tree | 197c810e5f5bce17b1233a7cb8d7b50c0bcd25e2 /TAO/performance-tests/Protocols | |
parent | 6b846cf03c0bcbd8c276cb0af61a181e5f98eaae (diff) | |
download | ATCD-3aff90f4a822fcf5d902bbfbcc9fa931d6191a8c.tar.gz |
Repo restructuring
Diffstat (limited to 'TAO/performance-tests/Protocols')
17 files changed, 2291 insertions, 0 deletions
diff --git a/TAO/performance-tests/Protocols/Makefile.am b/TAO/performance-tests/Protocols/Makefile.am new file mode 100644 index 00000000000..81c6a7eadb9 --- /dev/null +++ b/TAO/performance-tests/Protocols/Makefile.am @@ -0,0 +1,139 @@ +## Process this file with automake to create Makefile.in +## +## $Id$ +## +## This file was generated by MPC. Any changes made directly to +## this file will be lost the next time it is generated. +## +## MPC Command: +## ../bin/mwc.pl -type automake -noreldefs TAO.mwc + +ACE_BUILDDIR = $(top_builddir)/.. +ACE_ROOT = $(top_srcdir)/.. +TAO_BUILDDIR = $(top_builddir) +TAO_IDL = ACE_ROOT=$(ACE_ROOT) TAO_ROOT=$(TAO_ROOT) $(TAO_BUILDDIR)/TAO_IDL/tao_idl +TAO_IDL_DEP = $(TAO_BUILDDIR)/TAO_IDL/tao_idl +TAO_IDLFLAGS = -Ge 1 -Wb,pre_include=ace/pre.h -Wb,post_include=ace/post.h -I$(TAO_ROOT) -I$(srcdir) -g $(ACE_BUILDDIR)/apps/gperf/src/gperf +TAO_ROOT = $(top_srcdir) + +noinst_PROGRAMS = + +## Makefile.Protocols_IDL.am + +BUILT_SOURCES = \ + testC.cpp \ + testC.h \ + testC.inl \ + testS.cpp \ + testS.h \ + testS.inl + +CLEANFILES = \ + test-stamp \ + testC.cpp \ + testC.h \ + testC.inl \ + testS.cpp \ + testS.h \ + testS.inl + +testC.cpp testC.h testC.inl testS.cpp testS.h testS.inl: test-stamp + +test-stamp: $(srcdir)/test.idl $(TAO_IDL_DEP) + $(TAO_IDL) $(TAO_IDLFLAGS) -Sa -St $(srcdir)/test.idl + @touch $@ + + +noinst_HEADERS = \ + test.idl + +## Makefile.Protocols_Distributor.am + +if BUILD_RT_CORBA + +noinst_PROGRAMS += distributor + +distributor_CPPFLAGS = \ + -I$(ACE_ROOT) \ + -I$(ACE_BUILDDIR) \ + -I$(TAO_ROOT) \ + -I$(TAO_BUILDDIR) + +distributor_SOURCES = \ + distributor.cpp \ + testC.cpp \ + testS.cpp + +distributor_LDADD = \ + $(TAO_BUILDDIR)/tao/libTAO_RTPortableServer.la \ + $(TAO_BUILDDIR)/tao/libTAO_RTCORBA.la \ + $(TAO_BUILDDIR)/tao/libTAO_PortableServer.la \ + $(TAO_BUILDDIR)/tao/libTAO_PI.la \ + $(TAO_BUILDDIR)/tao/libTAO_CodecFactory.la \ + $(TAO_BUILDDIR)/tao/libTAO_AnyTypeCode.la \ + $(TAO_BUILDDIR)/tao/libTAO.la \ + $(ACE_BUILDDIR)/ace/libACE.la + +endif BUILD_RT_CORBA + +## Makefile.Protocols_Receiver.am + +if !BUILD_ACE_FOR_TAO + +noinst_PROGRAMS += receiver + +receiver_CPPFLAGS = \ + -I$(ACE_ROOT) \ + -I$(ACE_BUILDDIR) \ + -I$(TAO_ROOT) \ + -I$(TAO_BUILDDIR) + +receiver_SOURCES = \ + receiver.cpp \ + testC.cpp \ + testS.cpp + +receiver_LDADD = \ + $(TAO_BUILDDIR)/tao/libTAO_PortableServer.la \ + $(TAO_BUILDDIR)/tao/libTAO_AnyTypeCode.la \ + $(TAO_BUILDDIR)/tao/libTAO.la \ + $(ACE_BUILDDIR)/ace/libACE.la + +endif !BUILD_ACE_FOR_TAO + +## Makefile.Protocols_Sender.am + +if BUILD_RT_CORBA +if !BUILD_ACE_FOR_TAO + +noinst_PROGRAMS += sender + +sender_CPPFLAGS = \ + -I$(ACE_ROOT) \ + -I$(ACE_BUILDDIR) \ + -I$(TAO_ROOT) \ + -I$(TAO_BUILDDIR) \ + -I$(srcdir)/../../tests/RTCORBA/Diffserv + +sender_SOURCES = \ + sender.cpp \ + testC.cpp + +sender_LDADD = \ + $(TAO_BUILDDIR)/tao/libTAO_RTCORBA.la \ + $(TAO_BUILDDIR)/tao/libTAO_PI.la \ + $(TAO_BUILDDIR)/tao/libTAO_CodecFactory.la \ + $(TAO_BUILDDIR)/tao/libTAO_AnyTypeCode.la \ + $(TAO_BUILDDIR)/tao/libTAO.la \ + $(ACE_BUILDDIR)/ace/libACE.la + +endif !BUILD_ACE_FOR_TAO +endif BUILD_RT_CORBA + +## Clean up template repositories, etc. +clean-local: + -rm -f *~ *.bak *.rpo *.sym lib*.*_pure_* core core.* + -rm -f gcctemp.c gcctemp so_locations *.ics + -rm -rf cxx_repository ptrepository ti_files + -rm -rf templateregistry ir.out + -rm -rf ptrepository SunWS_cache Templates.DB diff --git a/TAO/performance-tests/Protocols/Protocols.mpc b/TAO/performance-tests/Protocols/Protocols.mpc new file mode 100644 index 00000000000..f5a235aa7de --- /dev/null +++ b/TAO/performance-tests/Protocols/Protocols.mpc @@ -0,0 +1,52 @@ +// -*- MPC -*- +// $Id$ + +project(*IDL): taoidldefaults { + IDL_Files { + test.idl + } + custom_only = 1 +} + +project(*Receiver): taoserver { + avoids += ace_for_tao + after += *IDL + exename = receiver + Source_Files { + receiver.cpp + testS.cpp + testC.cpp + } + IDL_Files { + } +} + +project(*Distributor): rt_server { + after += *IDL + exename = distributor + Source_Files { + distributor.cpp + testS.cpp + testC.cpp + } + IDL_Files { + } +} + +project(*Sender): rt_client { + avoids += ace_for_tao + after += *IDL + + specific (automake ) { + includes += $(srcdir)/../../tests/RTCORBA/Diffserv + } else { + includes += ../../tests/RTCORBA/Diffserv + } + + Source_Files { + sender.cpp + testC.cpp + } + IDL_Files { + } +} diff --git a/TAO/performance-tests/Protocols/altq.conf b/TAO/performance-tests/Protocols/altq.conf new file mode 100644 index 00000000000..b0755750527 --- /dev/null +++ b/TAO/performance-tests/Protocols/altq.conf @@ -0,0 +1,10 @@ +# +# priority queue configuration for fxp2 (100Mbps ethernet) +# tos 80: high priority +# others: low priority +# +interface fxp2 bandwidth 100M priq + +class priq fxp2 high_class NULL priority 15 + filter fxp2 high_class 0 0 0 0 0 tos 80 tosmask 0xfc +class priq fxp2 low_class NULL priority 0 default red diff --git a/TAO/performance-tests/Protocols/distributor.cpp b/TAO/performance-tests/Protocols/distributor.cpp new file mode 100644 index 00000000000..5a7ad1c1735 --- /dev/null +++ b/TAO/performance-tests/Protocols/distributor.cpp @@ -0,0 +1,455 @@ +// $Id$ + +#include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_unistd.h" +#include "tao/RTCORBA/RTCORBA.h" +#include "tao/ORB_Constants.h" +#include "tao/debug.h" +#include "testS.h" + +static const char *ior_file = "distributor.ior"; +static const char *ior = "file://receiver.ior"; +static int number_of_connection_attempts = 20; + +static int +parse_args (int argc, char **argv) +{ + ACE_Get_Opt get_opts (argc, argv, "f:k:"); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'k': + ior = get_opts.opt_arg (); + break; + + case 'f': + ior_file = get_opts.opt_arg (); + break; + + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s\n" + "\t-f <ior_file> (defaults to %s)\n" + "\t-k <ior> (defaults to %s)\n" + "\n", + argv[0], + ior_file, + ior), + -1); + } + + return 0; +} + +class test_i : + public POA_test +{ +public: + test_i (CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + RTCORBA::RTORB_ptr rtorb, + CORBA::PolicyManager_ptr policy_manager, + test_ptr receiver); + + ~test_i (void); + + void start_test (CORBA::Long session_id, + const char *protocol, + CORBA::ULong invocation_rate, + CORBA::ULong message_size, + CORBA::ULong iterations + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + void end_test (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + void oneway_sync (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + void twoway_sync (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + void oneway_method (CORBA::Long session_id, + CORBA::ULong iteration, + const ::test::octets &payload + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + void twoway_method (CORBA::Long &session_id, + CORBA::ULong &iteration, + ::test::octets &payload + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + void shutdown (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + PortableServer::POA_ptr _default_POA (ACE_ENV_SINGLE_ARG_DECL); + +private: + CORBA::ORB_var orb_; + PortableServer::POA_var poa_; + RTCORBA::RTORB_var rtorb_; + CORBA::PolicyManager_var policy_manager_; + test_var receiver_; + + CORBA::PolicyList base_protocol_policy_; + CORBA::PolicyList test_protocol_policy_; +}; + +test_i::test_i (CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + RTCORBA::RTORB_ptr rtorb, + CORBA::PolicyManager_ptr policy_manager, + test_ptr receiver) + : orb_ (CORBA::ORB::_duplicate (orb)), + poa_ (PortableServer::POA::_duplicate (poa)), + rtorb_ (RTCORBA::RTORB::_duplicate (rtorb)), + policy_manager_ (CORBA::PolicyManager::_duplicate (policy_manager)), + receiver_ (test::_duplicate (receiver)) +{ + // Base protocol is used for setting up and tearing down the test. + this->base_protocol_policy_.length (1); + + // Test protocol is the one being tested. + this->test_protocol_policy_.length (1); + + RTCORBA::ProtocolList protocols; + protocols.length (1); + protocols[0].transport_protocol_properties = + RTCORBA::ProtocolProperties::_nil (); + protocols[0].orb_protocol_properties = + RTCORBA::ProtocolProperties::_nil (); + + // IIOP is always used for the base protocol. + protocols[0].protocol_type = 0; + + // User decides the test protocol. + this->base_protocol_policy_[0] = + this->rtorb_->create_client_protocol_policy (protocols); +} + +test_i::~test_i (void) +{ +} + +void +test_i::start_test (CORBA::Long session_id, + const char *protocol, + CORBA::ULong invocation_rate, + CORBA::ULong message_size, + CORBA::ULong iterations + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + RTCORBA::ProtocolList protocols; + protocols.length (1); + protocols[0].transport_protocol_properties = + RTCORBA::ProtocolProperties::_nil (); + protocols[0].orb_protocol_properties = + RTCORBA::ProtocolProperties::_nil (); + + if (ACE_OS::strcmp (protocol, "DIOP") == 0) + { + if (TAO_debug_level) ACE_DEBUG ((LM_DEBUG, "test protocol is DIOP\n")); + protocols[0].protocol_type = TAO_TAG_DIOP_PROFILE; + } + else if (ACE_OS::strcmp (protocol, "SCIOP") == 0) + { + if (TAO_debug_level) ACE_DEBUG ((LM_DEBUG, "test protocol is SCIOP\n")); + protocols[0].protocol_type = TAO_TAG_SCIOP_PROFILE; + } + else + { + if (TAO_debug_level) ACE_DEBUG ((LM_DEBUG, "test protocol is IIOP\n")); + protocols[0].protocol_type = 0; + } + + this->test_protocol_policy_[0] = + this->rtorb_->create_client_protocol_policy (protocols); + + // Make sure we have a connection to the server using the test + // protocol. + this->policy_manager_->set_policy_overrides (this->test_protocol_policy_, + CORBA::SET_OVERRIDE + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // Since the network maybe unavailable temporarily, make sure to try + // for a few times before giving up. + for (int j = 0;;) + { + + test_protocol_setup: + + ACE_TRY_EX (B1) + { + // Send a message to ensure that the connection is setup. + this->receiver_->oneway_sync (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK_EX (B1); + + goto test_protocol_success; + } + ACE_CATCH (CORBA::TRANSIENT, exception) + { + ++j; + + if (j < number_of_connection_attempts) + { + ACE_OS::sleep (1); + goto test_protocol_setup; + } + } + ACE_ENDTRY; + + ACE_ERROR ((LM_ERROR, + "Cannot setup test protocol\n")); + + ACE_THROW (CORBA::TRANSIENT (CORBA::OMGVMCID | 2, + CORBA::COMPLETED_NO)); + } + + test_protocol_success: + + // Use IIOP for setting up the test since the test protocol maybe + // unreliable. + this->policy_manager_->set_policy_overrides (this->base_protocol_policy_, + CORBA::SET_OVERRIDE + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // Since the network maybe unavailable temporarily, make sure to try + // for a few times before giving up. + for (int k = 0;;) + { + + base_protocol_setup: + + ACE_TRY_EX (B2) + { + // Let the server know what to expect.. + this->receiver_->start_test (session_id, + protocol, + invocation_rate, + message_size, + iterations + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK_EX (B2); + + goto base_protocol_success; + } + ACE_CATCH (CORBA::TRANSIENT, exception) + { + ACE_OS::sleep (1); + + if (k < number_of_connection_attempts) + { + ACE_OS::sleep (1); + goto base_protocol_setup; + } + } + ACE_ENDTRY; + + ACE_ERROR ((LM_ERROR, + "Cannot setup base protocol\n")); + + ACE_THROW (CORBA::TRANSIENT (CORBA::OMGVMCID | 2, + CORBA::COMPLETED_NO)); + } + + base_protocol_success: + + // Select the test protocol for these invocation. + this->policy_manager_->set_policy_overrides (this->test_protocol_policy_, + CORBA::SET_OVERRIDE + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +void +test_i::end_test (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // Use IIOP to indicate end of test to server. + this->policy_manager_->set_policy_overrides (this->base_protocol_policy_, + CORBA::SET_OVERRIDE + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + this->receiver_->end_test (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; +} + +void +test_i::oneway_sync (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + this->receiver_->oneway_sync (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; +} + +void +test_i::twoway_sync (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + this->receiver_->twoway_sync (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; +} + +void +test_i::oneway_method (CORBA::Long session_id, + CORBA::ULong iteration, + const ::test::octets &payload + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + this->receiver_->oneway_method (session_id, + iteration, + payload + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +void +test_i::twoway_method (CORBA::Long &session_id, + CORBA::ULong &iteration, + ::test::octets &payload + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + this->receiver_->twoway_method (session_id, + iteration, + payload + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +PortableServer::POA_ptr +test_i::_default_POA (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +{ + return PortableServer::POA::_duplicate (this->poa_.in ()); +} + +void +test_i::shutdown (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + this->receiver_->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + this->orb_->shutdown (0 + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +int +main (int argc, char **argv) +{ + ACE_TRY_NEW_ENV + { + CORBA::ORB_var orb = + CORBA::ORB_init (argc, + argv, + 0 + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::Object_var object = + orb->resolve_initial_references ("RTORB" + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + RTCORBA::RTORB_var rtorb = + RTCORBA::RTORB::_narrow (object.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + object = + orb->resolve_initial_references ("ORBPolicyManager" + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::PolicyManager_var policy_manager = + CORBA::PolicyManager::_narrow (object.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + int parse_args_result = + parse_args (argc, argv); + if (parse_args_result != 0) + return parse_args_result; + + object = + orb->resolve_initial_references ("RootPOA" + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + PortableServer::POA_var root_poa = + PortableServer::POA::_narrow (object.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + PortableServer::POAManager_var poa_manager = + root_poa->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + object = + orb->string_to_object (ior + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + test_var receiver = + test::_narrow (object.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + test_i *servant = + new test_i (orb.in (), + root_poa.in (), + rtorb.in (), + policy_manager.in (), + receiver.in ()); + PortableServer::ServantBase_var safe_servant (servant); + ACE_UNUSED_ARG (safe_servant); + + test_var test = + servant->_this (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::String_var ior = + orb->object_to_string (test.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + FILE *output_file = + ACE_OS::fopen (ior_file, "w"); + ACE_ASSERT (output_file != 0); + + u_int result = + ACE_OS::fprintf (output_file, + "%s", + ior.in ()); + ACE_ASSERT (result == ACE_OS::strlen (ior.in ())); + ACE_UNUSED_ARG (result); + + ACE_OS::fclose (output_file); + + poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + orb->run (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Exception caught"); + return -1; + } + ACE_ENDTRY; + + return 0; +} diff --git a/TAO/performance-tests/Protocols/lksctp_params.conf b/TAO/performance-tests/Protocols/lksctp_params.conf new file mode 100644 index 00000000000..45205a956f5 --- /dev/null +++ b/TAO/performance-tests/Protocols/lksctp_params.conf @@ -0,0 +1,9 @@ +PREFIX= +association_max_retrans=25 +hb_interval=10 +max_init_retransmits=25 +path_max_retrans=0 +rto_max=10 +rto_initial=10 +rto_min=10 +SETTINGS="association_max_retrans hb_interval max_init_retransmits path_max_retrans rto_min rto_max rto_initial" diff --git a/TAO/performance-tests/Protocols/receiver.cpp b/TAO/performance-tests/Protocols/receiver.cpp new file mode 100644 index 00000000000..586fab9059b --- /dev/null +++ b/TAO/performance-tests/Protocols/receiver.cpp @@ -0,0 +1,420 @@ +// $Id$ + +#include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_string.h" +#include "ace/Sample_History.h" +#include "ace/High_Res_Timer.h" +#include "ace/Stats.h" +#include "tao/debug.h" +#include "testS.h" + +static const char *ior_file = "receiver.ior"; +static int do_dump_history = 0; +static int print_missed_invocations = 0; +static ACE_UINT32 gsf = 0; + +static int +parse_args (int argc, char **argv) +{ + ACE_Get_Opt get_opts (argc, argv, "d:f:m:"); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'd': + do_dump_history = ACE_OS::atoi (get_opts.opt_arg ()); + break; + + case 'f': + ior_file = get_opts.opt_arg (); + break; + + case 'm': + print_missed_invocations = ACE_OS::atoi (get_opts.opt_arg ()); + break; + + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s\n" + "\t-d <show history> (defaults to %d)\n" + "\t-f <ior_file> (defaults to %s)\n" + "\t-m <print missed invocations for paced workers> (defaults to %d)\n" + "\n", + argv[0], + do_dump_history, + ior_file, + print_missed_invocations), + -1); + } + + return 0; +} + +class test_i : + public POA_test +{ +public: + test_i (CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa); + + ~test_i (void); + + void start_test (CORBA::Long session_id, + const char *protocol, + CORBA::ULong invocation_rate, + CORBA::ULong message_size, + CORBA::ULong iterations + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + void end_test (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + void oneway_sync (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + void twoway_sync (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + void oneway_method (CORBA::Long session_id, + CORBA::ULong iteration, + const ::test::octets &payload + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + void twoway_method (CORBA::Long &session_id, + CORBA::ULong &iteration, + ::test::octets &payload + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + void shutdown (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + PortableServer::POA_ptr _default_POA (ACE_ENV_SINGLE_ARG_DECL); + +private: + CORBA::ORB_var orb_; + PortableServer::POA_var poa_; + typedef ACE_Array_Base<CORBA::Boolean> Invocations; + Invocations invocations_received_; + ACE_hrtime_t time_of_last_call_; + ACE_hrtime_t test_start_; + ACE_hrtime_t test_end_; + CORBA::Boolean first_invocation_; + ACE_Sample_History *inter_arrival_times_; + CORBA::ULong iterations_; + CORBA::ULong number_of_invocations_received_; + CORBA::Long session_id_; +}; + +test_i::test_i (CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa) + : orb_ (CORBA::ORB::_duplicate (orb)), + poa_ (PortableServer::POA::_duplicate (poa)), + inter_arrival_times_ (0), + iterations_ (0), + session_id_ (-1) +{ +} + +test_i::~test_i (void) +{ +} + +void +test_i::start_test (CORBA::Long session_id, + const char *protocol, + CORBA::ULong invocation_rate, + CORBA::ULong message_size, + CORBA::ULong iterations + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + if (TAO_debug_level > 0) + { + ACE_DEBUG ((LM_DEBUG, + "Session id starts %d\n", + session_id)); + + } + + ACE_DEBUG ((LM_DEBUG, + "Protocol = %5s Invocation Rate = %3d Message Size = %5d Expected Latency = %4d ", + protocol, + invocation_rate, + message_size, + 1000 / invocation_rate)); + + // Remember test parameters. + this->session_id_ = session_id; + this->iterations_ = iterations; + this->number_of_invocations_received_ = 0; + + // + // Initialize counters and tables. + // + this->inter_arrival_times_ = + new ACE_Sample_History (iterations); + + this->first_invocation_ = 1; + + this->invocations_received_.size (iterations); + for (CORBA::ULong i = 0; + i < iterations; + ++i) + this->invocations_received_[i] = 0; + + // Record start time. + this->test_start_ = + ACE_OS::gethrtime (); +} + +void +test_i::end_test (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // Record end time. + this->test_end_ = + ACE_OS::gethrtime (); + + if (do_dump_history) + { + this->inter_arrival_times_->dump_samples ("Inter-arrival times", gsf); + } + + ACE_Basic_Stats stats; + this->inter_arrival_times_->collect_basic_stats (stats); + + ACE_DEBUG ((LM_DEBUG, + "Max Latency = %6d ", + stats.max_ / gsf / 1000)); + + ACE_DEBUG ((LM_DEBUG, + "Invocations expected / received / missed / missed %% = %6d / %6d / %6d / %5.2f\n", + this->iterations_, + this->number_of_invocations_received_, + this->iterations_ - this->number_of_invocations_received_, + (this->iterations_ - this->number_of_invocations_received_) / (double) this->iterations_ * 100)); + + if (print_missed_invocations) + { + ACE_DEBUG ((LM_DEBUG, "\nFollowing invocations were never received:\n")); + + for (CORBA::ULong i = 0; + i < this->iterations_; + ++i) + { + if (this->invocations_received_[i] == 0) + { + ACE_DEBUG ((LM_DEBUG, + "%d ", + i)); + } + } + + ACE_DEBUG ((LM_DEBUG, "\n")); + } + + if (TAO_debug_level > 0) + { + ACE_DEBUG ((LM_DEBUG, + "Session id ends %d\n", + this->session_id_)); + + stats.dump_results ("Inter-arrival times", gsf); + + ACE_Throughput_Stats::dump_throughput ("Inter-arrival times", gsf, + this->test_end_ - this->test_start_, + stats.samples_count ()); + } + + this->session_id_ = -1; + + delete this->inter_arrival_times_; +} + +void +test_i::oneway_sync (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ +} + +void +test_i::twoway_sync (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ +} + +void +test_i::oneway_method (CORBA::Long session_id, + CORBA::ULong iteration, + const ::test::octets &payload + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + if (this->session_id_ != session_id) + { + ACE_DEBUG ((LM_DEBUG, + "Late message with iteration id = %d: will not count message\n", + iteration)); + return; + } + + if (TAO_debug_level > 0) + { + ACE_DEBUG ((LM_DEBUG, + "test_i::oneway_method -> session id = %d iteration = %d payload size = %d\n", + session_id, + iteration, + payload.length ())); + } + + this->invocations_received_[iteration] = 1; + ++this->number_of_invocations_received_; + + ACE_hrtime_t time_of_current_call = + ACE_OS::gethrtime (); + + if (this->first_invocation_) + this->first_invocation_ = 0; + else + this->inter_arrival_times_->sample (time_of_current_call - this->time_of_last_call_); + + this->time_of_last_call_ = time_of_current_call; +} + +void +test_i::twoway_method (CORBA::Long &session_id, + CORBA::ULong &iteration, + ::test::octets &payload + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + if (this->session_id_ != session_id) + { + ACE_DEBUG ((LM_DEBUG, + "Late message with iteration id = %d: will not count message\n", + iteration)); + return; + } + + if (TAO_debug_level > 0) + { + ACE_DEBUG ((LM_DEBUG, + "test_i::twoway_method -> session id = %d iteration = %d payload size = %d\n", + session_id, + iteration, + payload.length ())); + } + + this->invocations_received_[iteration] = 1; + ++this->number_of_invocations_received_; + + ACE_hrtime_t time_of_current_call = + ACE_OS::gethrtime (); + + if (this->first_invocation_) + this->first_invocation_ = 0; + else + this->inter_arrival_times_->sample (time_of_current_call - this->time_of_last_call_); + + this->time_of_last_call_ = time_of_current_call; +} + +PortableServer::POA_ptr +test_i::_default_POA (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +{ + return PortableServer::POA::_duplicate (this->poa_.in ()); +} + +void +test_i::shutdown (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + ACE_DEBUG ((LM_DEBUG, + "test_i::shutdown\n")); + + this->orb_->shutdown (0 + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +int +main (int argc, char **argv) +{ + gsf = ACE_High_Res_Timer::global_scale_factor (); + + ACE_TRY_NEW_ENV + { + CORBA::ORB_var orb = + CORBA::ORB_init (argc, + argv, + 0 + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + int parse_args_result = + parse_args (argc, argv); + if (parse_args_result != 0) + return parse_args_result; + + CORBA::Object_var object = + orb->resolve_initial_references ("RootPOA" + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + PortableServer::POA_var root_poa = + PortableServer::POA::_narrow (object.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + PortableServer::POAManager_var poa_manager = + root_poa->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + test_i *servant = + new test_i (orb.in (), + root_poa.in ()); + + PortableServer::ServantBase_var safe_servant (servant); + ACE_UNUSED_ARG (safe_servant); + + test_var test = + servant->_this (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::String_var ior = + orb->object_to_string (test.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + FILE *output_file = + ACE_OS::fopen (ior_file, "w"); + ACE_ASSERT (output_file != 0); + + u_int result = + ACE_OS::fprintf (output_file, + "%s", + ior.in ()); + ACE_ASSERT (result == ACE_OS::strlen (ior.in ())); + ACE_UNUSED_ARG (result); + + ACE_OS::fclose (output_file); + + poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + orb->run (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Exception caught"); + return -1; + } + ACE_ENDTRY; + + return 0; +} diff --git a/TAO/performance-tests/Protocols/run_senders.pl b/TAO/performance-tests/Protocols/run_senders.pl new file mode 100755 index 00000000000..01bfbf5da8a --- /dev/null +++ b/TAO/performance-tests/Protocols/run_senders.pl @@ -0,0 +1,217 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# $Id$ +# -*- perl -*- + +require Process; +use lib "$ENV{'ACE_ROOT'}/bin"; +use PerlACE::Run_Test; + +# Type of test to run +$test_type = "PACED"; + +# Estimated execution of each test +$execution_time = 100; + +# Expected throughput of the network (in Mbps) +$expected_throughput = 100; + +# +# Assigns default rates +# +$min_rate = 25; +$max_rate = 100; +$rate_increment = 25; + +@rates[0] = 5; + +for ($rate = $min_rate, $i = 1; + $rate <= $max_rate; + $rate += $rate_increment, $i += 1) +{ + @rates[$i] = $rate; +} + + +# +# Assigns default message sizes +# +$min_message_size = 1 * 1000; +$max_message_size = 64 * 1000; + +@message_sizes[0] = 0; + +for ($message_size = $min_message_size, $i = 1; + $message_size <= $max_message_size; + $message_size *= 2, $i += 1) +{ + @message_sizes[$i] = $message_size; +} + + +# +# Assigns default protocols +# +@protocols = + ( + "IIOP", + "DIOP", + "SCIOP", + ); + + +# +# Parse the arguments +# +for ($i = 0; $i <= $#ARGV; $i++) { + if ($ARGV[$i] eq "-h" || $ARGV[$i] eq "-?") + { + print STDERR "\nusage: run_senders.pl\n"; + + print STDERR "\t-h shows options menu\n"; + + print STDERR "\t-message_sizes: defaults to ("; + for $message_size (@message_sizes) + { + print STDERR "$message_size, "; + } + print STDERR ")\n"; + + print STDERR "\t-rates: defaults to ("; + for $rate (@rates) + { + print STDERR "$rate, "; + } + print STDERR ")\n"; + + print STDERR "\t-protocols: defaults to ("; + for $protocol (@protocols) + { + print STDERR "$protocol, "; + } + print STDERR ")\n"; + + print STDERR "\t-execution_time: defaults to $execution_time\n"; + + print STDERR "\t-test_type: defaults to $test_type (valid options are PACED, THROUGHPUT, and LATENCY)\n"; + + print STDERR "\n"; + + $CL = new PerlACE::Process ("sender", "-h"); + $CL->Spawn (); + $CL->WaitKill (5); + + $SV = new PerlACE::Process ("receiver", "-h"); + $SV->Spawn (); + $SV->WaitKill (5); + + exit; + } + elsif ($ARGV[$i] eq "-message_sizes") + { + @message_sizes = split (',', $ARGV[$i + 1]); + $i++; + } + elsif ($ARGV[$i] eq "-rates") + { + @rates = split (',', $ARGV[$i + 1]); + $i++; + } + elsif ($ARGV[$i] eq "-protocols") + { + @protocols = split (',', $ARGV[$i + 1]); + $i++; + } + elsif ($ARGV[$i] eq "-execution_time") + { + $execution_time = $ARGV[$i + 1]; + $i++; + } + elsif ($ARGV[$i] eq "-test_type") + { + $test_type = $ARGV[$i + 1]; + $i++; + + # Rate is irrelevant in THROUGHPUT and LATENCY tests. + if ($test_type eq "THROUGHPUT" || + $test_type eq "LATENCY") + { + @rates = split (',', "1"); + } + } + else + { + $extra_args .= " " . $ARGV[$i]; + } +} + +$i = 0; + +# +# This loop form the arguments +# +for $protocol (@protocols) +{ + for $rate (@rates) + { + for $message_size (@message_sizes) + { + # DIOP does not support messages beyond 8K + next if ($protocol eq "DIOP" && $message_size > (8 * 1000)); + + # Since DIOP is unreliable, it doesn't make sense to use it for THROUGHPUT and LATENCY tests. + next if ($protocol eq "DIOP" && ($test_type eq "THROUGHPUT" || $test_type eq "LATENCY")); + + # Assign iterations + if ($test_type eq "PACED") + { + $iterations = $execution_time * $rate; + } + elsif ($test_type eq "THROUGHPUT") + { + # Skip message size of zero since we will never to able get any throughput + next if ($message_size == 0); + $iterations = $expected_throughput * 1000 * 1000 * $execution_time / $message_size / 8; + } + elsif ($test_type eq "LATENCY") + { + # Latency iteration are fixed. Using + # expected_throughput is really not a good measure. + $iterations = 10000; + } + + @configs[$i] = "-i $iterations -p $protocol -r $rate -s $message_size"; + $i++; + } + } +} + + +if ($test_type eq "PACED") +{ + $test = 0; + + # Sender-side stats are not interesting when pacing + $print_statistics = 0; +} +elsif ($test_type eq "THROUGHPUT") +{ + $test = 1; + $print_statistics = 1; +} +elsif ($test_type eq "LATENCY") +{ + $test = 2; + $print_statistics = 1; +} + + +for $config (@configs) +{ + $command = "./sender -a $test -t $print_statistics $config $extra_args"; + print "$command \n"; + system ($command); +} + diff --git a/TAO/performance-tests/Protocols/run_test.pl b/TAO/performance-tests/Protocols/run_test.pl new file mode 100755 index 00000000000..dd3d00f0aeb --- /dev/null +++ b/TAO/performance-tests/Protocols/run_test.pl @@ -0,0 +1,43 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# $Id$ +# -*- perl -*- + +use lib '../../../bin'; +use PerlACE::Run_Test; + +$ORBdebuglevel = 0; +$status = 0; + +$iorfile = "receiver.ior"; +unlink $iorfile; + +$SV = new PerlACE::Process ("receiver", "-ORBdebuglevel $ORBdebuglevel"); +$CL = new PerlACE::Process ("sender", "-ORBdebuglevel $ORBdebuglevel -a 0 -b 0 -c 0 -d 0 -e 0 -i 10 -k file://receiver.ior -m 0 -p IIOP -r 5 -s 100 -t 0 -x 1"); + +$SV->Spawn (); + +if (PerlACE::waitforfile_timed ($iorfile, 10) == -1) { + print STDERR "ERROR: cannot find file <$iorfile>\n"; + $SV->Kill (); + exit 1; +} + +$sender = $CL->SpawnWaitKill (60); +$receiver = $SV->WaitKill (5); + +unlink $iorfile; + +if ($sender != 0) { + print STDERR "ERROR: sender returned $sender\n"; + $status = 1; +} + +if ($receiver != 0) { + print STDERR "ERROR: receiver returned $receiver\n"; + $status = 1; +} + +exit $status; diff --git a/TAO/performance-tests/Protocols/sctp_params.conf b/TAO/performance-tests/Protocols/sctp_params.conf new file mode 100644 index 00000000000..a786b188072 --- /dev/null +++ b/TAO/performance-tests/Protocols/sctp_params.conf @@ -0,0 +1,11 @@ +PREFIX=sctp_ +assoc_max_retrans=25 +heartbeat_itvl=1 +init_retries=25 +max_sack_delay=0 +path_max_retrans=0 +rto_max=0 +rto_initial=0 +rto_min=0 +SETTINGS="assoc_max_retrans heartbeat_itvl init_retries max_sack_delay path_max_retrans rto_min rto_max rto_initial " + diff --git a/TAO/performance-tests/Protocols/sender.cpp b/TAO/performance-tests/Protocols/sender.cpp new file mode 100644 index 00000000000..5558f0abcee --- /dev/null +++ b/TAO/performance-tests/Protocols/sender.cpp @@ -0,0 +1,782 @@ +// $Id$ + +#include "ace/Get_Opt.h" +#include "ace/High_Res_Timer.h" +#include "ace/Stats.h" +#include "ace/Sample_History.h" +#include "ace/OS_NS_unistd.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_stdlib.h" +#include "ace/OS_NS_time.h" +#include "tao/RTCORBA/RTCORBA.h" +#include "tao/RTCORBA/RT_Policy_i.h" +#include "tao/RTCORBA/Network_Priority_Mapping_Manager.h" +#include "tao/RTCORBA/Network_Priority_Mapping.h" +#include "tao/ORB_Constants.h" +#include "Custom_Network_Priority_Mapping.h" +#include "Custom_Network_Priority_Mapping.cpp" +#include "tao/debug.h" +#include "testC.h" + +// Types of tests supported. +enum Test_Type + { + PACED, + THROUGHPUT, + LATENCY + }; + +static const char *ior = "file://distributor.ior"; +static int shutdown_server = 0; +static CORBA::ULong iterations = 5; +static CORBA::ULong invocation_rate = 5; +static int count_missed_end_deadlines = 0; +static ACE_UINT32 gsf = 0; +static int do_dump_history = 0; +static int print_missed_invocations = 0; +static CORBA::ULong message_size = 0; +static const char *test_protocol = "IIOP"; +static int print_statistics = 1; +static int number_of_connection_attempts = 20; +static int enable_diffserv_code_points = 0; +static RTCORBA::Priority corba_priority = RTCORBA::minPriority; +static Test_Type test_type = PACED; + +static int +parse_args (int argc, char **argv) +{ + ACE_Get_Opt get_opts (argc, argv, "a:b:c:d:e:i:k:m:p:r:s:t:x:"); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'a': + test_type = static_cast<Test_Type> (ACE_OS::atoi (get_opts.opt_arg ())); + break; + + case 'b': + enable_diffserv_code_points = ACE_OS::atoi (get_opts.opt_arg ()); + break; + + case 'c': + corba_priority = ACE_OS::atoi (get_opts.opt_arg ()); + break; + + case 'd': + do_dump_history = ACE_OS::atoi (get_opts.opt_arg ()); + break; + + case 'e': + count_missed_end_deadlines = ACE_OS::atoi (get_opts.opt_arg ()); + break; + + case 'i': + iterations = ACE_OS::atoi (get_opts.opt_arg ()); + break; + + case 'k': + ior = get_opts.opt_arg (); + break; + + case 'm': + print_missed_invocations = ACE_OS::atoi (get_opts.opt_arg ()); + break; + + case 'p': + test_protocol = get_opts.opt_arg (); + break; + + case 'r': + invocation_rate = ACE_OS::atoi (get_opts.opt_arg ()); + break; + + case 's': + message_size = ACE_OS::atoi (get_opts.opt_arg ()); + break; + + case 't': + print_statistics = ACE_OS::atoi (get_opts.opt_arg ()); + break; + + case 'x': + shutdown_server = ACE_OS::atoi (get_opts.opt_arg ()); + break; + + default: + { + const char *test = 0; + switch (test_type) + { + case PACED: + test = "PACED"; + break; + case THROUGHPUT: + test = "THROUGHPUT"; + break; + case LATENCY: + test = "LATENCY"; + break; + } + + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s\n" + "\t-a <test type> (defaults to %s [valid values are PACED(%d), THROUGHPUT(%d), and LATENCY(%d))\n" + "\t-b <enable diffserv code points> (defaults to %d)\n" + "\t-c <corba priority> (defaults to %d)\n" + "\t-d <show history> (defaults to %d)\n" + "\t-e <count missed end deadlines> (defaults to %d)\n" + "\t-h <help: shows options menu>\n" + "\t-i <iterations> (defaults to %d)\n" + "\t-k <ior> (defaults to %s)\n" + "\t-m <print missed invocations for paced workers> (defaults to %d)\n" + "\t-p <test protocol> (defaults to %s [valid values are IIOP, DIOP, and SCIOP])\n" + "\t-r <invocation rate> (defaults to %d)\n" + "\t-s <message size> (defaults to %d)\n" + "\t-t <print stats> (defaults to %d)\n" + "\t-x <shutdown server> (defaults to %d)\n" + "\n", + argv[0], + test, PACED, THROUGHPUT, LATENCY, + enable_diffserv_code_points, + corba_priority, + do_dump_history, + count_missed_end_deadlines, + iterations, + ior, + print_missed_invocations, + test_protocol, + invocation_rate, + message_size, + print_statistics, + shutdown_server), + -1); + } + } + + return 0; +} + +double +to_seconds (ACE_UINT64 hrtime, + ACE_UINT32 sf) +{ + double seconds = static_cast<double> ( + ACE_UINT64_DBLCAST_ADAPTER (hrtime / sf)); + seconds /= ACE_HR_SCALE_CONVERSION; + + return seconds; +} + +ACE_UINT64 +to_hrtime (double seconds, + ACE_UINT32 sf) +{ + return ACE_UINT64 (seconds * sf * ACE_HR_SCALE_CONVERSION); +} + +class Worker +{ +public: + Worker (CORBA::ORB_ptr orb, + RTCORBA::RTORB_ptr rtorb, + CORBA::PolicyManager_ptr policy_manager, + test_ptr test); + + void run (ACE_ENV_SINGLE_ARG_DECL); + + void print_stats (void); + + void setup (ACE_ENV_SINGLE_ARG_DECL); + +private: + + ACE_hrtime_t deadline_for_current_call (CORBA::ULong i); + void missed_start_deadline (CORBA::ULong invocation); + void missed_end_deadline (CORBA::ULong invocation); + + RTCORBA::RTORB_var rtorb_; + CORBA::PolicyManager_var policy_manager_; + test_var test_; + ACE_Sample_History history_; + ACE_hrtime_t interval_between_calls_; + ACE_hrtime_t test_start_; + ACE_hrtime_t test_end_; + CORBA::ULong missed_start_deadlines_; + CORBA::ULong missed_end_deadlines_; + + typedef ACE_Array_Base<CORBA::ULong> Missed_Invocations; + Missed_Invocations missed_start_invocations_; + Missed_Invocations missed_end_invocations_; + + CORBA::PolicyList base_protocol_policy_; + CORBA::PolicyList test_protocol_policy_; + + CORBA::Long session_id_; +}; + +Worker::Worker (CORBA::ORB_ptr orb, + RTCORBA::RTORB_ptr rtorb, + CORBA::PolicyManager_ptr policy_manager, + test_ptr test) + : rtorb_ (RTCORBA::RTORB::_duplicate (rtorb)), + policy_manager_ (CORBA::PolicyManager::_duplicate (policy_manager)), + test_ (test::_duplicate (test)), + history_ (iterations), + interval_between_calls_ (), + missed_start_deadlines_ (0), + missed_end_deadlines_ (0), + missed_start_invocations_ (iterations), + missed_end_invocations_ (iterations) +{ + // Each sender will have a random session id. This helps in + // identifying late packets arriving at the server. + ACE_OS::srand ((unsigned) ACE_OS::time (NULL)); + this->session_id_ = ACE_OS::rand (); + + // Interval is inverse of rate. + this->interval_between_calls_ = + to_hrtime (1 / double (invocation_rate), gsf); + + // Base protocol is used for setting up and tearing down the test. + this->base_protocol_policy_.length (1); + + // Test protocol is the one being tested. + this->test_protocol_policy_.length (1); + + RTCORBA::ProtocolProperties_var base_transport_protocol_properties = + TAO_Protocol_Properties_Factory::create_transport_protocol_property (IOP::TAG_INTERNET_IOP, + orb->orb_core ()); + + RTCORBA::TCPProtocolProperties_var tcp_base_transport_protocol_properties = + RTCORBA::TCPProtocolProperties::_narrow (base_transport_protocol_properties.in ()); + + tcp_base_transport_protocol_properties->enable_network_priority (enable_diffserv_code_points); + + RTCORBA::ProtocolList protocols; + protocols.length (1); + protocols[0].transport_protocol_properties = + base_transport_protocol_properties; + protocols[0].orb_protocol_properties = + RTCORBA::ProtocolProperties::_nil (); + + // IIOP is always used for the base protocol. + protocols[0].protocol_type = IOP::TAG_INTERNET_IOP; + + // User decides the test protocol. + this->base_protocol_policy_[0] = + this->rtorb_->create_client_protocol_policy (protocols); + + if (ACE_OS::strcmp (test_protocol, "DIOP") == 0) + { + if (TAO_debug_level) ACE_DEBUG ((LM_DEBUG, "test protocol is DIOP\n")); + protocols[0].protocol_type = TAO_TAG_DIOP_PROFILE; + } + else if (ACE_OS::strcmp (test_protocol, "SCIOP") == 0) + { + if (TAO_debug_level) ACE_DEBUG ((LM_DEBUG, "test protocol is SCIOP\n")); + protocols[0].protocol_type = TAO_TAG_SCIOP_PROFILE; + } + else + { + if (TAO_debug_level) ACE_DEBUG ((LM_DEBUG, "test protocol is IIOP\n")); + protocols[0].protocol_type = IOP::TAG_INTERNET_IOP; + } + + RTCORBA::ProtocolProperties_var test_transport_protocol_properties = + TAO_Protocol_Properties_Factory::create_transport_protocol_property (protocols[0].protocol_type, + orb->orb_core ()); + + if (protocols[0].protocol_type == TAO_TAG_DIOP_PROFILE) + { + RTCORBA::UserDatagramProtocolProperties_var udp_test_transport_protocol_properties = + RTCORBA::UserDatagramProtocolProperties::_narrow (test_transport_protocol_properties.in ()); + + udp_test_transport_protocol_properties->enable_network_priority (enable_diffserv_code_points); + } + else if (protocols[0].protocol_type == TAO_TAG_SCIOP_PROFILE) + { + RTCORBA::StreamControlProtocolProperties_var sctp_test_transport_protocol_properties = + RTCORBA::StreamControlProtocolProperties::_narrow (test_transport_protocol_properties.in ()); + + sctp_test_transport_protocol_properties->enable_network_priority (enable_diffserv_code_points); + } + else if (protocols[0].protocol_type == IOP::TAG_INTERNET_IOP) + { + RTCORBA::TCPProtocolProperties_var tcp_test_transport_protocol_properties = + RTCORBA::TCPProtocolProperties::_narrow (test_transport_protocol_properties.in ()); + + tcp_test_transport_protocol_properties->enable_network_priority (enable_diffserv_code_points); + } + + protocols[0].transport_protocol_properties = + test_transport_protocol_properties; + + this->test_protocol_policy_[0] = + this->rtorb_->create_client_protocol_policy (protocols); +} + +void +Worker::print_stats (void) +{ + CORBA::ULong missed_total_deadlines = + this->missed_start_deadlines_ + this->missed_end_deadlines_; + + CORBA::ULong made_total_deadlines = + iterations - missed_total_deadlines; + + ACE_DEBUG ((LM_DEBUG, + "\n************ Statistics ************\n\n")); + + // + // Senders-side stats for PACED invocations are not too relevant + // since we are doing one way calls. + // + if (test_type == PACED) + { + ACE_DEBUG ((LM_DEBUG, + "Rate = %d/sec; Iterations = %d; ", + invocation_rate, + iterations)); + + if (count_missed_end_deadlines) + ACE_DEBUG ((LM_DEBUG, + "Deadlines made/missed[start,end]/%% = %d/%d[%d,%d]/%.2f%%; Effective Rate = %.2f\n", + made_total_deadlines, + missed_total_deadlines, + this->missed_start_deadlines_, + this->missed_end_deadlines_, + made_total_deadlines * 100 / (double) iterations, + made_total_deadlines / to_seconds (this->test_end_ - this->test_start_, gsf))); + else + ACE_DEBUG ((LM_DEBUG, + "Deadlines made/missed/%% = %d/%d/%.2f%%; Effective Rate = %.2f\n", + made_total_deadlines, + missed_total_deadlines, + made_total_deadlines * 100 / (double) iterations, + made_total_deadlines / to_seconds (this->test_end_ - this->test_start_, gsf))); + + if (print_missed_invocations) + { + ACE_DEBUG ((LM_DEBUG, "\nMissed start invocations are:\n")); + + for (CORBA::ULong j = 0; + j < this->missed_start_deadlines_; + ++j) + { + ACE_DEBUG ((LM_DEBUG, + "%d ", + this->missed_start_invocations_[j])); + } + + ACE_DEBUG ((LM_DEBUG, "\n")); + + if (count_missed_end_deadlines) + { + ACE_DEBUG ((LM_DEBUG, "\nMissed end invocations are:\n")); + + for (CORBA::ULong j = 0; + j < this->missed_end_deadlines_; + ++j) + { + ACE_DEBUG ((LM_DEBUG, + "%d ", + this->missed_end_invocations_[j])); + } + + ACE_DEBUG ((LM_DEBUG, "\n")); + } + } + } + + // Individual calls are relevant for the PACED and LATENCY tests. + if (test_type == PACED || + test_type == LATENCY) + { + if (do_dump_history) + { + this->history_.dump_samples ("HISTORY", gsf); + } + + ACE_Basic_Stats stats; + this->history_.collect_basic_stats (stats); + stats.dump_results ("Total", gsf); + + ACE_Throughput_Stats::dump_throughput ("Total", gsf, + this->test_end_ - this->test_start_, + iterations); + } + else + { + ACE_hrtime_t elapsed_time = + this->test_end_ - this->test_start_; + + double seconds = + to_seconds (elapsed_time, gsf); + + ACE_hrtime_t bits = iterations; + bits *= message_size * 8; + + ACE_DEBUG ((LM_DEBUG, + "%Q bits sent in %5.1f seconds at a rate of %5.2f Mbps\n", + bits, + seconds, + ACE_UINT64_DBLCAST_ADAPTER (bits) / seconds / 1000 / 1000)); + } +} + +ACE_hrtime_t +Worker::deadline_for_current_call (CORBA::ULong i) +{ + ACE_hrtime_t deadline_for_current_call = + this->interval_between_calls_; + + deadline_for_current_call *= (i + 1); + + deadline_for_current_call += this->test_start_; + + return deadline_for_current_call; +} + +void +Worker::missed_start_deadline (CORBA::ULong invocation) +{ + this->missed_start_invocations_[this->missed_start_deadlines_++] = + invocation; +} + +void +Worker::missed_end_deadline (CORBA::ULong invocation) +{ + if (count_missed_end_deadlines) + this->missed_end_invocations_[this->missed_end_deadlines_++] = + invocation; +} + +void +Worker::setup (ACE_ENV_SINGLE_ARG_DECL) +{ + // Make sure we have a connection to the server using the test + // protocol. + this->policy_manager_->set_policy_overrides (this->test_protocol_policy_, + CORBA::SET_OVERRIDE + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // Since the network maybe unavailable temporarily, make sure to try + // for a few times before giving up. + for (int j = 0;;) + { + + test_protocol_setup: + + ACE_TRY_EX (B1) + { + // Send a message to ensure that the connection is setup. + this->test_->oneway_sync (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK_EX (B1); + + goto test_protocol_success; + } + ACE_CATCH (CORBA::TRANSIENT, exception) + { + ++j; + + if (j < number_of_connection_attempts) + { + ACE_OS::sleep (1); + goto test_protocol_setup; + } + } + ACE_ENDTRY; + + ACE_ERROR ((LM_ERROR, + "Cannot setup test protocol\n")); + + ACE_OS::exit (-1); + } + + test_protocol_success: + + // Use IIOP for setting up the test since the test protocol maybe + // unreliable. + this->policy_manager_->set_policy_overrides (this->base_protocol_policy_, + CORBA::SET_OVERRIDE + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // Since the network maybe unavailable temporarily, make sure to try + // for a few times before giving up. + for (int k = 0;;) + { + + base_protocol_setup: + + ACE_TRY_EX (B2) + { + // Let the server know what to expect.. + this->test_->start_test (this->session_id_, + test_protocol, + invocation_rate, + message_size, + iterations + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK_EX (B2); + + goto base_protocol_success; + } + ACE_CATCH (CORBA::TRANSIENT, exception) + { + ACE_OS::sleep (1); + + if (k < number_of_connection_attempts) + { + ACE_OS::sleep (1); + goto base_protocol_setup; + } + } + ACE_ENDTRY; + + ACE_ERROR ((LM_ERROR, + "Cannot setup base protocol\n")); + + ACE_OS::exit (-1); + } + + base_protocol_success: + + return; +} + +void +Worker::run (ACE_ENV_SINGLE_ARG_DECL) +{ + // Select the test protocol for these invocation. + this->policy_manager_->set_policy_overrides (this->test_protocol_policy_, + CORBA::SET_OVERRIDE + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // Payload. + ::test::octets_var payload (new ::test::octets); + payload->length (message_size); + + CORBA::Octet *buffer = + payload->get_buffer (); + + // Not necessary but good for debugging. + ACE_OS::memset (buffer, + 1, + message_size * sizeof (CORBA::Octet)); + + // Record the start time of the test. + this->test_start_ = + ACE_OS::gethrtime (); + + // Test with several iterations. + for (CORBA::ULong i = 0; + i < iterations; + ++i) + { + ACE_hrtime_t time_before_call = 0; + ACE_hrtime_t deadline_for_current_call = 0; + + // For PACED and LATENCY, each sender call is individually + // noted. + if (test_type == PACED || + test_type == LATENCY) + { + time_before_call = + ACE_OS::gethrtime (); + + // Pacing code. + if (test_type == PACED) + { + deadline_for_current_call = + this->deadline_for_current_call (i); + + if (time_before_call > deadline_for_current_call) + { + this->missed_start_deadline (i); + continue; + } + } + } + + // Use oneways for PACING and THROUGHPUT. + if (test_type == PACED || + test_type == THROUGHPUT) + { + this->test_->oneway_method (this->session_id_, + i, + payload.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + else + { + // Use twoway calls for LATENCY. + this->test_->twoway_method (this->session_id_, + i, + payload.inout () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + + // For PACED and LATENCY, each sender call is individually + // noted. + if (test_type == PACED || + test_type == LATENCY) + { + ACE_hrtime_t time_after_call = + ACE_OS::gethrtime (); + + if (test_type == LATENCY) + this->history_.sample ((time_after_call - time_before_call) / 2); + else + this->history_.sample (time_after_call - time_before_call); + + if (test_type == PACED) + { + if (time_after_call > deadline_for_current_call) + { + this->missed_end_deadline (i); + continue; + } + + ACE_hrtime_t sleep_time = + deadline_for_current_call - time_after_call; + + ACE_OS::sleep (ACE_Time_Value (0, + long (to_seconds (sleep_time, gsf) * + ACE_ONE_SECOND_IN_USECS))); + } + } + } + + // This call is used to ensure that all the THROUGHPUT related data + // has reached the server. + if (test_type == THROUGHPUT && + ACE_OS::strcmp (test_protocol, "DIOP") != 0) + { + this->test_->twoway_sync (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + } + + // Record end time for the test. + this->test_end_ = ACE_OS::gethrtime (); + + // Use IIOP to indicate end of test to server. + this->policy_manager_->set_policy_overrides (this->base_protocol_policy_, + CORBA::SET_OVERRIDE + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // Tell server that the test is over. + this->test_->end_test (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; +} + +int +main (int argc, char **argv) +{ + gsf = ACE_High_Res_Timer::global_scale_factor (); + + ACE_TRY_NEW_ENV + { + CORBA::ORB_var orb = + CORBA::ORB_init (argc, + argv, + 0 + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::Object_var object = + orb->resolve_initial_references ("RTORB" + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + RTCORBA::RTORB_var rtorb = + RTCORBA::RTORB::_narrow (object.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + object = + orb->resolve_initial_references ("ORBPolicyManager" + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::PolicyManager_var policy_manager = + CORBA::PolicyManager::_narrow (object.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + int parse_args_result = + parse_args (argc, argv); + if (parse_args_result != 0) + return parse_args_result; + + // Resolve the Network priority Mapping Manager + object = + orb->resolve_initial_references ("NetworkPriorityMappingManager" + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + RTCORBA::NetworkPriorityMappingManager_var mapping_manager = + RTCORBA::NetworkPriorityMappingManager::_narrow (object.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + // Initialize the custom priority mapping + Custom_Network_Priority_Mapping *cnpm = 0; + ACE_NEW_RETURN (cnpm, + Custom_Network_Priority_Mapping, + -1); + + // Set the desired corba priority on the network mapping manager + cnpm->corba_priority (corba_priority); + + // Load the custom network priority mapping object in the + // network priority mapping manager. The user can thus add his + // own priority mapping. + mapping_manager->mapping (cnpm); + + object = + orb->string_to_object (ior + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + test_var test = + test::_narrow (object.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + Worker worker (orb.in (), + rtorb.in (), + policy_manager.in (), + test.in ()); + + worker.setup (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + worker.run (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (print_statistics) + worker.print_stats (); + + if (shutdown_server) + { + test->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "Error!"); + return -1; + } + ACE_ENDTRY; + + return 0; +} diff --git a/TAO/performance-tests/Protocols/set_lksctp_params.sh b/TAO/performance-tests/Protocols/set_lksctp_params.sh new file mode 100755 index 00000000000..799f5950d58 --- /dev/null +++ b/TAO/performance-tests/Protocols/set_lksctp_params.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +B_PROC=/proc/sys/net/sctp + +CONF_PATH=/groups/pces/uav_oep/oomworks/lksctp-debug/TAO/performance-tests/Protocols +. ${CONF_PATH}/lksctp_params.conf + +for i in $SETTINGS; do + eval "echo \"echo \$$i > \$B_PROC/\${PREFIX}${i}\"" + eval "echo \$$i > \$B_PROC/\${PREFIX}${i}" +done diff --git a/TAO/performance-tests/Protocols/set_sctp_params.sh b/TAO/performance-tests/Protocols/set_sctp_params.sh new file mode 100755 index 00000000000..767158f8038 --- /dev/null +++ b/TAO/performance-tests/Protocols/set_sctp_params.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +B_PROC=/proc/sys/net/ipv4 + +CONF_PATH=/groups/pces/uav_oep/oomworks/openss7-debug/TAO/performance-tests/Protocols +. ${CONF_PATH}/sctp_params.conf + +for i in $SETTINGS; do + eval "echo \"echo \$$i > \$B_PROC/\${PREFIX}${i}\"" + eval "echo \$$i > \$B_PROC/\${PREFIX}${i}" +done diff --git a/TAO/performance-tests/Protocols/show_lksctp_params.sh b/TAO/performance-tests/Protocols/show_lksctp_params.sh new file mode 100755 index 00000000000..89cf1e2a5c6 --- /dev/null +++ b/TAO/performance-tests/Protocols/show_lksctp_params.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +max_len=24 +pushd /proc/sys/net/sctp &> /dev/null +echo "SCTP Parameters" +for i in `ls *`; do + ct=0 + tmp_len=`echo ${i} | wc -m` + let "tmp_len=tmp_len-1" + let "spaces=${max_len}-${tmp_len}" + echo -n " $i:" + while [ ${ct} -lt ${spaces} ]; do + echo -n " " + let "ct=${ct}+1" + done + cat $i +done +echo diff --git a/TAO/performance-tests/Protocols/show_sctp_params.sh b/TAO/performance-tests/Protocols/show_sctp_params.sh new file mode 100755 index 00000000000..9037784ed1b --- /dev/null +++ b/TAO/performance-tests/Protocols/show_sctp_params.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +max_len=24 +pushd /proc/sys/net/ipv4 &> /dev/null +echo "SCTP Parameters" +for i in `ls sctp_*`; do + ct=0 + tmp_len=`echo ${i} | wc -m` + let "tmp_len=tmp_len-1" + let "spaces=${max_len}-${tmp_len}" + echo -n " $i:" + while [ ${ct} -lt ${spaces} ]; do + echo -n " " + let "ct=${ct}+1" + done + cat $i +done +echo diff --git a/TAO/performance-tests/Protocols/svc.conf b/TAO/performance-tests/Protocols/svc.conf new file mode 100644 index 00000000000..711df131ebc --- /dev/null +++ b/TAO/performance-tests/Protocols/svc.conf @@ -0,0 +1 @@ +dynamic Advanced_Resource_Factory Service_Object * TAO_Strategies:_make_TAO_Advanced_Resource_Factory() diff --git a/TAO/performance-tests/Protocols/test.idl b/TAO/performance-tests/Protocols/test.idl new file mode 100644 index 00000000000..71bbaab76a6 --- /dev/null +++ b/TAO/performance-tests/Protocols/test.idl @@ -0,0 +1,28 @@ +// $Id$ + +interface test +{ + void start_test (in long session_id, + in string protocol, + in unsigned long invocation_rate, + in unsigned long message_size, + in unsigned long iterations); + + void end_test (); + + oneway void oneway_sync (); + + void twoway_sync (); + + void shutdown (); + + typedef sequence<octet> octets; + + oneway void oneway_method (in long session_id, + in unsigned long iteration, + in octets payload); + + void twoway_method (inout long session_id, + inout unsigned long iteration, + inout octets payload); +}; diff --git a/TAO/performance-tests/Protocols/toggle_link.pl b/TAO/performance-tests/Protocols/toggle_link.pl new file mode 100755 index 00000000000..88908ac5052 --- /dev/null +++ b/TAO/performance-tests/Protocols/toggle_link.pl @@ -0,0 +1,66 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# $Id$ +# -*- perl -*- + +use Time::localtime; +use Time::Local; + +# amount of delay between running the servers +$sleeptime = 2; +$phasetime = 3; + +$project = "pces/sctp"; + +$L1_DOWN = "tevc -e $project now link1 down &"; +$L1_UP = "tevc -e $project now link1 up &"; +$L2_DOWN = "tevc -e $project now link2 down &"; +$L2_UP = "tevc -e $project now link2 up &"; + +$now = localtime; +$start_seconds = timelocal ($now->sec, $now->min, $now->hour, $now->mday, $now->mon, $now->year); + +print_with_time ("L1 UP"); +system ($L1_UP); + +print_with_time ("L2 DOWN"); +system ($L2_DOWN); + +select undef, undef, undef, $phasetime; + +for (;;) +{ + print_with_time ("L2 UP"); + + system ($L2_UP); + + select undef, undef, undef, $sleeptime / 2; + + print_with_time ("L1 DOWN"); + + system ($L1_DOWN); + + select undef, undef, undef, $sleeptime; + + print_with_time ("L1 UP"); + + system ($L1_UP); + + select undef, undef, undef, $sleeptime / 2; + + print_with_time ("L2 Down"); + + system ($L2_DOWN); + + select undef, undef, undef, $sleeptime; +} + +sub print_with_time +{ + $now = localtime; + $now_seconds = timelocal ($now->sec, $now->min, $now->hour, $now->mday, $now->mon, $now->year); + + print "@_ at ", $now_seconds - $start_seconds, "\n"; +} |