Skip to content
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

cleanup: improve perf populate_cmdline #2138

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 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::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;

Check warning on line 1092 in userspace/libsinsp/threadinfo.cpp

View check run for this annotation

Codecov / codecov/patch

userspace/libsinsp/threadinfo.cpp#L1091-L1092

Added lines #L1091 - L1092 were not covered by tests
}
} 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
Loading