Skip to content

Conversation

@deepskyblue86
Copy link
Member

What type of PR is this?

/kind feature

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:
Improve sinsp_threadinfo::get_container_id() performance. Based on my test with microbenchmarking there's a ~16% performance improvement.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE

Avoid unnecessary extra lookup

Signed-off-by: Angelo Puglisi <[email protected]>
Have the container_id accessor as an attribute, avoiding
sinsp_thread_manager::get_field_accessor at each call.

Signed-off-by: Angelo Puglisi <[email protected]>
@codecov
Copy link

codecov bot commented Oct 24, 2025

Codecov Report

❌ Patch coverage is 70.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.91%. Comparing base (0376a8f) to head (eeff419).
⚠️ Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
userspace/libsinsp/threadinfo.cpp 71.42% 2 Missing ⚠️
userspace/libsinsp/thread_manager.h 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2705      +/-   ##
==========================================
- Coverage   76.91%   76.91%   -0.01%     
==========================================
  Files         294      294              
  Lines       30862    30865       +3     
  Branches     4689     4692       +3     
==========================================
+ Hits        23739    23740       +1     
- Misses       7123     7125       +2     
Flag Coverage Δ
libsinsp 76.91% <70.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@terror96 terror96 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

Looks like an obvious change provided the value of accessor remains constant between calls to get_container_id(), which I presume is the case here.

@poiana
Copy link
Contributor

poiana commented Oct 27, 2025

LGTM label has been added.

Git tree hash: 18a15163d97d238f11942a2f49bdce7ae59e80e5

@deepskyblue86
Copy link
Member Author

/lgtm

Looks like an obvious change provide the value of accessor remains constant between calls to get_container_id(), which I presume is the case here.

Happy to detail this more!
sinsp_thread_manager::get_field_accessor() returns the accessor from m_foreign_fields_accessors, being populated just once at sinsp::init(), more specifically at sinsp::set_thread_manager_foreign_accessors_and_tables().

@ekoops
Copy link
Contributor

ekoops commented Oct 27, 2025

/milestone 0.23.0

@poiana poiana added this to the 0.23.0 milestone Oct 27, 2025
Copy link
Contributor

@ekoops ekoops left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve

@github-project-automation github-project-automation bot moved this from Todo to In progress in Falco Roadmap Oct 27, 2025
@poiana
Copy link
Contributor

poiana commented Oct 27, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: deepskyblue86, ekoops, terror96

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:
  • OWNERS [deepskyblue86,ekoops]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@poiana poiana merged commit dfe6c71 into falcosecurity:master Oct 27, 2025
62 of 66 checks passed
@github-project-automation github-project-automation bot moved this from In progress to Done in Falco Roadmap Oct 27, 2025
@deepskyblue86 deepskyblue86 deleted the perf/get_container_id branch October 27, 2025 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants