Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

Commit

Permalink
perf_counter: code refactor (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
shengofsun committed Jul 6, 2018
1 parent dab2ea5 commit acf7545
Show file tree
Hide file tree
Showing 44 changed files with 190 additions and 1,338 deletions.
2 changes: 1 addition & 1 deletion include/dsn/dist/failure_detector/failure_detector.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@

#include <dsn/dist/failure_detector/fd.client.h>
#include <dsn/dist/failure_detector/fd.server.h>
#include <dsn/cpp/perf_counter_wrapper.h>
#include <dsn/perf_counter/perf_counter_wrapper.h>

namespace dsn {
namespace fd {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#include <dsn/utility/enum_helper.h>
#include <dsn/utility/autoref_ptr.h>
#include <dsn/utility/dlib.h>
#include <dsn/service_api_c.h>
#include <memory>
#include <sstream>
#include <vector>
Expand Down Expand Up @@ -89,20 +88,6 @@ typedef ref_ptr<perf_counter> perf_counter_ptr;

class perf_counter : public ref_counter
{
public:
template <typename T>
static perf_counter *create(const char *app,
const char *section,
const char *name,
dsn_perf_counter_type_t type,
const char *dsptr)
{
return new T(app, section, name, type, dsptr);
}

typedef perf_counter *(*factory)(
const char *, const char *, const char *, dsn_perf_counter_type_t, const char *);

public:
perf_counter(const char *app,
const char *section,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@

#pragma once

#include <dsn/service_api_c.h>
#include <dsn/tool-api/perf_counter.h>
#include <dsn/tool-api/perf_counters.h>
#include <dsn/perf_counter/perf_counter.h>
#include <dsn/perf_counter/perf_counters.h>

namespace dsn {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@

#pragma once

#include <dsn/tool-api/perf_counter.h>
#include <dsn/utility/singleton.h>
#include <dsn/utility/synchronize.h>
#include <dsn/perf_counter/perf_counter.h>
#include <map>
#include <sstream>
#include <queue>
Expand Down Expand Up @@ -68,8 +68,6 @@ class perf_counters : public dsn::utils::singleton<perf_counters>
// get all the existed perf counters, useful for monitor system
void get_all_counters(/*out*/ std::vector<dsn::perf_counter_ptr> *counter_vec);

void register_factory(perf_counter::factory factory);

static std::string list_counter(const std::vector<std::string> &args);
static std::string get_counter_value(const std::vector<std::string> &args);
static std::string get_counter_sample(const std::vector<std::string> &args);
Expand All @@ -78,6 +76,11 @@ class perf_counters : public dsn::utils::singleton<perf_counters>
// full_name = perf_counter::build_full_name(...);
perf_counter_ptr get_counter(const char *full_name);
std::string list_counter_internal(const std::vector<std::string> &args);
perf_counter *new_counter(const char *app,
const char *section,
const char *name,
dsn_perf_counter_type_t type,
const char *dsptr);

mutable utils::rw_lock_nr _lock;

Expand All @@ -92,7 +95,6 @@ class perf_counters : public dsn::utils::singleton<perf_counters>
int user_reference;
};
std::map<std::string, counter_object> _counters;
perf_counter::factory _factory;
};

} // end namespace dsn::utils
2 changes: 0 additions & 2 deletions include/dsn/tool-api/global_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ struct service_spec
std::string rwlock_nr_factory_name;
std::string semaphore_factory_name;
std::string nfs_factory_name;
std::string perf_counter_factory_name;
std::string logging_factory_name;

std::list<std::string> network_aspects; // toollets compatible to the above network main
Expand Down Expand Up @@ -211,7 +210,6 @@ CONFIG_FLD_STRING(lock_nr_factory_name, "", "non-recurisve exclusive lock provid
CONFIG_FLD_STRING(rwlock_nr_factory_name, "", "non-recurisve rwlock provider")
CONFIG_FLD_STRING(semaphore_factory_name, "", "semaphore provider")
CONFIG_FLD_STRING(nfs_factory_name, "", "nfs provider")
CONFIG_FLD_STRING(perf_counter_factory_name, "", "peformance counter provider")
CONFIG_FLD_STRING(logging_factory_name, "", "logging provider")

CONFIG_FLD_STRING_LIST(network_aspects, "network aspect providers, usually for tooling purpose")
Expand Down
2 changes: 1 addition & 1 deletion include/dsn/tool-api/task_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#pragma once

#include <dsn/tool-api/task.h>
#include <dsn/cpp/perf_counter_wrapper.h>
#include <dsn/perf_counter/perf_counter_wrapper.h>
#include <dsn/utility/dlib.h>

namespace dsn {
Expand Down
2 changes: 1 addition & 1 deletion include/dsn/tool-api/task_spec.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#include <dsn/utility/extensible_object.h>
#include <dsn/utility/exp_delay.h>
#include <dsn/utility/dlib.h>
#include <dsn/tool-api/perf_counter.h>
#include <dsn/perf_counter/perf_counter.h>
#include <dsn/tool-api/auto_codes.h>

ENUM_BEGIN(dsn_log_level_t, LOG_LEVEL_INVALID)
Expand Down
2 changes: 1 addition & 1 deletion include/dsn/tool-api/task_worker.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#include <dsn/utility/extensible_object.h>
#include <dsn/utility/synchronize.h>
#include <dsn/utility/dlib.h>
#include <dsn/tool-api/perf_counter.h>
#include <dsn/perf_counter/perf_counter.h>
#include <thread>

namespace dsn {
Expand Down
2 changes: 0 additions & 2 deletions include/dsn/tool_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,6 @@ DSN_API bool
register_component_provider(const char *name, aio_provider::factory f, ::dsn::provider_type type);
DSN_API bool
register_component_provider(const char *name, env_provider::factory f, ::dsn::provider_type type);
DSN_API bool
register_component_provider(const char *name, perf_counter::factory f, ::dsn::provider_type type);
DSN_API bool register_component_provider(const char *name,
logging_provider::factory f,
::dsn::provider_type type);
Expand Down
3 changes: 0 additions & 3 deletions src/apps/echo/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,6 @@ nfs_io_mode =
; whether to pause at startup time for easier debugging
pause_on_start = false

; peformance counter provider
perf_counter_factory_name =

; how many rpc engines? IOE_PER_NODE, or IOE_PER_QUEUE
rpc_io_mode =

Expand Down
2 changes: 1 addition & 1 deletion src/apps/nfs/nfs_client_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include <deque>
#include <dsn/tool-api/nfs.h>
#include <dsn/tool-api/task_tracker.h>
#include <dsn/cpp/perf_counter_wrapper.h>
#include <dsn/perf_counter/perf_counter_wrapper.h>

namespace dsn {
namespace service {
Expand Down
2 changes: 1 addition & 1 deletion src/apps/nfs/nfs_server_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*/
#pragma once
#include <dsn/tool-api/task_tracker.h>
#include <dsn/cpp/perf_counter_wrapper.h>
#include <dsn/perf_counter/perf_counter_wrapper.h>
#include "nfs_server.h"
#include "nfs_client_impl.h"

Expand Down
1 change: 1 addition & 0 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
add_definitions(-DDSN_IN_CORE)
set(DSN_IN_CORE "TRUE")
add_subdirectory(core)
add_subdirectory(perf_counter)
add_subdirectory(tools)
add_subdirectory(runtime)
add_subdirectory(tests)
Expand Down
2 changes: 1 addition & 1 deletion src/core/core/disk_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*/

#include "disk_engine.h"
#include <dsn/tool-api/perf_counter.h>
#include <dsn/perf_counter/perf_counter.h>
#include <dsn/tool-api/aio_provider.h>
#include <dsn/utility/utils.h>
#include <dsn/utility/transient_memory.h>
Expand Down
2 changes: 1 addition & 1 deletion src/core/core/rpc_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#include "rpc_engine.h"
#include "service_engine.h"
#include <dsn/utility/factory_store.h>
#include <dsn/tool-api/perf_counter.h>
#include <dsn/perf_counter/perf_counter.h>
#include <dsn/tool-api/group_address.h>
#include <dsn/tool-api/uri_address.h>
#include <dsn/tool-api/task_queue.h>
Expand Down
8 changes: 2 additions & 6 deletions src/core/core/service_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
#include <dsn/utility/factory_store.h>
#include <dsn/utility/filesystem.h>
#include <dsn/tool-api/command_manager.h>
#include <dsn/tool-api/perf_counter.h>
#include <dsn/tool-api/perf_counters.h>
#include <dsn/perf_counter/perf_counter.h>
#include <dsn/perf_counter/perf_counters.h>
#include <dsn/tool_api.h>
#include <dsn/tool/node_scoper.h>

Expand Down Expand Up @@ -256,10 +256,6 @@ void service_engine::init_before_toollets(const service_spec &spec)
_logging = factory_store<logging_provider>::create(
spec.logging_factory_name.c_str(), ::dsn::PROVIDER_TYPE_MAIN, spec.dir_log.c_str());

perf_counters::instance().register_factory(
factory_store<perf_counter>::get_factory<perf_counter::factory>(
spec.perf_counter_factory_name.c_str(), ::dsn::PROVIDER_TYPE_MAIN));

// init common for all per-node providers
message_ex::s_local_hash =
(uint32_t)dsn_config_get_value_uint64("core",
Expand Down
2 changes: 1 addition & 1 deletion src/core/core/task_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*/

#include "task_engine.h"
#include <dsn/tool-api/perf_counter.h>
#include <dsn/perf_counter/perf_counter.h>
#include <dsn/utility/factory_store.h>

using namespace dsn::utils;
Expand Down
2 changes: 1 addition & 1 deletion src/core/core/task_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include "service_engine.h"
#include <dsn/tool-api/task_queue.h>
#include <dsn/tool-api/admission_controller.h>
#include <dsn/tool-api/perf_counter.h>
#include <dsn/perf_counter/perf_counter.h>
#include <dsn/tool-api/task_worker.h>
#include <dsn/tool-api/timer_service.h>

Expand Down
2 changes: 1 addition & 1 deletion src/core/core/task_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

#include <dsn/tool-api/task_queue.h>
#include "task_engine.h"
#include <dsn/tool-api/perf_counters.h>
#include <dsn/perf_counter/perf_counters.h>
#include <dsn/tool-api/network.h>
#include <cstdio>
#include "rpc_engine.h"
Expand Down
2 changes: 1 addition & 1 deletion src/core/core/task_spec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

#include <dsn/tool-api/task_spec.h>
#include <dsn/utility/singleton.h>
#include <dsn/tool-api/perf_counter.h>
#include <dsn/perf_counter/perf_counter.h>
#include <dsn/tool-api/command_manager.h>
#include <sstream>
#include <vector>
Expand Down
7 changes: 0 additions & 7 deletions src/core/core/tool_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,6 @@ bool register_component_provider(const char *name,
return dsn::utils::factory_store<env_provider>::register_factory(name, f, type);
}

bool register_component_provider(const char *name,
perf_counter::factory f,
::dsn::provider_type type)
{
return dsn::utils::factory_store<perf_counter>::register_factory(name, f, type);
}

bool register_component_provider(const char *name, nfs_node::factory f, ::dsn::provider_type type)
{
return dsn::utils::factory_store<nfs_node>::register_factory(name, f, type);
Expand Down
19 changes: 19 additions & 0 deletions src/core/perf_counter/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
set(MY_PROJ_NAME dsn.perf_counter)

set(MY_PROJ_SRC "")

# Search mode for source files under CURRENT project directory?
# "GLOB_RECURSE" for recursive search
# "GLOB" for non-recursive search
set(MY_SRC_SEARCH_MODE "GLOB")

set(MY_PROJ_INC_PATH "")

set(MY_PROJ_LIBS "")

set(MY_PROJ_LIB_PATH "")

# Extra files that will be installed
set(MY_BINPLACES "")

dsn_add_object()
Loading

0 comments on commit acf7545

Please sign in to comment.