Skip to content

Commit

Permalink
Adding performance counters for parcel and message counts to test
Browse files Browse the repository at this point in the history
- adding a new API for discovering performance counters used in the tests
  • Loading branch information
hkaiser committed Jan 5, 2016
1 parent a2f3b43 commit d7527b6
Show file tree
Hide file tree
Showing 8 changed files with 131 additions and 20 deletions.
19 changes: 13 additions & 6 deletions CMakeLists.txt
Expand Up @@ -579,9 +579,19 @@ if(HPX_WITH_RUN_MAIN_EVERYWHERE)
endif()

# Options for our plugins
hpx_option(HPX_WITH_COMPRESSION_BZIP2 BOOL "Enable bzip2 compression for parcel data (default: OFF)." OFF ADVANCED)
hpx_option(HPX_WITH_COMPRESSION_SNAPPY BOOL "Enable snappy compression for parcel data (default: OFF)." OFF ADVANCED)
hpx_option(HPX_WITH_COMPRESSION_ZLIB BOOL "Enable zlib compression for parcel data (default: OFF)." OFF ADVANCED)
hpx_option(HPX_WITH_COMPRESSION_BZIP2 BOOL
"Enable bzip2 compression for parcel data (default: OFF)." OFF ADVANCED)
hpx_option(HPX_WITH_COMPRESSION_SNAPPY BOOL
"Enable snappy compression for parcel data (default: OFF)." OFF ADVANCED)
hpx_option(HPX_WITH_COMPRESSION_ZLIB BOOL
"Enable zlib compression for parcel data (default: OFF)." OFF ADVANCED)

# Parcel coalescing is used by the main HPX library, enable it always
hpx_option(HPX_WITH_PARCEL_COALESCING BOOL
"Enable the parcel coalescing plugin (default: ON)." ON ADVANCED)
if(HPX_WITH_PARCEL_COALESCING)
hpx_add_config_define(HPX_HAVE_PARCEL_COALESCING)
endif()

################################################################################
# Backwards compatibility options (edit for each release)
Expand Down Expand Up @@ -1328,9 +1338,6 @@ if(HPX_WITH_COMPRESSION_ZLIB)
hpx_add_config_define(HPX_HAVE_COMPRESSION_ZLIB)
endif()

# Parcel coalescing is used by the main HPX library, enable it always
hpx_add_config_define(HPX_HAVE_PARCEL_COALESCING)

