From d20bbddef56700f0a09ee730e7de7ddd249c0e48 Mon Sep 17 00:00:00 2001 From: dengg Date: Thu, 8 Feb 2007 03:31:10 +0000 Subject: Added a Plan_Launcher_Benchmark_Impl.{h,cpp} subclass which overrides the launch_plan() method to collect benchmarking results. Also modified the base class to take additional command line argument to specify the number of iterations to deploy the application. --- CIAO/DAnCE/Plan_Launcher/Plan_Launcher.cpp | 91 +++++--- .../Plan_Launcher/Plan_Launcher_Benchmark_Impl.cpp | 244 +++++++++++++++++++++ .../Plan_Launcher/Plan_Launcher_Benchmark_Impl.h | 44 ++++ CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Impl.cpp | 4 +- CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Impl.h | 12 +- 5 files changed, 355 insertions(+), 40 deletions(-) create mode 100644 CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Benchmark_Impl.cpp create mode 100644 CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Benchmark_Impl.h diff --git a/CIAO/DAnCE/Plan_Launcher/Plan_Launcher.cpp b/CIAO/DAnCE/Plan_Launcher/Plan_Launcher.cpp index 642e3f6b606..93e57b802bf 100644 --- a/CIAO/DAnCE/Plan_Launcher/Plan_Launcher.cpp +++ b/CIAO/DAnCE/Plan_Launcher/Plan_Launcher.cpp @@ -1,6 +1,6 @@ // $Id$ -#include "Plan_Launcher_Impl.h" +#include "Plan_Launcher_Benchmark_Impl.h" #include "ace/OS.h" #include "ace/Get_Opt.h" @@ -27,6 +27,8 @@ namespace CIAO const char* repoman_name_ = "RepositoryManager"; const char* dap_ior_filename = 0; const char* dap_ior = 0; + bool do_benchmarking = false; + size_t niterations = 0; CORBA::Short priority = 0; enum mode_type { @@ -46,19 +48,20 @@ namespace CIAO ACE_ERROR ((LM_ERROR, ACE_TEXT ("[(%P|%t) Executor] Usage: %s\n") ACE_TEXT ("-a \n") + ACE_TEXT ("-b \n") ACE_TEXT ("-e \n") - ACE_TEXT ("-p \n") - ACE_TEXT ("-n : Use naming service to fetch EM") + ACE_TEXT ("-i \n") ACE_TEXT ("-k ") ACE_TEXT (" : Default file://em.ior\n") ACE_TEXT ("-l ") ACE_TEXT (" : Default file://rm.ior\n") - ACE_TEXT ("-v : Use naming service to fetch RM with the given name") - ACE_TEXT (" : Default RepositoryManager\n") - ACE_TEXT ("-t \n") + ACE_TEXT ("-n : Use naming service to fetch EM") ACE_TEXT ("-o \n") - ACE_TEXT ("-i \n") + ACE_TEXT ("-p \n") ACE_TEXT ("-r \n") + ACE_TEXT ("-t \n") + ACE_TEXT ("-v : Use naming service to fetch RM with the given name") + ACE_TEXT (" : Default RepositoryManager\n") ACE_TEXT ("-z \n") ACE_TEXT ("-h : Show this usage information\n"), program)); @@ -70,7 +73,7 @@ namespace CIAO { ACE_Get_Opt get_opt (argc, argv, - ACE_TEXT ("a:e:p:nk:l:v:t:o:i:r:z:h")); + ACE_TEXT ("a:b:e:p:nk:l:v:t:o:i:r:z:h")); int c; while ((c = get_opt ()) != EOF) @@ -81,6 +84,10 @@ namespace CIAO package_names = get_opt.opt_arg (); use_package_name = true; break; + case 'b': + do_benchmarking = true; + niterations = ACE_OS::atoi (get_opt.opt_arg ()); + break; case 'e': package_types = get_opt.opt_arg (); use_package_name = false; @@ -191,14 +198,28 @@ namespace CIAO if (parse_args (argc, argv) == false) return -1; - Plan_Launcher_i launcher; + Plan_Launcher_i * launcher = 0; + + if (do_benchmarking) + { + ACE_NEW_RETURN (launcher, + Plan_Launcher_Benchmark_i, + -1); + } + else + { + ACE_NEW_RETURN (launcher, + Plan_Launcher_i, + -1); + } - if (!launcher.init (em_use_naming ? 0 : em_ior_file, - orb.in (), - use_repoman, - rm_use_naming, - rm_use_naming ? repoman_name_ : rm_ior_file, - priority)) + if (!launcher->init (em_use_naming ? 0 : em_ior_file, + orb.in (), + use_repoman, + rm_use_naming, + rm_use_naming ? repoman_name_ : rm_ior_file, + priority, + niterations)) { ACE_ERROR ((LM_ERROR, "(%P|%t) Plan_Launcher: Error initializing the EM.\n")); return -1; @@ -211,15 +232,15 @@ namespace CIAO CORBA::String_var uuid; if (package_names != 0) - uuid = launcher.launch_plan (deployment_plan_url, - package_names, - use_package_name, - use_repoman); + uuid = launcher->launch_plan (deployment_plan_url, + package_names, + use_package_name, + use_repoman); else - uuid = launcher.launch_plan (deployment_plan_url, - package_types, - use_package_name, - use_repoman); + uuid = launcher->launch_plan (deployment_plan_url, + package_types, + use_package_name, + use_repoman); if (uuid.in () == 0) { @@ -228,7 +249,7 @@ namespace CIAO } ACE_DEBUG ((LM_DEBUG, "Plan_Launcher returned UUID is %s\n", uuid.in ())); - dapp_mgr = launcher.get_dam (uuid.in ()); + dapp_mgr = launcher->get_dam (uuid.in ()); // Write out DAM ior if requested if (mode == pl_mode_start) @@ -245,7 +266,7 @@ namespace CIAO // Tear down the assembly ACE_DEBUG ((LM_DEBUG, "Plan_Launcher: destroy the application.....\n")); - if (! launcher.teardown_plan (uuid)) + if (! launcher->teardown_plan (uuid)) ACE_DEBUG ((LM_DEBUG, "(%P|%t) CIAO_PlanLauncher:tear down assembly failed: " "unkonw plan uuid.\n")); @@ -259,15 +280,15 @@ namespace CIAO CORBA::String_var uuid; if (package_names != 0) - uuid = launcher.re_launch_plan (new_deployment_plan_url, - package_names, - use_package_name, - use_repoman); + uuid = launcher->re_launch_plan (new_deployment_plan_url, + package_names, + use_package_name, + use_repoman); else - uuid = launcher.re_launch_plan (new_deployment_plan_url, - package_types, - use_package_name, - use_repoman); + uuid = launcher->re_launch_plan (new_deployment_plan_url, + package_types, + use_package_name, + use_repoman); if (uuid.in () == 0) { @@ -292,14 +313,14 @@ namespace CIAO // Tear down the assembly ACE_DEBUG ((LM_DEBUG, "Plan_Launcher: destroy the application.....\n")); - launcher.teardown_plan (dapp_mgr.in ()); + launcher->teardown_plan (dapp_mgr.in ()); } else if (mode == pl_mode_stop_by_uuid) // tear down by plan_uuid { // Tear down the assembly ACE_DEBUG ((LM_DEBUG, "Plan_Launcher: destroy the application.....\n")); - if (! launcher.teardown_plan (plan_uuid)) + if (! launcher->teardown_plan (plan_uuid)) { ACE_ERROR ((LM_ERROR, "(%P|%t) CIAO_PlanLauncher:tear down assembly failed: " diff --git a/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Benchmark_Impl.cpp b/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Benchmark_Impl.cpp new file mode 100644 index 00000000000..dede7257be8 --- /dev/null +++ b/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Benchmark_Impl.cpp @@ -0,0 +1,244 @@ +// $Id$ +#include "Plan_Launcher_Benchmark_Impl.h" + +#include "ace/High_Res_Timer.h" +#include "ace/Sched_Params.h" +#include "ace/Stats.h" +#include "ace/Sample_History.h" + +namespace CIAO +{ + namespace Plan_Launcher + { + const char * + Plan_Launcher_Benchmark_i::launch_plan ( + const ::Deployment::DeploymentPlan &plan ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((Plan_Launcher_i::Deployment_Failure)) + { + ACE_TRY + { + + ///// Start Test //////////////////////////////////////////// + ACE_Sample_History history_prepare_plan (this->niterations_); + ACE_Sample_History history_start_launch (this->niterations_); + ACE_Sample_History history_finish_launch (this->niterations_); + ACE_Sample_History history_start_system (this->niterations_); + ACE_hrtime_t test_start = ACE_OS::gethrtime (); + ACE_hrtime_t call_start, call_end; + + while (this->niterations_ > 0) + { + --this->niterations_; + + if (CORBA::is_nil (this->em_.in ())) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("CIAO::Plan_Launcher_Benchmark_i: ") + ACE_TEXT ("launch_plan called witn an uninitialized EM.\n"))); + return 0; + } + + if (CIAO::debug_level () > 9) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("CIAO::Plan_Launcher_Benchmark_i: " ) + ACE_TEXT ("about to call this->em_->preparePlan\n"))); + } + + //////// Measure the latency for preparePlan() //////////////// + call_start = ACE_OS::gethrtime (); + ::Deployment::DomainApplicationManager_var dam (this->em_->preparePlan (plan, 1)); + call_end = ACE_OS::gethrtime (); + history_prepare_plan.sample (call_end - call_start); + + if (CIAO::debug_level () > 9) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("CIAO::Plan_Launcher_Benchmark_i: " ) + ACE_TEXT ("after to call this->em_->preparePlan\n"))); + } + + if (CORBA::is_nil (dam.in ())) + { + ACE_ERROR ((LM_ERROR, + "(%P|%t) CIAO_PlanLauncher:preparePlan call failed: " + "nil DomainApplicationManager reference\n")); + return 0; + } + + if (CIAO::debug_level () > 9) + { + ACE_DEBUG ((LM_DEBUG, + "CIAO_PlanLauncher: Obtained DAM ref \n")); + } + + ::Deployment::Properties_var properties; + ACE_NEW_RETURN (properties, + Deployment::Properties, + 0); + + if (CIAO::debug_level ()) + { + ACE_DEBUG ((LM_DEBUG, + "CIAO_PlanLauncher: start Launch application...\n")); + } + + + + // Do not start the Application immediately since it violates + // the semantics of component activation sequence + int start = 0; + + //////// Measure the latency for startLaunch() //////////////// + call_start = ACE_OS::gethrtime (); + dam->startLaunch (properties.in (), 0); + call_end = ACE_OS::gethrtime (); + history_start_launch.sample (call_end - call_start); + + + if (CIAO::debug_level ()) + ACE_DEBUG ((LM_DEBUG, "[success]\n")); + + // Call finish Launch to complete the connections + if (CIAO::debug_level ()) + ACE_DEBUG ((LM_DEBUG, + "CIAO_PlanLauncher: finish Launch application...\n")); + + + //////// Measure the latency for finishLaunch() //////////////// + call_start = ACE_OS::gethrtime (); + dam->finishLaunch (start, false); // is_ReDAC by default is + call_end = ACE_OS::gethrtime (); + history_finish_launch.sample (call_end - call_start); + + + if (CIAO::debug_level ()) + ACE_DEBUG ((LM_DEBUG, "[success]\n")); + + // Call start to activate components + if (CIAO::debug_level ()) + ACE_DEBUG ((LM_DEBUG, + "CIAO_PlanLauncher: start activating components...\n")); + + //////// Measure the latency for finishLaunch() //////////////// + call_start = ACE_OS::gethrtime (); + dam->start (); + call_end = ACE_OS::gethrtime (); + history_start_system.sample (call_end - call_start); + + + if (CIAO::debug_level ()) + ACE_DEBUG ((LM_DEBUG, "[success]\n")); + + if (CIAO::debug_level ()) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("CIAO_PlanLauncher: ") + ACE_TEXT ("Application Deployed successfully\n"))); + + map_.bind_dam_reference (plan.UUID.in (), + Deployment::DomainApplicationManager::_duplicate (dam.in ())); + + // In order to run the launch_plan() multiple times to collect benchmarking + // results, we have to tear down the plan and then redeploy. + if (this->niterations_ > 0) + { + dam->destroyApplication (); + this->destroy_dam_by_plan (plan.UUID.in ()); + } + } + + + ///// End Test //////////////////////////////////////////// + ACE_hrtime_t test_end = ACE_OS::gethrtime (); + + ACE_DEBUG ((LM_DEBUG, "test finished\n")); + + ACE_DEBUG ((LM_DEBUG, "High resolution timer calibration....")); + ACE_UINT32 gsf = ACE_High_Res_Timer::global_scale_factor (); + ACE_DEBUG ((LM_DEBUG, "done\n")); + + ACE_Basic_Stats stats_1; + history_prepare_plan.dump_samples ("HISTORY -- pareparePlan", gsf); + history_prepare_plan.collect_basic_stats (stats_1); + stats_1.dump_results ("TOTAL -- pareparePlan", gsf); + + ACE_Basic_Stats stats_2; + history_start_launch.dump_samples ("HISTORY -- startLaunch", gsf); + history_start_launch.collect_basic_stats (stats_2); + stats_2.dump_results ("TOTAL -- startLaunch", gsf); + + ACE_Basic_Stats stats_3; + history_finish_launch.dump_samples ("HISTORY -- finishLaunch", gsf); + history_finish_launch.collect_basic_stats (stats_3); + stats_3.dump_results ("TOTAL -- finishLaunch", gsf); + + ACE_Basic_Stats stats_4; + history_start_system.dump_samples ("HISTORY -- activateSystem", gsf); + history_start_system.collect_basic_stats (stats_4); + stats_4.dump_results ("TOTAL -- activateSystem", gsf); + +/* + ACE_Throughput_Stats::dump_throughput ("Total", gsf, + test_end - test_start, + stats.samples_count ());*/ + + } + ACE_CATCH (Deployment::ResourceNotAvailable, ex) + { + ACE_ERROR ((LM_ERROR, + "EXCEPTION: ResourceNotAvaiable exception caught: %s,\n" + "Type: %s\n" + "Property: %s\n" + "Element: %s\n" + "Resource: %s\n", + ex.name.in (), + ex.resourceType.in (), + ex.propertyName.in (), + ex.elementName.in (), + ex.resourceName.in ())); + ACE_THROW (Deployment_Failure ("")); + } + ACE_CATCH (Deployment::StartError, ex) + { + ACE_ERROR ((LM_ERROR, + "EXCEPTION: StartError exception caught: %s, %s\n", + ex.name.in (), + ex.reason.in ())); + ACE_THROW (Deployment_Failure ("")); + } + ACE_CATCH (Deployment::InvalidProperty, ex) + { + ACE_ERROR ((LM_ERROR, + "EXCEPTION: InvalidProperty exception caught: %s, %s\n", + ex.name.in (), + ex.reason.in ())); + ACE_THROW (Deployment_Failure ("")); + } + ACE_CATCH (Deployment::InvalidConnection, ex) + { + ACE_ERROR ((LM_ERROR, + "EXCEPTION: InvalidConnection exception caught: %s, %s\n", + ex.name.in (), + ex.reason.in ())); + ACE_THROW (Deployment_Failure ("")); + } + ACE_CATCHANY + { + ACE_ERROR ((LM_ERROR, + "CORBA EXCEPTION: %s\n", + ACE_ANY_EXCEPTION._info().fast_rep())); + ACE_THROW (Deployment_Failure ("")); + } + ACE_CATCHALL + { + ACE_ERROR ((LM_ERROR, + "EXCEPTION: non-CORBA exception\n")); + ACE_THROW (Deployment_Failure ("")); + } + ACE_ENDTRY; + ACE_CHECK_RETURN (0); + + return CORBA::string_dup (plan.UUID.in ()); + } + } +} diff --git a/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Benchmark_Impl.h b/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Benchmark_Impl.h new file mode 100644 index 00000000000..8599434714f --- /dev/null +++ b/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Benchmark_Impl.h @@ -0,0 +1,44 @@ +/** + * $Id$ + * @file Plan_Launcher_Benchmark_Impl.h + * @author Gan Deng + * + * A subclass of the Plan_Launcher_i class, which overrides the method + * called lauch_plan() to collect benchmarking results.. + */ +#ifndef PLAN_LAUNCHER_BENCHMARK_IMPL_H +#define PLAN_LAUNCHER_BENCHMARK_IMPL_H + +#include "Plan_Launcher_Impl.h" + +namespace CIAO +{ + namespace Plan_Launcher + { + /** + * @class Plan_Launcher_Benchmark_i + * @brief This class is a subclass of Plan_Launcher_i which is solely for + * benchmarking purpose. + */ + class Plan_Launcher_Impl_Export Plan_Launcher_Benchmark_i + : public Plan_Launcher_i + { + public: + + /** + * @brief Launch a plan, given an IDL deployment plan + * @param plan A valid IDL deployment plan + * @returns a string containing the UUID of the plan. Null indicates failure. + */ + virtual const char * launch_plan (const ::Deployment::DeploymentPlan &plan + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((Plan_Launcher_i::Deployment_Failure)); + + protected: + + }; + + } +} + +#endif /* PLAN_LAUNCHER_BENCHMARK_IMPL_H */ diff --git a/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Impl.cpp b/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Impl.cpp index 95a072969ab..322c596fe53 100644 --- a/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Impl.cpp +++ b/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Impl.cpp @@ -52,10 +52,12 @@ namespace CIAO bool use_repoman, bool rm_use_naming, const char *rm_name, - CORBA::Short priority + CORBA::Short priority, + size_t niterations ACE_ENV_ARG_DECL) { this->orb_ = CORBA::ORB::_duplicate (orb); + this->niterations_ = niterations; this->desired_priority_ = priority; CORBA::Object_var obj; diff --git a/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Impl.h b/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Impl.h index 7b30f6735ac..5d39f557467 100644 --- a/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Impl.h +++ b/CIAO/DAnCE/Plan_Launcher/Plan_Launcher_Impl.h @@ -44,7 +44,8 @@ namespace CIAO bool use_repoman = false, bool rm_use_naming = false, const char *rm_name = 0, - CORBA::Short priority = 0 + CORBA::Short priority = 0, + size_t niterations = 0 ACE_ENV_ARG_DECL_WITH_DEFAULTS); /** @@ -71,11 +72,11 @@ namespace CIAO * @param plan A valid IDL deployment plan * @returns a string containing the UUID of the plan. Null indicates failure. */ - const char * launch_plan (const ::Deployment::DeploymentPlan &plan + virtual const char * launch_plan (const ::Deployment::DeploymentPlan &plan ACE_ENV_ARG_DECL_WITH_DEFAULTS) ACE_THROW_SPEC ((Deployment_Failure)); - const char * re_launch_plan (const ::Deployment::DeploymentPlan &plan + virtual const char * re_launch_plan (const ::Deployment::DeploymentPlan &plan ACE_ENV_ARG_DECL_WITH_DEFAULTS) ACE_THROW_SPEC ((Deployment_Failure)); @@ -103,10 +104,10 @@ namespace CIAO // PriorityModelPolicy. bool is_client_propagated_model (void); - private: /// Cached ORB pointer CORBA::ORB_var orb_; + /// Object reference of the ExecutionManager ::CIAO::ExecutionManagerDaemon_var em_; /// Local map for DAMs, to save expensive UUID lookups. @@ -116,6 +117,9 @@ namespace CIAO /// Desired CORBA prioirty to be propagated to EM CORBA::Short desired_priority_; + + /// Number of iterations to run benchmarking, if specified + size_t niterations_; }; } -- cgit v1.2.1