From 00faa48ac22802bc63b8ce8b30ebe3a1bb946c52 Mon Sep 17 00:00:00 2001 From: Milan Radosavljevic Date: Fri, 17 Oct 2025 15:30:29 +0200 Subject: [PATCH] Add flushing of perfetto buffer (#1417) - Add flushing of perfetto buffer - Add `ROCPROFSYS_PERFETTO_FLUSH_PERIOD_MS` config setting. - Update CHANGELOG.sh - Resolves SWDEV-518817 --------- Co-authored-by: David Galiffi --- projects/rocprofiler-systems/CHANGELOG.md | 6 ++++++ .../rocprofiler-systems/source/lib/core/config.cpp | 11 +++++++++++ .../rocprofiler-systems/source/lib/core/config.hpp | 3 +++ .../rocprofiler-systems/source/lib/core/perfetto.cpp | 3 +++ 4 files changed, 23 insertions(+) diff --git a/projects/rocprofiler-systems/CHANGELOG.md b/projects/rocprofiler-systems/CHANGELOG.md index 0e12995e41..5a6f5cdc34 100644 --- a/projects/rocprofiler-systems/CHANGELOG.md +++ b/projects/rocprofiler-systems/CHANGELOG.md @@ -4,6 +4,12 @@ Full documentation for ROCm Systems Profiler is available at [https://rocm.docs.amd.com/projects/rocprofiler-systems/en/latest/](https://rocm.docs.amd.com/projects/rocprofiler-systems/en/latest/). +## ROCm Systems Profiler 1.3.0 for ROCm 7.2.0 + +### Added + +- Added a `ROCPROFSYS_PERFETTO_FLUSH_PERIOD_MS` configuration setting to set the flush period for Perfetto traces. The default value is 10000 ms (10 seconds). + ## ROCm Systems Profiler 1.2.0 for ROCm 7.1.0 ### Added diff --git a/projects/rocprofiler-systems/source/lib/core/config.cpp b/projects/rocprofiler-systems/source/lib/core/config.cpp index cc9c19aba9..b98cd3f4f1 100644 --- a/projects/rocprofiler-systems/source/lib/core/config.cpp +++ b/projects/rocprofiler-systems/source/lib/core/config.cpp @@ -645,6 +645,10 @@ configure_settings(bool _init) "default to the value of ROCPROFSYS_COLLAPSE_PROCESSES", false, "perfetto", "data", "advanced"); + ROCPROFSYS_CONFIG_SETTING(uint32_t, "ROCPROFSYS_PERFETTO_FLUSH_PERIOD_MS", + "Set Perfetto flush period (in ms)", uint32_t{ 10000 }, + "perfetto", "data"); + ROCPROFSYS_CONFIG_SETTING( std::string, "ROCPROFSYS_PERFETTO_FILL_POLICY", "Behavior when perfetto buffer is full. 'discard' will ignore new entries, " @@ -1997,6 +2001,13 @@ get_perfetto_buffer_size() return static_cast&>(*_v->second).get(); } +uint32_t +get_perfetto_flush_period() +{ + static auto _v = get_config()->find("ROCPROFSYS_PERFETTO_FLUSH_PERIOD_MS"); + return static_cast&>(*_v->second).get(); +} + bool get_perfetto_combined_traces() { diff --git a/projects/rocprofiler-systems/source/lib/core/config.hpp b/projects/rocprofiler-systems/source/lib/core/config.hpp index 4eabda8aa3..14ac0894a7 100644 --- a/projects/rocprofiler-systems/source/lib/core/config.hpp +++ b/projects/rocprofiler-systems/source/lib/core/config.hpp @@ -252,6 +252,9 @@ get_perfetto_shmem_size_hint(); size_t get_perfetto_buffer_size(); +uint32_t +get_perfetto_flush_period(); + bool get_perfetto_combined_traces(); diff --git a/projects/rocprofiler-systems/source/lib/core/perfetto.cpp b/projects/rocprofiler-systems/source/lib/core/perfetto.cpp index 50f366721e..3ca5ecc020 100644 --- a/projects/rocprofiler-systems/source/lib/core/perfetto.cpp +++ b/projects/rocprofiler-systems/source/lib/core/perfetto.cpp @@ -78,6 +78,7 @@ setup() // environment settings auto shmem_size_hint = config::get_perfetto_shmem_size_hint(); auto buffer_size = config::get_perfetto_buffer_size(); + auto flush_period = config::get_perfetto_flush_period(); auto _policy = config::get_perfetto_fill_policy() == "discard" @@ -94,6 +95,8 @@ setup() track_event_cfg.add_disabled_categories(itr); } + cfg.set_flush_period_ms(flush_period); + auto* ds_cfg = cfg.add_data_sources()->mutable_config(); ds_cfg->set_name("track_event"); // this MUST be track_event ds_cfg->set_track_event_config_raw(track_event_cfg.SerializeAsString());