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

fix(libsinsp): expose main thread fd table #2133

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mrgian
Copy link
Contributor

@mrgian mrgian commented Oct 24, 2024

What type of PR is this?

Uncomment one (or more) /kind <> lines:

/kind bug

/kind cleanup

/kind design

/kind documentation

/kind failing-test

/kind feature

Any specific area of the project related to this PR?

Uncomment one (or more) /area <> lines:

/area API-version

/area build

/area CI

/area driver-kmod

/area driver-bpf

/area driver-modern-bpf

/area libscap-engine-bpf

/area libscap-engine-gvisor

/area libscap-engine-kmod

/area libscap-engine-modern-bpf

/area libscap-engine-nodriver

/area libscap-engine-noop

/area libscap-engine-source-plugin

/area libscap-engine-savefile

/area libscap

/area libpman

/area libsinsp

/area tests

/area proposals

Does this PR require a change in the driver versions?

/version driver-API-version-major

/version driver-API-version-minor

/version driver-API-version-patch

/version driver-SCHEMA-version-major

/version driver-SCHEMA-version-minor

/version driver-SCHEMA-version-patch

What this PR does / why we need it:
This PR ensures that the plugin API exposes the file descriptor table of its main thread instead of its own.
Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

fix(libsinsp): expose main thread fd table

Copy link

github-actions bot commented Oct 24, 2024

Perf diff from master - unit tests

     6.55%     +1.22%  [.] sinsp::next
     1.31%     -0.67%  [.] sinsp_threadinfo::~sinsp_threadinfo
     2.10%     -0.62%  [.] sinsp::fetch_next_event
     2.78%     +0.58%  [.] sinsp_thread_manager::get_thread_ref
     1.02%     -0.55%  [.] std::vector<sinsp_evt_param, std::allocator<sinsp_evt_param> >::emplace_back<sinsp_evt*, unsigned int&, char const*, unsigned long&>
     2.25%     -0.55%  [.] std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release
     5.13%     -0.52%  [.] sinsp_parser::process_event
    10.01%     -0.51%  [.] sinsp_parser::reset
     0.90%     -0.45%  [.] sinsp_split[abi:cxx11]
     4.52%     -0.44%  [.] sinsp_evt::load_params

Heap diff from master - unit tests

peak heap memory consumption: -80.01K
peak RSS (including heaptrack overhead): 0B
total memory leaked: 0B

Heap diff from master - scap file

peak heap memory consumption: -2.02K
peak RSS (including heaptrack overhead): 0B
total memory leaked: 0B

Benchmarks diff from master

Comparing gbench_data.json to /root/actions-runner/_work/libs/libs/build/gbench_data.json
Benchmark                                                         Time             CPU      Time Old      Time New       CPU Old       CPU New
----------------------------------------------------------------------------------------------------------------------------------------------
BM_sinsp_split_mean                                            +0.0006         +0.0006           155           155           155           155
BM_sinsp_split_median                                          +0.0027         +0.0027           155           155           155           155
BM_sinsp_split_stddev                                          +0.1441         +0.1446             2             2             2             2
BM_sinsp_split_cv                                              +0.1434         +0.1439             0             0             0             0
BM_sinsp_concatenate_paths_relative_path_mean                  +0.0240         +0.0240            61            62            61            62
BM_sinsp_concatenate_paths_relative_path_median                +0.0277         +0.0277            61            62            61            62
BM_sinsp_concatenate_paths_relative_path_stddev                +1.9169         +1.9145             0             1             0             1
BM_sinsp_concatenate_paths_relative_path_cv                    +1.8484         +1.8461             0             0             0             0
BM_sinsp_concatenate_paths_empty_path_mean                     -0.0047         -0.0047            25            25            25            25
BM_sinsp_concatenate_paths_empty_path_median                   +0.0014         +0.0014            25            25            25            25
BM_sinsp_concatenate_paths_empty_path_stddev                   -0.4492         -0.4496             0             0             0             0
BM_sinsp_concatenate_paths_empty_path_cv                       -0.4466         -0.4470             0             0             0             0
BM_sinsp_concatenate_paths_absolute_path_mean                  +0.0217         +0.0217            61            62            61            62
BM_sinsp_concatenate_paths_absolute_path_median                +0.0171         +0.0171            60            61            60            61
BM_sinsp_concatenate_paths_absolute_path_stddev                -0.0397         -0.0397             1             1             1             1
BM_sinsp_concatenate_paths_absolute_path_cv                    -0.0601         -0.0602             0             0             0             0
BM_sinsp_split_container_image_mean                            +0.0167         +0.0167           390           396           390           396
BM_sinsp_split_container_image_median                          +0.0196         +0.0196           388           396           388           396
BM_sinsp_split_container_image_stddev                          -0.5192         -0.5192             4             2             4             2
BM_sinsp_split_container_image_cv                              -0.5271         -0.5271             0             0             0             0

Copy link

codecov bot commented Oct 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 74.46%. Comparing base (90c1520) to head (2cd6315).
Report is 10 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff            @@
##           master    #2133    +/-   ##
========================================
  Coverage   74.46%   74.46%            
========================================
  Files         253      254     +1     
  Lines       33069    33340   +271     
  Branches     5697     5727    +30     
========================================
+ Hits        24624    24827   +203     
- Misses       8445     8507    +62     
- Partials        0        6     +6     
Flag Coverage Δ
libsinsp 74.46% <100.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.

@mrgian mrgian marked this pull request as ready for review October 24, 2024 10:59
@poiana poiana requested a review from Molter73 October 24, 2024 10:59
@@ -1385,6 +1393,8 @@ void sinsp_thread_manager::create_thread_dependencies(
return;
}
parent_thread->add_child(tinfo);

tinfo->update_main_fdtable();
Copy link
Member

Choose a reason for hiding this comment

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

putting this in create_thread_dependencies should correctly set the fdtable in all cases

  • /proc scan at initi time
  • /proc scan at runtime
  • when a new thread is added after a clone syscall

@mrgian
Copy link
Contributor Author

mrgian commented Oct 24, 2024

/cc @Andreagit97 @jasondellaluce

Copy link
Member

@Andreagit97 Andreagit97 left a comment

Choose a reason for hiding this comment

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

/approve

@poiana
Copy link
Contributor

poiana commented Oct 24, 2024

LGTM label has been added.

Git tree hash: bc6dcb27c550d8a5c39f8548bf0ee496a702cb78

@poiana
Copy link
Contributor

poiana commented Oct 24, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Andreagit97, mrgian

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants