-
Notifications
You must be signed in to change notification settings - Fork 165
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
chore(userspace/libsinsp): keep a reference on m_sinsp_stats_v2 where needed #1910
Conversation
bd331d7
to
a42d9e6
Compare
cabfa07
to
a479e9a
Compare
Mmmh seems like the job is hit by: actions/runner#2402 |
67108fd
to
574fbaf
Compare
if (!m_sinsp_stats_v2) | ||
{ | ||
// Sinsp stats disabled. | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Below we also have other metrics categories that then could not be used without the sinsip stats?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this early return is ok, it has the exact same behavior as before as far as i can tell; otherwise, can you point me to the lines (perhaps i am just missing them!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
libs/userspace/libsinsp/metrics_collector.cpp
Lines 724 to 785 in 570b86c
if((m_metrics_flags & METRICS_V2_RESOURCE_UTILIZATION)) | |
{ | |
const scap_agent_info* agent_info = m_inspector->get_agent_info(); | |
get_cpu_usage_and_total_procs(agent_info->start_time, cpu_usage_perc, host_cpu_usage_perc, host_procs_running); | |
get_rss_vsz_pss_total_memory_and_open_fds(rss, vsz, pss, host_memory_used, host_open_fds); | |
// Resource utilization of the agent itself | |
for (int i = SINSP_RESOURCE_UTILIZATION_CPU_PERC; i <= SINSP_RESOURCE_UTILIZATION_HOST_FDS; i++) | |
{ | |
m_metrics.emplace_back(sinsp_stats_v2_collectors[i]()); | |
} | |
} | |
if((m_metrics_flags & METRICS_V2_STATE_COUNTERS)) | |
{ | |
if (!sinsp_stats_v2) | |
{ | |
m_inspector->set_sinsp_stats_v2_enabled(); | |
sinsp_stats_v2 = m_inspector->get_sinsp_stats_v2(); | |
} | |
if (sinsp_stats_v2) | |
{ | |
auto thread_manager = m_inspector->m_thread_manager.get(); | |
if (thread_manager) | |
{ | |
n_threads = thread_manager->get_thread_count(); | |
threadinfo_map_t* threadtable = thread_manager->get_threads(); | |
if (threadtable) | |
{ | |
threadtable->loop([&n_fds] (sinsp_threadinfo& tinfo) | |
{ | |
sinsp_fdtable* fdtable = tinfo.get_fd_table(); | |
if (fdtable != nullptr) | |
{ | |
n_fds += fdtable->size(); | |
} | |
return true; | |
}); | |
} | |
} | |
// Resource utilization of the agent itself | |
for (int i = SINSP_STATS_V2_N_THREADS; i < SINSP_MAX_STATS_V2; i++) | |
{ | |
m_metrics.emplace_back(sinsp_stats_v2_collectors[i]()); | |
} | |
} | |
} | |
/* | |
* plugins metrics | |
*/ | |
if(m_metrics_flags & METRICS_V2_PLUGINS) | |
{ | |
for (auto& p : m_inspector->get_plugin_manager()->plugins()) | |
{ | |
std::vector<metrics_v2> plugin_metrics = p->get_metrics(); | |
m_metrics.insert(m_metrics.end(), plugin_metrics.begin(), plugin_metrics.end()); | |
} | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh! Thanks Melissa, completely overlooked them!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed :)
/milestone 0.18.0 |
6bc1a8e
to
f2eb192
Compare
So, the job is failing on our cncf x64 self-hosted node too; but i manually tried on the node and it worked fine. EDIT: I also tried to run |
2fbb50a
to
768e031
Compare
Perf diff from master - unit tests
Perf diff from master - scap file
Heap diff from master - unit tests
Heap diff from master - scap file
|
994b28c
to
1b1a5a2
Compare
Perf diff from master - unit tests
Perf diff from master - scap file
Heap diff from master - unit tests
Heap diff from master - scap file
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/approve
/hold |
Properly keep a reference on m_sinsp_stats_v2 where needed, instead of fetching it every time. Moreover, improve perf in `sinsp_utils::ts_to_string`: cache `gmt2local` result instead of fetching it every time as it is an heavy operation. Signed-off-by: Federico Di Pierro <[email protected]>
… return empty value, to be skipped, when requirements are not met. For now, this means that metrics that require `m_sinsp_stats_v2` will be automatically skipped when it is disabled. Signed-off-by: Federico Di Pierro <[email protected]>
Signed-off-by: Federico Di Pierro <[email protected]>
Signed-off-by: Federico Di Pierro <[email protected]>
…ifact action. Signed-off-by: Federico Di Pierro <[email protected]>
1b1a5a2
to
377edd5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Andreagit97, FedeDP, leogr The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Perf diff from master - unit tests
Perf diff from master - scap file
Heap diff from master - unit tests
Heap diff from master - scap file
|
/unhold |
/milestone 0.17.3 |
What type of PR is this?
/kind cleanup
Any specific area of the project related to this PR?
/area libsinsp
Does this PR require a change in the driver versions?
What this PR does / why we need it:
This PR keeps a reference on m_sinsp_stats_v2 where needed, instead of fetching it every time.
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?: