A bit of reformatting code

This commit is contained in:
Andrey Skobtsov 2020-04-23 21:46:19 +03:00
parent 30a87a8a58
commit 0cf949f1b5
2 changed files with 20 additions and 15 deletions

View File

@ -258,11 +258,6 @@ namespace DB
current_thread_counters = nullptr; current_thread_counters = nullptr;
} }
Logger * PerfDescriptorsHolder::getLogger()
{
return &Logger::get("PerfDescriptorsHolder");
}
PerfDescriptorsHolder::PerfDescriptorsHolder() PerfDescriptorsHolder::PerfDescriptorsHolder()
{ {
for (int & descriptor : descriptors) for (int & descriptor : descriptors)
@ -285,6 +280,12 @@ namespace DB
descriptor = -1; descriptor = -1;
} }
} }
Logger * PerfDescriptorsHolder::getLogger()
{
return &Logger::get("PerfDescriptorsHolder");
}
#else #else
void PerfEventsCounters::initializeProfileEvents(PerfEventsCounters &) {} void PerfEventsCounters::initializeProfileEvents(PerfEventsCounters &) {}

View File

@ -153,8 +153,6 @@ struct PerfEventInfo
ProfileEvents::Event profile_event; ProfileEvents::Event profile_event;
}; };
#endif
struct PerfDescriptorsHolder; struct PerfDescriptorsHolder;
struct PerfEventsCounters struct PerfEventsCounters
@ -172,17 +170,14 @@ struct PerfEventsCounters
// that restricts perf_event_open() to processes with the CAP_SYS_ADMIN capability // that restricts perf_event_open() to processes with the CAP_SYS_ADMIN capability
// todo: check whether perf_event_open() is available with CAP_SYS_ADMIN // todo: check whether perf_event_open() is available with CAP_SYS_ADMIN
#if defined(__linux__)
static constexpr size_t NUMBER_OF_RAW_EVENTS = 18; static constexpr size_t NUMBER_OF_RAW_EVENTS = 18;
static const PerfEventInfo raw_events_info[]; static const PerfEventInfo raw_events_info[];
#endif
static void initializeProfileEvents(PerfEventsCounters & counters); static void initializeProfileEvents(PerfEventsCounters & counters);
static void finalizeProfileEvents(PerfEventsCounters & counters, ProfileEvents::Counters & profile_events); static void finalizeProfileEvents(PerfEventsCounters & counters, ProfileEvents::Counters & profile_events);
#if defined(__linux__)
private: private:
// used to write information about perf unavailability only once for all threads // used to write information about perf unavailability only once for all threads
static std::atomic<bool> perf_unavailability_logged; static std::atomic<bool> perf_unavailability_logged;
@ -201,21 +196,30 @@ private:
static bool initializeThreadLocalEvents(PerfEventsCounters & counters); static bool initializeThreadLocalEvents(PerfEventsCounters & counters);
[[nodiscard]] UInt64 getRawValue(int event_type, int event_config) const; [[nodiscard]] UInt64 getRawValue(int event_type, int event_config) const;
#endif
}; };
#if defined(__linux__)
struct PerfDescriptorsHolder { struct PerfDescriptorsHolder {
static Logger * getLogger();
int descriptors[PerfEventsCounters::NUMBER_OF_RAW_EVENTS]{}; int descriptors[PerfEventsCounters::NUMBER_OF_RAW_EVENTS]{};
PerfDescriptorsHolder(); PerfDescriptorsHolder();
~PerfDescriptorsHolder(); ~PerfDescriptorsHolder();
static Logger * getLogger();
}; };
#else
struct PerfEventsCounters
{
static void initializeProfileEvents(PerfEventsCounters & counters);
static void finalizeProfileEvents(PerfEventsCounters & counters, ProfileEvents::Counters & profile_events);
};
#endif
#if defined(__linux__)
struct TasksStatsCounters struct TasksStatsCounters
{ {
::taskstats stat; ::taskstats stat;