Skip to content

Commit

Permalink
cleanup: improve perf populate_cmdline
Browse files Browse the repository at this point in the history
Signed-off-by: Andrea Terzolo <[email protected]>
  • Loading branch information
Andreagit97 authored and poiana committed Oct 31, 2024
1 parent 15e24ae commit 4d04cad
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
20 changes: 15 additions & 5 deletions userspace/libsinsp/threadinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,13 @@ void sinsp_threadinfo::set_args(const char* args, size_t len) {

void sinsp_threadinfo::set_args(const std::vector<std::string>& args) {
m_args = args;
m_cmd_line = get_comm();
if(!m_cmd_line.empty()) {
for(const auto& arg : m_args) {
m_cmd_line += " ";
m_cmd_line += arg;
}
}
}

void sinsp_threadinfo::set_env(const char* env, size_t len) {
Expand Down Expand Up @@ -1078,11 +1085,14 @@ void sinsp_threadinfo::assign_children_to_reaper(sinsp_threadinfo* reaper) {
}

void sinsp_threadinfo::populate_cmdline(std::string& cmdline, const sinsp_threadinfo* tinfo) {
cmdline = tinfo->get_comm();

for(const auto& arg : tinfo->m_args) {
cmdline += " ";
cmdline += arg;
if(tinfo->m_cmd_line.empty()) {
cmdline = tinfo->get_comm();
for(const auto& arg : tinfo->m_args) {
cmdline += " ";
cmdline += arg;
}
} else {
cmdline = tinfo->m_cmd_line;
}
}

Expand Down
1 change: 1 addition & 0 deletions userspace/libsinsp/threadinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ class SINSP_PUBLIC sinsp_threadinfo : public libsinsp::state::table_entry {
std::shared_ptr<thread_group_info> m_tginfo;
std::list<std::weak_ptr<sinsp_threadinfo>> m_children;
uint64_t m_not_expired_children;
std::string m_cmd_line;
bool m_filtered_out; ///< True if this thread is filtered out by the inspector filter from
///< saving to a capture

Expand Down

0 comments on commit 4d04cad

Please sign in to comment.