[rocprofiler-systems] Add cached demangler and replace old demangle (#2135)
* Add cached demangler and replace old * Add unit tests * Applied suggestions from code review * Applied suggestions from code review
This commit is contained in:
committed by
GitHub
parent
21afa807a9
commit
666e76deac
@@ -30,6 +30,7 @@
|
||||
#include "core/config.hpp"
|
||||
#include "core/containers/c_array.hpp"
|
||||
#include "core/debug.hpp"
|
||||
#include "core/demangler.hpp"
|
||||
#include "core/state.hpp"
|
||||
#include "core/utility.hpp"
|
||||
#include "library/causal/delay.hpp"
|
||||
@@ -399,7 +400,8 @@ save_line_info_impl(std::ostream& _ofs,
|
||||
_ofs << " " << as_hex(_addr_off) << " [" << as_hex(_addr)
|
||||
<< "] :: " << itr.file;
|
||||
if(itr.line > 0) _ofs << ":" << itr.line;
|
||||
if(!itr.func.empty()) _ofs << " [" << tim::demangle(itr.func) << "]";
|
||||
if(!itr.func.empty())
|
||||
_ofs << " [" << rocprofsys::utility::demangle(itr.func) << "]";
|
||||
_ofs << "\n";
|
||||
|
||||
if(std::get<0>(_info))
|
||||
@@ -408,7 +410,7 @@ save_line_info_impl(std::ostream& _ofs,
|
||||
{
|
||||
_ofs << " " << ditr.file << ":" << ditr.line;
|
||||
if(!ditr.func.empty())
|
||||
_ofs << " [" << tim::demangle(ditr.func) << "]";
|
||||
_ofs << " [" << rocprofsys::utility::demangle(ditr.func) << "]";
|
||||
_ofs << "\n";
|
||||
}
|
||||
}
|
||||
@@ -608,14 +610,16 @@ perform_experiment_impl(std::shared_ptr<std::promise<void>> _started) // NOLINT
|
||||
<< " :: " << std::setw(5) << std::boolalpha
|
||||
<< _is_eligible << " :: " << as_hex(itr.first) << " "
|
||||
<< _linfo->location << ":" << _linfo->lineno << " ["
|
||||
<< demangle(_linfo->name) << "]\n";
|
||||
<< rocprofsys::utility::demangle(_linfo->name)
|
||||
<< "]\n";
|
||||
for(const auto& iitr : _linfo->lineinfo.lines)
|
||||
{
|
||||
_sample << " " << std::setw(8) << itr.second
|
||||
<< " :: " << std::setw(5) << std::boolalpha
|
||||
<< _is_eligible << " :: " << as_hex(itr.first)
|
||||
<< " " << iitr.location << ":" << iitr.line
|
||||
<< " [" << demangle(iitr.name) << "]\n";
|
||||
_sample
|
||||
<< " " << std::setw(8) << itr.second
|
||||
<< " :: " << std::setw(5) << std::boolalpha
|
||||
<< _is_eligible << " :: " << as_hex(itr.first) << " "
|
||||
<< iitr.location << ":" << iitr.line << " ["
|
||||
<< rocprofsys::utility::demangle(iitr.name) << "]\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -839,8 +843,9 @@ sample_selection(size_t _nitr, size_t _wait_ns)
|
||||
as_hex(_lookup_addr).c_str(), as_hex(_addr).c_str(),
|
||||
as_hex(_sym_addr).c_str(),
|
||||
(_location.empty()) ? "" : _location.data(),
|
||||
demangle(itr.func).c_str(), itr.file.c_str(), itr.line,
|
||||
itr.address.as_string().c_str(), itr.address.size());
|
||||
rocprofsys::utility::demangle(itr.func).c_str(),
|
||||
itr.file.c_str(), itr.line, itr.address.as_string().c_str(),
|
||||
itr.address.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "common/defines.h"
|
||||
#include "core/config.hpp"
|
||||
#include "core/debug.hpp"
|
||||
#include "core/demangler.hpp"
|
||||
#include "core/state.hpp"
|
||||
#include "library/causal/components/backtrace.hpp"
|
||||
#include "library/causal/components/progress_point.hpp"
|
||||
@@ -127,7 +128,7 @@ experiment::sample::serialize(ArchiveT& ar, const unsigned)
|
||||
|
||||
if constexpr(concepts::is_output_archive<ArchiveT>::value)
|
||||
{
|
||||
ar(cereal::make_nvp("dfunc", demangle(name)),
|
||||
ar(cereal::make_nvp("dfunc", rocprofsys::utility::demangle(name)),
|
||||
cereal::make_nvp("dwarf_info", std::vector<binary::dwarf_entry>{}));
|
||||
}
|
||||
ar(cereal::make_nvp("inlines", inlines));
|
||||
@@ -140,7 +141,7 @@ std::string
|
||||
experiment::sample::get_identifier() const
|
||||
{
|
||||
return (lineno > 0 && !location.empty()) ? join(":", location, lineno)
|
||||
: demangle(name);
|
||||
: rocprofsys::utility::demangle(name);
|
||||
}
|
||||
|
||||
template <typename ArchiveT>
|
||||
@@ -391,7 +392,7 @@ experiment::as_string() const
|
||||
}
|
||||
return _v;
|
||||
};
|
||||
auto _func = _patch(demangle(selection.symbol.func));
|
||||
auto _func = _patch(rocprofsys::utility::demangle(selection.symbol.func));
|
||||
_ss << "['" << _func << "']";
|
||||
|
||||
return _ss.str();
|
||||
@@ -620,7 +621,7 @@ experiment::save_experiments(std::string _fname_base, const filename_config_t& _
|
||||
as_hex(_line_info.address).c_str(), _line_info.file.c_str(),
|
||||
_line_info.line, _line_info.func.c_str());
|
||||
|
||||
ofs << "experiment\tselected=" << demangle(_name)
|
||||
ofs << "experiment\tselected=" << rocprofsys::utility::demangle(_name)
|
||||
<< "\tspeedup=" << std::setprecision(2)
|
||||
<< static_cast<double>(itr.virtual_speedup / 100.0)
|
||||
<< "\tduration=" << itr.duration << "\tselected-samples=" << itr.selected
|
||||
@@ -637,7 +638,8 @@ experiment::save_experiments(std::string _fname_base, const filename_config_t& _
|
||||
if(pitr.second.is_throughput_point() && pitr.second.get_delta() != 0)
|
||||
{
|
||||
ofs << "throughput-point\tname="
|
||||
<< tim::demangle(tim::get_hash_identifier(pitr.first))
|
||||
<< rocprofsys::utility::demangle(
|
||||
tim::get_hash_identifier(pitr.first))
|
||||
<< "\tdelta=" << pitr.second.get_delta() << "\n";
|
||||
if(get_causal_end_to_end()) break;
|
||||
}
|
||||
@@ -646,7 +648,8 @@ experiment::save_experiments(std::string _fname_base, const filename_config_t& _
|
||||
if(get_causal_end_to_end()) continue;
|
||||
auto _delta = std::max<int64_t>(pitr.second.get_latency_delta(), 1);
|
||||
ofs << "latency-point\tname="
|
||||
<< tim::demangle(tim::get_hash_identifier(pitr.first))
|
||||
<< rocprofsys::utility::demangle(
|
||||
tim::get_hash_identifier(pitr.first))
|
||||
<< "\tarrivals=" << pitr.second.get_arrival()
|
||||
<< "\tdepartures=" << pitr.second.get_departure()
|
||||
<< "\tdifference=" << _delta << "\n";
|
||||
|
||||
+2
-1
@@ -24,6 +24,7 @@
|
||||
#include "core/components/fwd.hpp"
|
||||
#include "core/config.hpp"
|
||||
#include "core/debug.hpp"
|
||||
#include "core/demangler.hpp"
|
||||
#include "core/perfetto.hpp"
|
||||
#include "core/state.hpp"
|
||||
#include "library/components/ensure_storage.hpp"
|
||||
@@ -150,7 +151,7 @@ backtrace::filter_and_patch(const std::vector<entry_type>& _data)
|
||||
_ret.reserve(_data.size());
|
||||
for(const auto& itr : _data)
|
||||
{
|
||||
auto _name = tim::demangle(_patch_label(itr.name));
|
||||
auto _name = rocprofsys::utility::demangle(_patch_label(itr.name));
|
||||
auto _use = _use_label(_name);
|
||||
if(_use == -1) break;
|
||||
if(_use == 0) continue;
|
||||
|
||||
+5
-2
@@ -24,6 +24,7 @@
|
||||
|
||||
#include "core/config.hpp"
|
||||
#include "core/defines.hpp"
|
||||
#include "core/demangler.hpp"
|
||||
#include "core/state.hpp"
|
||||
#include "core/timemory.hpp"
|
||||
#include "core/trace_cache/cache_manager.hpp"
|
||||
@@ -403,7 +404,8 @@ category_region<CategoryT>::audit(const gotcha_data_t& _data, audit::incoming,
|
||||
{
|
||||
int64_t _n = 0;
|
||||
ROCPROFSYS_FOLD_EXPRESSION(tracing::add_perfetto_annotation(
|
||||
ctx, tim::try_demangle<std::remove_reference_t<Args>>(), _args, _n++));
|
||||
ctx, rocprofsys::utility::demangle<std::remove_reference_t<Args>>(),
|
||||
_args, _n++));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -431,7 +433,8 @@ category_region<CategoryT>::audit(std::string_view _name, audit::incoming,
|
||||
{
|
||||
int64_t _n = 0;
|
||||
ROCPROFSYS_FOLD_EXPRESSION(tracing::add_perfetto_annotation(
|
||||
ctx, tim::try_demangle<std::remove_reference_t<Args>>(), _args, _n++));
|
||||
ctx, rocprofsys::utility::demangle<std::remove_reference_t<Args>>(),
|
||||
_args, _n++));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "core/demangler.hpp"
|
||||
#include "core/timemory.hpp"
|
||||
|
||||
#include <timemory/components/base.hpp>
|
||||
@@ -184,7 +185,8 @@ rocprofsys::component::activate_mpip()
|
||||
|
||||
static std::string _label = []() {
|
||||
std::stringstream ss;
|
||||
ss << "rocprofsys-mpip-" << demangle<Toolset>() << "-" << demangle<Tag>();
|
||||
ss << "rocprofsys-mpip-" << rocprofsys::utility::demangle<Toolset>() << "-"
|
||||
<< rocprofsys::utility::demangle<Tag>();
|
||||
return ss.str();
|
||||
}();
|
||||
ROCPROFSYS_BASIC_DEBUG_F("Adding cleanup for %s", _label.c_str());
|
||||
@@ -208,7 +210,8 @@ rocprofsys::component::deactivate_mpip(uint64_t id)
|
||||
{
|
||||
static std::string _label = []() {
|
||||
std::stringstream ss;
|
||||
ss << "rocprofsys-mpip-" << demangle<Toolset>() << "-" << demangle<Tag>();
|
||||
ss << "rocprofsys-mpip-" << rocprofsys::utility::demangle<Toolset>() << "-"
|
||||
<< rocprofsys::utility::demangle<Tag>();
|
||||
return ss.str();
|
||||
}();
|
||||
ROCPROFSYS_BASIC_DEBUG_F("Removing cleanup for %s", _label.c_str());
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "core/config.hpp"
|
||||
#include "core/containers/stable_vector.hpp"
|
||||
#include "core/debug.hpp"
|
||||
#include "core/demangler.hpp"
|
||||
#include "core/gpu.hpp"
|
||||
#include "core/perfetto.hpp"
|
||||
#include "core/state.hpp"
|
||||
@@ -335,8 +336,9 @@ iterate_args_callback(rocprofiler_callback_tracing_kind_t /*kind*/, int32_t /*op
|
||||
{
|
||||
auto* _data = static_cast<function_args_t*>(data);
|
||||
if(arg_type && arg_name && arg_value_str)
|
||||
_data->emplace_back(
|
||||
argument_info{ arg_number, demangle(arg_type), arg_name, arg_value_str });
|
||||
_data->emplace_back(argument_info{ arg_number,
|
||||
rocprofsys::utility::demangle(arg_type),
|
||||
arg_name, arg_value_str });
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -388,8 +390,8 @@ get_backtrace(std::optional<std::vector<tim::unwind::processed_entry>>& _bt_data
|
||||
(_linfo && _linfo.line > 0)
|
||||
? join("", _linfo.line)
|
||||
: ((itr.lineno == 0) ? std::string{ "?" } : join("", itr.lineno));
|
||||
auto _entry = join("", demangle(*_func), " @ ",
|
||||
join(':', ::basename(_loc->c_str()), _line));
|
||||
auto _entry = join("", rocprofsys::utility::demangle(*_func), " @ ",
|
||||
join(':', ::basename(_loc->c_str()), _line));
|
||||
backtrace[join("", "frame#", _bt_cnt++)] = _entry;
|
||||
}
|
||||
}
|
||||
@@ -771,7 +773,7 @@ tool_tracing_callback_stop(
|
||||
: ((itr.lineno == 0) ? std::string{ "?" }
|
||||
: join("", itr.lineno));
|
||||
auto _entry =
|
||||
join("", demangle(*_func), " @ ",
|
||||
join("", rocprofsys::utility::demangle(*_func), " @ ",
|
||||
join(':', ::basename(_loc->c_str()), _line));
|
||||
if(_bt_cnt < 10)
|
||||
{
|
||||
@@ -1139,12 +1141,13 @@ ompt_tracing_callback_stop(
|
||||
(_linfo && !_linfo.location.empty())
|
||||
? &_linfo.location
|
||||
: ((itr.location.empty()) ? &_unk : &itr.location);
|
||||
auto _line = (_linfo && _linfo.line > 0)
|
||||
? join("", _linfo.line)
|
||||
: ((itr.lineno == 0) ? std::string{ "?" }
|
||||
: join("", itr.lineno));
|
||||
auto _entry = join("", demangle(*_func), " @ ",
|
||||
join(':', ::basename(_loc->c_str()), _line));
|
||||
auto _line = (_linfo && _linfo.line > 0)
|
||||
? join("", _linfo.line)
|
||||
: ((itr.lineno == 0) ? std::string{ "?" }
|
||||
: join("", itr.lineno));
|
||||
auto _entry =
|
||||
join("", rocprofsys::utility::demangle(*_func), " @ ",
|
||||
join(':', ::basename(_loc->c_str()), _line));
|
||||
if(_bt_cnt < 10)
|
||||
{
|
||||
// Prepend zero for better ordering in UI. Only one zero
|
||||
@@ -1570,13 +1573,13 @@ tool_tracing_buffered(rocprofiler_context_id_t /*context*/,
|
||||
const auto* _kern_sym_data =
|
||||
get_kernel_symbol_info(record->dispatch_info.kernel_id);
|
||||
|
||||
auto _name = tim::demangle(_kern_sym_data->kernel_name);
|
||||
auto _stack_id = record->correlation_id.internal;
|
||||
auto _beg_ns = record->start_timestamp;
|
||||
auto _end_ns = record->end_timestamp;
|
||||
auto _agent_id = record->dispatch_info.agent_id;
|
||||
auto _queue_id = record->dispatch_info.queue_id;
|
||||
const auto* _agent = tool_data->get_gpu_tool_agent(_agent_id);
|
||||
auto _name = rocprofsys::utility::demangle(_kern_sym_data->kernel_name);
|
||||
auto _stack_id = record->correlation_id.internal;
|
||||
auto _beg_ns = record->start_timestamp;
|
||||
auto _end_ns = record->end_timestamp;
|
||||
auto _agent_id = record->dispatch_info.agent_id;
|
||||
auto _queue_id = record->dispatch_info.queue_id;
|
||||
const auto* _agent = tool_data->get_gpu_tool_agent(_agent_id);
|
||||
|
||||
uint64_t _stream_id = get_stream_id(record).handle;
|
||||
if(_stream_id == 0)
|
||||
|
||||
+4
-1
@@ -22,6 +22,7 @@
|
||||
|
||||
#include "library/rocprofiler-sdk/counters.hpp"
|
||||
#include "core/agent_manager.hpp"
|
||||
#include "core/demangler.hpp"
|
||||
#include "core/trace_cache/cache_manager.hpp"
|
||||
#include "core/trace_cache/metadata_registry.hpp"
|
||||
#include "library/rocprofiler-sdk/fwd.hpp"
|
||||
@@ -94,7 +95,9 @@ counter_event::operator()(const client_data* tool_data, ::perfetto::CounterTrack
|
||||
const auto* _kern_sym_data =
|
||||
tool_data->get_kernel_symbol_info(_dispatch_info.kernel_id);
|
||||
|
||||
auto _bundle = counter_bundle_t{ tim::demangle(_kern_sym_data->kernel_name), _scope };
|
||||
auto _bundle =
|
||||
counter_bundle_t{ rocprofsys::utility::demangle(_kern_sym_data->kernel_name),
|
||||
_scope };
|
||||
|
||||
_bundle.push(_dispatch_info.queue_id.handle)
|
||||
.start()
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "core/components/fwd.hpp"
|
||||
#include "core/config.hpp"
|
||||
#include "core/debug.hpp"
|
||||
#include "core/demangler.hpp"
|
||||
#include "core/locking.hpp"
|
||||
#include "core/node_info.hpp"
|
||||
#include "core/perf.hpp"
|
||||
@@ -172,7 +173,7 @@ generate_call_stack_json(const tim::unwind::processed_entry& stack_entry)
|
||||
{
|
||||
nlohmann::json call_stack;
|
||||
|
||||
call_stack["name"] = std::string(demangle(stack_entry.name));
|
||||
call_stack["name"] = std::string(rocprofsys::utility::demangle(stack_entry.name));
|
||||
call_stack["pc"] = as_hex(stack_entry.address);
|
||||
call_stack["file"] = std::string(stack_entry.location);
|
||||
|
||||
@@ -184,7 +185,7 @@ generate_line_info_json(const tim::unwind::processed_entry& line_info_entry)
|
||||
{
|
||||
nlohmann::json line_info;
|
||||
line_info["line_address"] = as_hex(line_info_entry.line_address);
|
||||
line_info["name"] = std::string(demangle(line_info_entry.name));
|
||||
line_info["name"] = std::string(rocprofsys::utility::demangle(line_info_entry.name));
|
||||
|
||||
if(line_info_entry.lineinfo && !line_info_entry.lineinfo.lines.empty())
|
||||
{
|
||||
@@ -193,7 +194,7 @@ generate_line_info_json(const tim::unwind::processed_entry& line_info_entry)
|
||||
for(const auto& line : _lines)
|
||||
{
|
||||
nlohmann::json inlined;
|
||||
inlined["name"] = std::string(demangle(line.name));
|
||||
inlined["name"] = std::string(rocprofsys::utility::demangle(line.name));
|
||||
inlined["location"] = std::string(line.location);
|
||||
inlined["line"] = std::to_string(line.line);
|
||||
line_info["inlined"] = inlined;
|
||||
@@ -311,7 +312,7 @@ cache_sampling_data(int64_t _tid, const std::vector<timer_sampling_data>& _timer
|
||||
|
||||
for(const auto& iitr : itr.m_stack)
|
||||
{
|
||||
auto _name = std::string(demangle(iitr.name));
|
||||
auto _name = std::string(rocprofsys::utility::demangle(iitr.name));
|
||||
auto _track_name = get_track_name<category::timer_sampling>(*_thread_info);
|
||||
auto _call_stack = generate_call_stack_json(iitr);
|
||||
auto _line_info = generate_line_info_json(iitr);
|
||||
@@ -343,7 +344,7 @@ cache_sampling_data(int64_t _tid, const std::vector<timer_sampling_data>& _timer
|
||||
|
||||
for(const auto& iitr : itr.m_stack)
|
||||
{
|
||||
auto _name = std::string(demangle(iitr.name));
|
||||
auto _name = std::string(rocprofsys::utility::demangle(iitr.name));
|
||||
auto _track_name = get_track_name<category::overflow_sampling>(*_thread_info);
|
||||
auto _call_stack = generate_call_stack_json(iitr);
|
||||
auto _line_info = generate_line_info_json(iitr);
|
||||
@@ -1384,7 +1385,8 @@ post_process_perfetto(int64_t _tid, const std::vector<timer_sampling_data>& _tim
|
||||
for(const auto& iitr : itr.m_stack)
|
||||
{
|
||||
const auto* _name =
|
||||
static_strings.emplace(demangle(iitr.name)).first->c_str();
|
||||
static_strings.emplace(rocprofsys::utility::demangle(iitr.name))
|
||||
.first->c_str();
|
||||
tracing::push_perfetto_track(
|
||||
category::overflow_sampling{}, _name, _track, _beg,
|
||||
[&](::perfetto::EventContext ctx) {
|
||||
@@ -1405,7 +1407,8 @@ post_process_perfetto(int64_t _tid, const std::vector<timer_sampling_data>& _tim
|
||||
auto _label = JOIN('-', "lineinfo", _n++);
|
||||
tracing::add_perfetto_annotation(
|
||||
ctx, _label.c_str(),
|
||||
JOIN('@', demangle(line.name),
|
||||
JOIN('@',
|
||||
rocprofsys::utility::demangle(line.name),
|
||||
JOIN(':', line.location, line.line)));
|
||||
}
|
||||
}
|
||||
@@ -1496,7 +1499,9 @@ post_process_perfetto(int64_t _tid, const std::vector<timer_sampling_data>& _tim
|
||||
for(const auto& line : _lines)
|
||||
{
|
||||
const auto* _name =
|
||||
static_strings.emplace(demangle(line.name)).first->c_str();
|
||||
static_strings
|
||||
.emplace(rocprofsys::utility::demangle(line.name))
|
||||
.first->c_str();
|
||||
auto _info = JOIN(':', line.location, line.line);
|
||||
tracing::push_perfetto_track(
|
||||
category::timer_sampling{}, _name, _track, _beg,
|
||||
@@ -1542,7 +1547,8 @@ post_process_perfetto(int64_t _tid, const std::vector<timer_sampling_data>& _tim
|
||||
auto _label = JOIN('-', "lineinfo", _n++);
|
||||
tracing::add_perfetto_annotation(
|
||||
ctx, _label.c_str(),
|
||||
JOIN('@', demangle(line.name),
|
||||
JOIN('@',
|
||||
rocprofsys::utility::demangle(line.name),
|
||||
JOIN(':', line.location, line.line)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "core/config.hpp"
|
||||
#include "core/debug.hpp"
|
||||
#include "core/defines.hpp"
|
||||
#include "core/demangler.hpp"
|
||||
#include "core/perfetto.hpp"
|
||||
#include "core/state.hpp"
|
||||
#include "core/timemory.hpp"
|
||||
@@ -181,8 +182,9 @@ get_perfetto_track(CategoryT, FuncT&& _desc_generator, Args&&... _args)
|
||||
::perfetto::TrackEvent::SetTrackDescriptor(_track, _desc);
|
||||
|
||||
ROCPROFSYS_VERBOSE_F(4, "[%s] Created %s(%zu) with description: \"%s\"\n",
|
||||
trait::name<CategoryT>::value, demangle<TrackT>().c_str(),
|
||||
_uuid, _name.c_str());
|
||||
trait::name<CategoryT>::value,
|
||||
rocprofsys::utility::demangle<TrackT>().c_str(), _uuid,
|
||||
_name.c_str());
|
||||
|
||||
_track_uuids.emplace(_uuid, _name);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user