Support for disabling perfetto categories (#72)

* Updates

- get_perfetto_categories() impl
- rework perfetto category usage

* TIMEMORY_DEFINE_NAME_TRAIT for cpu_freq::cpu_peak

* Add process_memory_hwm perfetto category
This commit is contained in:
Jonathan R. Madsen
2022-07-18 08:25:48 -05:00
committed by GitHub
parent 8f8aa43d1a
commit 16bd20121e
5 changed files with 92 additions and 28 deletions
+30
View File
@@ -24,6 +24,7 @@
#include "library/debug.hpp"
#include "library/defines.hpp"
#include "library/gpu.hpp"
#include "library/perfetto.hpp"
#include <timemory/backends/dmp.hpp>
#include <timemory/backends/mpi.hpp>
@@ -73,6 +74,16 @@ get_setting_name(std::string _v)
return _v;
}
template <typename Tp>
Tp
get_available_perfetto_categories()
{
auto _v = Tp{};
for(auto itr : { OMNITRACE_PERFETTO_CATEGORIES })
tim::utility::emplace(_v, itr.name);
return _v;
}
#define OMNITRACE_CONFIG_SETTING(TYPE, ENV_NAME, DESCRIPTION, INITIAL_VALUE, ...) \
[&]() { \
auto _ret = _config->insert<TYPE, TYPE>( \
@@ -399,6 +410,11 @@ configure_settings(bool _init)
"discard", "perfetto", "data")
->set_choices({ "fill", "discard" });
OMNITRACE_CONFIG_SETTING(std::string, "OMNITRACE_PERFETTO_CATEGORIES",
"Categories to collect within perfetto", "", "perfetto",
"data")
->set_choices(get_available_perfetto_categories<std::vector<std::string>>());
OMNITRACE_CONFIG_EXT_SETTING(int64_t, "OMNITRACE_CRITICAL_TRACE_COUNT",
"Number of critical trace to export (0 == all)",
int64_t{ 0 }, "data", "critical_trace",
@@ -1383,6 +1399,20 @@ get_perfetto_fill_policy()
return static_cast<tim::tsettings<std::string>&>(*_v->second).get();
}
std::set<std::string>
get_perfetto_categories()
{
static auto _v = get_config()->find("OMNITRACE_PERFETTO_CATEGORIES");
static auto _avail = get_available_perfetto_categories<std::set<std::string>>();
auto _ret = std::set<std::string>{};
for(auto itr : tim::delimit(
static_cast<tim::tsettings<std::string>&>(*_v->second).get(), " ,;:"))
{
if(_avail.count(itr) > 0) _ret.emplace(itr);
}
return _ret;
}
uint64_t
get_critical_trace_update_freq()
{