-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Topdown metric support #318
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -96,6 +96,8 @@ struct Config | |||||||
bool use_nec; | ||||||||
std::chrono::microseconds nec_read_interval; | ||||||||
std::chrono::milliseconds nec_check_interval; | ||||||||
//topdown | ||||||||
bool topdown; | ||||||||
Comment on lines
+99
to
+100
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
}; | ||||||||
|
||||||||
const Config& config(); | ||||||||
|
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -25,6 +25,7 @@ | |||
#include <lo2s/monitor/poll_monitor.hpp> | ||||
|
||||
#include <lo2s/perf/counter/group/writer.hpp> | ||||
#include <lo2s/perf/counter/topdown/writer.hpp> | ||||
#include <lo2s/perf/counter/userspace/writer.hpp> | ||||
|
||||
#include <lo2s/perf/sample/writer.hpp> | ||||
|
@@ -74,6 +75,8 @@ class ScopeMonitor : public PollMonitor | |||
std::unique_ptr<perf::sample::Writer> sample_writer_; | ||||
std::unique_ptr<perf::counter::group::Writer> group_counter_writer_; | ||||
std::unique_ptr<perf::counter::userspace::Writer> userspace_counter_writer_; | ||||
|
||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
std::unique_ptr<perf::counter::topdown::Writer> topdown_writer_; | ||||
}; | ||||
} // namespace monitor | ||||
} // namespace lo2s |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,72 @@ | ||||||
/* | ||||||
* This file is part of the lo2s software. | ||||||
* Linux OTF2 sampling | ||||||
* | ||||||
* Copyright (c) 2021, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
* Technische Universitaet Dresden, Germany | ||||||
* | ||||||
* lo2s is free software: you can redistribute it and/or modify | ||||||
* it under the terms of the GNU General Public License as published by | ||||||
* the Free Software Foundation, either version 3 of the License, or | ||||||
* (at your option) any later version. | ||||||
* | ||||||
* lo2s is distributed in the hope that it will be useful, | ||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||||
* GNU General Public License for more details. | ||||||
* | ||||||
* You should have received a copy of the GNU General Public License | ||||||
* along with lo2s. If not, see <http://www.gnu.org/licenses/>. | ||||||
*/ | ||||||
|
||||||
#pragma once | ||||||
|
||||||
#include <lo2s/execution_scope.hpp> | ||||||
#include <lo2s/perf/counter/counter_collection.hpp> | ||||||
#include <lo2s/trace/trace.hpp> | ||||||
|
||||||
#include <cstdint> | ||||||
|
||||||
#include <vector> | ||||||
|
||||||
#include <cstdlib> | ||||||
namespace lo2s | ||||||
{ | ||||||
namespace perf | ||||||
{ | ||||||
namespace counter | ||||||
{ | ||||||
namespace topdown | ||||||
{ | ||||||
struct TopdownEvent | ||||||
{ | ||||||
uint64_t nr; | ||||||
uint64_t slots; | ||||||
uint64_t retiring; | ||||||
uint64_t bad_spec; | ||||||
uint64_t fe_bound; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fe? |
||||||
uint64_t be_bound; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. be? |
||||||
}; | ||||||
|
||||||
template <class T> | ||||||
class Reader | ||||||
{ | ||||||
public: | ||||||
Reader(ExecutionScope scope); | ||||||
|
||||||
void read(); | ||||||
|
||||||
int fd() | ||||||
{ | ||||||
return timer_fd_; | ||||||
} | ||||||
|
||||||
protected: | ||||||
int leader_fd_; | ||||||
std::vector<int> counter_fds_; | ||||||
int timer_fd_; | ||||||
}; | ||||||
} // namespace topdown | ||||||
} // namespace counter | ||||||
} // namespace perf | ||||||
} // namespace lo2s |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,54 @@ | ||||||
/* | ||||||
* This file is part of the lo2s software. | ||||||
* Linux OTF2 sampling | ||||||
* | ||||||
* Copyright (c) 2018, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
* Technische Universitaet Dresden, Germany | ||||||
* | ||||||
* lo2s is free software: you can redistribute it and/or modify | ||||||
* it under the terms of the GNU General Public License as published by | ||||||
* the Free Software Foundation, either version 3 of the License, or | ||||||
* (at your option) any later version. | ||||||
* | ||||||
* lo2s is distributed in the hope that it will be useful, | ||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||||
* GNU General Public License for more details. | ||||||
* | ||||||
* You should have received a copy of the GNU General Public License | ||||||
* along with lo2s. If not, see <http://www.gnu.org/licenses/>. | ||||||
*/ | ||||||
|
||||||
#pragma once | ||||||
|
||||||
#include <lo2s/perf/counter/counter_collection.hpp> | ||||||
#include <lo2s/perf/counter/metric_writer.hpp> | ||||||
#include <lo2s/perf/counter/topdown/reader.hpp> | ||||||
#include <lo2s/perf/time/converter.hpp> | ||||||
#include <lo2s/trace/trace.hpp> | ||||||
|
||||||
namespace lo2s | ||||||
{ | ||||||
namespace perf | ||||||
{ | ||||||
namespace counter | ||||||
{ | ||||||
namespace topdown | ||||||
{ | ||||||
class Writer : public Reader<Writer> | ||||||
{ | ||||||
public: | ||||||
Writer(ExecutionScope scope, trace::Trace& trace); | ||||||
|
||||||
bool handle(TopdownEvent* ev); | ||||||
|
||||||
private: | ||||||
time::Converter time_converter_; | ||||||
otf2::writer::local& writer_; | ||||||
otf2::definition::metric_instance metric_instance_; | ||||||
otf2::event::metric metric_event_; | ||||||
}; | ||||||
} // namespace topdown | ||||||
} // namespace counter | ||||||
} // namespace perf | ||||||
} // namespace lo2s |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,6 +130,7 @@ class Trace | |
otf2::definition::mapping_table merge_syscall_contexts(const std::set<int64_t>& used_syscalls); | ||
|
||
otf2::writer::local& sample_writer(const ExecutionScope& scope); | ||
otf2::writer::local& topdown_writer(const ExecutionScope& scope); | ||
otf2::writer::local& metric_writer(const MeasurementScope& scope); | ||
otf2::writer::local& syscall_writer(const Cpu& cpu); | ||
otf2::writer::local& bio_writer(BlockDevice dev); | ||
|
@@ -169,6 +170,32 @@ class Trace | |
return cpuid_metric_class_; | ||
} | ||
|
||
otf2::definition::metric_class topdown_metric_class() | ||
{ | ||
if (!topdown_metric_class_) | ||
{ | ||
topdown_metric_class_ = registry_.create<otf2::definition::metric_class>( | ||
otf2::common::metric_occurence::async, otf2::common::recorder_kind::abstract); | ||
topdown_metric_class_->add_member(metric_member( | ||
"slots", "Number of UOPS slots", otf2::common::metric_mode::absolute_point, | ||
otf2::common::type::int64, "slots")); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the second |
||
topdown_metric_class_->add_member(metric_member( | ||
"retiring", "Number of UOPS retired", otf2::common::metric_mode::absolute_point, | ||
otf2::common::type::int64, "slots")); | ||
topdown_metric_class_->add_member(metric_member( | ||
"bad_spec", "Number of UOPS lost to bad speculation", | ||
otf2::common::metric_mode::absolute_point, otf2::common::type::int64, "slots")); | ||
topdown_metric_class_->add_member(metric_member( | ||
"fe_bound", "Number of front-end bound UOPS", | ||
otf2::common::metric_mode::absolute_point, otf2::common::type::int64, "slots")); | ||
topdown_metric_class_->add_member(metric_member( | ||
"be_bound", "Number of back-end bound UOPS", | ||
otf2::common::metric_mode::absolute_point, otf2::common::type::int64, "slots")); | ||
} | ||
|
||
return topdown_metric_class_; | ||
} | ||
|
||
otf2::definition::metric_member& get_event_metric_member(perf::EventDescription event) | ||
{ | ||
return registry_.emplace<otf2::definition::metric_member>( | ||
|
@@ -347,6 +374,7 @@ class Trace | |
otf2::definition::regions_group& syscall_regions_group_; | ||
|
||
otf2::definition::detail::weak_ref<otf2::definition::metric_class> cpuid_metric_class_; | ||
otf2::definition::detail::weak_ref<otf2::definition::metric_class> topdown_metric_class_; | ||
std::map<std::set<Cpu>, otf2::definition::detail::weak_ref<otf2::definition::metric_class>> | ||
perf_group_metric_classes_; | ||
std::map<std::set<Cpu>, otf2::definition::detail::weak_ref<otf2::definition::metric_class>> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -161,6 +161,7 @@ void parse_program_options(int argc, const char** argv) | |
auto& sensors_options = parser.group("sensors options"); | ||
auto& io_options = parser.group("I/O recording options"); | ||
auto& nec_options = parser.group("NEC SX-Aurora Tsubasa recording options"); | ||
auto& topdown_options = parser.group("Topdown metrics recording options"); | ||
|
||
lo2s::Config config; | ||
|
||
|
@@ -344,6 +345,8 @@ void parse_program_options(int argc, const char** argv) | |
.metavar("MSEC") | ||
.default_value("100"); | ||
|
||
topdown_options.toggle("topdown", "Enable recording of topdown metrics"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a special perf metric. No need for groups of one. |
||
|
||
nitro::options::arguments arguments; | ||
try | ||
{ | ||
|
@@ -370,6 +373,7 @@ void parse_program_options(int argc, const char** argv) | |
config.use_sensors = arguments.given("sensors"); | ||
config.use_block_io = arguments.given("block-io"); | ||
config.use_nec = arguments.given("nec"); | ||
config.topdown = arguments.given("topdown"); | ||
config.command = arguments.positionals(); | ||
|
||
if (arguments.given("help")) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,6 +72,11 @@ ScopeMonitor::ScopeMonitor(ExecutionScope scope, MainMonitor& parent, bool enabl | |
add_fd(userspace_counter_writer_->fd()); | ||
} | ||
|
||
if(config().topdown) | ||
{ | ||
topdown_writer_ = std::make_unique<perf::counter::topdown::Writer>(scope, parent.trace()); | ||
add_fd(topdown_writer_->fd()); | ||
Comment on lines
+77
to
+78
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. clang-format |
||
} | ||
// note: start() can now be called | ||
} | ||
|
||
|
@@ -116,6 +121,10 @@ void ScopeMonitor::monitor(int fd) | |
{ | ||
userspace_counter_writer_->read(); | ||
} | ||
if (fd == topdown_writer_->fd()) | ||
{ | ||
topdown_writer_->read(); | ||
} | ||
} | ||
} // namespace monitor | ||
} // namespace lo2s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
random new line?