################################################################################
# Documentation toolchain (DocBook, BoostBook, QuickBook, xsltproc)
################################################################################
Expand Down
2 changes: 2 additions & 0 deletions docs/manual/build_system/cmake_variables.qbk
Expand Up @@ -46,6 +46,7 @@ The options are split into these categories:
* [link build_system.cmake_variables.HPX_WITH_LOGGING HPX_WITH_LOGGING]
* [link build_system.cmake_variables.HPX_WITH_MALLOC HPX_WITH_MALLOC]
* [link build_system.cmake_variables.HPX_WITH_NATIVE_TLS HPX_WITH_NATIVE_TLS]
* [link build_system.cmake_variables.HPX_WITH_PARCEL_COALESCING HPX_WITH_PARCEL_COALESCING]
* [link build_system.cmake_variables.HPX_WITH_RUN_MAIN_EVERYWHERE HPX_WITH_RUN_MAIN_EVERYWHERE]
* [link build_system.cmake_variables.HPX_WITH_SECURITY HPX_WITH_SECURITY]
* [link build_system.cmake_variables.HPX_WITH_STATIC_LINKING HPX_WITH_STATIC_LINKING]
Expand All @@ -71,6 +72,7 @@ The options are split into these categories:
[[[#build_system.cmake_variables.HPX_WITH_LOGGING] `HPX_WITH_LOGGING:BOOL`][Build HPX with logging enabled (default: ON).]]
[[[#build_system.cmake_variables.HPX_WITH_MALLOC] `HPX_WITH_MALLOC:STRING`][Define which allocator should be linked in. Options are: system, tcmalloc, jemalloc, tbbmalloc, and custom (default is: tcmalloc)]]
[[[#build_system.cmake_variables.HPX_WITH_NATIVE_TLS] `HPX_WITH_NATIVE_TLS:BOOL`][Use native TLS support if available (default: ON)]]
[[[#build_system.cmake_variables.HPX_WITH_PARCEL_COALESCING] `HPX_WITH_PARCEL_COALESCING:BOOL`][Enable the parcel coalescing plugin (default: ON).]]
[[[#build_system.cmake_variables.HPX_WITH_RUN_MAIN_EVERYWHERE] `HPX_WITH_RUN_MAIN_EVERYWHERE:BOOL`][Run hpx_main by default on all localities (default: OFF).]]
[[[#build_system.cmake_variables.HPX_WITH_SECURITY] `HPX_WITH_SECURITY:BOOL`][Enable security support via libsodium.]]
[[[#build_system.cmake_variables.HPX_WITH_STATIC_LINKING] `HPX_WITH_STATIC_LINKING:BOOL`][Compile HPX statically linked libraries (Default: OFF)]]
Expand Down
10 changes: 9 additions & 1 deletion hpx/performance_counters/performance_counter.hpp
Expand Up @@ -41,7 +41,7 @@ namespace hpx { namespace performance_counters

///////////////////////////////////////////////////////////////////////
future<counter_info> get_info() const;
counter_info get_info_sync(error_code& ec = throws);
counter_info get_info_sync(error_code& ec = throws) const;

future<counter_value> get_counter_value(bool reset = false);
future<counter_value> get_counter_value() const;
Expand All @@ -60,6 +60,10 @@ namespace hpx { namespace performance_counters
future<void> reset();
void reset_sync(error_code& ec = throws);

///////////////////////////////////////////////////////////////////////
future<std::string> get_name() const;
std::string get_name_sync() const;

private:
template <typename T>
static T extract_value(future<counter_value> && value, error_code& ec)
Expand Down Expand Up @@ -94,6 +98,10 @@ namespace hpx { namespace performance_counters
return get_counter_value_sync().get_value<T>(ec);
}
};

/// Return all counters matching the given name (with optional wildcards).
HPX_API_EXPORT std::vector<performance_counter> discover_counters(
std::string const& name, error_code& ec = throws);
}}

#endif
26 changes: 14 additions & 12 deletions plugins/parcel/coalescing/CMakeLists.txt
@@ -1,22 +1,24 @@
# Copyright (c) 2007-2013 Hartmut Kaiser
# Copyright (c) 2007-2016 Hartmut Kaiser
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

include(HPX_AddLibrary)

macro(add_coalescing_module)
hpx_debug("add_coalescing_module")
add_hpx_library(parcel_coalescing
PLUGIN
SOURCES "${PROJECT_SOURCE_DIR}/plugins/parcel/coalescing/coalescing_message_handler.cpp"
HEADERS
"${PROJECT_SOURCE_DIR}/hpx/plugins/parcel/coalescing_message_handler.hpp"
"${PROJECT_SOURCE_DIR}/hpx/plugins/parcel/message_buffer.hpp"
FOLDER "Core/Plugins/MessageHandler"
)
if(HPX_WITH_PARCEL_COALESCING)
hpx_debug("add_coalescing_module")
add_hpx_library(parcel_coalescing
PLUGIN
SOURCES "${PROJECT_SOURCE_DIR}/plugins/parcel/coalescing/coalescing_message_handler.cpp"
HEADERS
"${PROJECT_SOURCE_DIR}/hpx/plugins/parcel/coalescing_message_handler.hpp"
"${PROJECT_SOURCE_DIR}/hpx/plugins/parcel/message_buffer.hpp"
FOLDER "Core/Plugins/MessageHandler"
)

add_hpx_pseudo_dependencies(plugins.parcel.coalescing parcel_coalescing_lib)
add_hpx_pseudo_dependencies(core plugins.parcel.coalescing)
add_hpx_pseudo_dependencies(plugins.parcel.coalescing parcel_coalescing_lib)
add_hpx_pseudo_dependencies(core plugins.parcel.coalescing)
endif()
endmacro()

46 changes: 45 additions & 1 deletion src/performance_counters/performance_counter.cpp
Expand Up @@ -38,7 +38,7 @@ namespace hpx { namespace performance_counters
{
return stubs::performance_counter::get_info_async(get_id());
}
counter_info performance_counter::get_info_sync(error_code& ec)
counter_info performance_counter::get_info_sync(error_code& ec) const
{
return stubs::performance_counter::get_info(get_id(), ec);
}
Expand Down Expand Up @@ -89,4 +89,48 @@ namespace hpx { namespace performance_counters
{
stubs::performance_counter::reset(get_id(), ec);
}

///
future<std::string> performance_counter::get_name() const
{
return lcos::make_future<std::string>(
get_info(),
[](counter_info && info) -> std::string
{
return info.fullname_;
});
}

std::string performance_counter::get_name_sync() const
{
return get_name().get();
}

///////////////////////////////////////////////////////////////////////////
/// Return all counters matching the given name (with optional wildcards).
std::vector<performance_counter>
discover_counters(std::string const& name, error_code& ec)
{
std::vector<performance_counter> counters;

std::vector<counter_info> infos;
counter_status status = discover_counter_type(name, infos,
discover_counters_full, ec);
if (!status_is_valid(status) || ec)
return counters;

try {
counters.reserve(infos.size());
for (counter_info const& info : infos)
{
performance_counter counter(info.fullname_);
counters.push_back(counter);
}
}
catch (hpx::exception const& e) {
HPX_RETHROWS_IF(ec, e, "discover_counters");
}

return counters;
}
}}
2 changes: 2 additions & 0 deletions tests/unit/parcelset/CMakeLists.txt
Expand Up @@ -11,11 +11,13 @@ set(tests
)

set(put_parcels_PARAMETERS LOCALITIES 2)
set(put_parcels_FLAGS DEPENDENCIES iostreams_component)
set(set_parcel_write_handler_PARAMETERS LOCALITIES 2)

if(HPX_WITH_PARCEL_COALESCING)
set(tests ${tests} put_parcels_with_coalescing)
set(put_parcels_with_coalescing_PARAMETERS LOCALITIES 2)
set(put_parcels_with_coalescing_FLAGS DEPENDENCIES iostreams_component)
endif()

foreach(test ${tests})
Expand Down
23 changes: 23 additions & 0 deletions tests/unit/parcelset/put_parcels.cpp
Expand Up @@ -5,6 +5,8 @@

#include <hpx/hpx.hpp>
#include <hpx/hpx_init.hpp>
#include <hpx/include/performance_counters.hpp>
#include <hpx/include/iostreams.hpp>
#include <hpx/util/lightweight_test.hpp>

///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -171,6 +173,23 @@ void test_mixed_arguments(hpx::id_type const& id)
}
}

///////////////////////////////////////////////////////////////////////////////
void print_counters(char const* name)
{
using namespace hpx::performance_counters;

std::vector<performance_counter> counters = discover_counters(name);

for (performance_counter const& c : counters)
{
counter_value value = c.get_counter_value_sync();
hpx::cout
<< "counter: " << c.get_name_sync()
<< ", value: " << value.get_value<double>()
<< std::endl;
}
}

///////////////////////////////////////////////////////////////////////////////
int hpx_main(boost::program_options::variables_map& vm)
{
Expand All @@ -188,6 +207,10 @@ int hpx_main(boost::program_options::variables_map& vm)
test_mixed_arguments(id);
}

// compare number of parcels with number of messages generated
print_counters("/parcels/count/*/sent");
print_counters("/messages/count/*/sent");

return hpx::finalize();
}

Expand Down
23 changes: 23 additions & 0 deletions tests/unit/parcelset/put_parcels_with_coalescing.cpp
Expand Up @@ -5,6 +5,8 @@

#include <hpx/hpx.hpp>
#include <hpx/hpx_init.hpp>
#include <hpx/include/performance_counters.hpp>
#include <hpx/include/iostreams.hpp>
#include <hpx/util/lightweight_test.hpp>

///////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -173,6 +175,23 @@ void test_mixed_arguments(hpx::id_type const& id)
}
}

///////////////////////////////////////////////////////////////////////////////
void print_counters(char const* name)
{
using namespace hpx::performance_counters;

std::vector<performance_counter> counters = discover_counters(name);

for (performance_counter const& c : counters)
{
counter_value value = c.get_counter_value_sync();
hpx::cout
<< "counter: " << c.get_name_sync()
<< ", value: " << value.get_value<double>()
<< std::endl;
}
}

///////////////////////////////////////////////////////////////////////////////
int hpx_main(boost::program_options::variables_map& vm)
{
Expand All @@ -190,6 +209,10 @@ int hpx_main(boost::program_options::variables_map& vm)
test_mixed_arguments(id);
}

// compare number of parcels with number of messages generated
print_counters("/parcels/count/*/sent");
print_counters("/messages/count/*/sent");

return hpx::finalize();
}

Expand Down

0 comments on commit d7527b6

Please sign in to comment.