Skip to content

Conversation

ekoops
Copy link
Contributor

@ekoops ekoops commented May 12, 2025

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 is part of a series #2343.
It removes sinsp::get_thread_ref(). As the end goal is to remove unneeded duties from sinsp, it removes this API and lets users directly call the corresponding thread manager API.

BREAKING CHANGE: remove sinsp::get_thread_ref()

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

feat(userspace/libsinsp)!: remove `sinsp::get_thread_ref()`

As the end goal is to remove unneeded duties from `sinsp`, remove
`sinsp::get_thread_ref()` API and let users directly call the
corresponding thread manager API.

BREAKING CHANGE: remove `sinsp::get_thread_ref()`

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
Copy link

Perf diff from master - unit tests

     6.67%     -0.86%  [.] sinsp::next
     3.48%     +0.42%  [.] next_event_from_file
     4.97%     +0.40%  [.] sinsp_parser::reset
     0.31%     +0.37%  [.] scap_next
     2.07%     -0.32%  [.] sinsp_parser::process_event
     1.28%     -0.28%  [.] scap_event_decode_params
     1.09%     -0.25%  [.] sinsp_evt_filter::sinsp_evt_filter
     1.40%     -0.22%  [.] std::_Hashtable<long, std::pair<long const, std::shared_ptr<sinsp_threadinfo> >, std::allocator<std::pair<long const, std::shared_ptr<sinsp_threadinfo> > >, std::__detail::_Select1st, std::equal_to<long>, std::hash<long>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true> >::_M_find_before_node
    34.72%     -0.15%  [.] sinsp_thread_manager::create_thread_dependencies
     0.37%     -0.13%  [.] sinsp_parser::parse_rw_exit

Heap diff from master - unit tests

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

Heap diff from master - scap file

peak heap memory consumption: 0B
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.0124         -0.0122           149           147           149           147
BM_sinsp_split_median                                          -0.0109         -0.0107           149           148           149           148
BM_sinsp_split_stddev                                          +0.0891         +0.0899             1             1             1             1
BM_sinsp_split_cv                                              +0.1027         +0.1034             0             0             0             0
BM_sinsp_concatenate_paths_relative_path_mean                  +0.0110         +0.0111            56            57            56            57
BM_sinsp_concatenate_paths_relative_path_median                +0.0103         +0.0104            56            57            56            57
BM_sinsp_concatenate_paths_relative_path_stddev                +1.5659         +1.5726             0             1             0             1
BM_sinsp_concatenate_paths_relative_path_cv                    +1.5380         +1.5443             0             0             0             0
BM_sinsp_concatenate_paths_empty_path_mean                     +0.0999         +0.1000            24            26            24            26
BM_sinsp_concatenate_paths_empty_path_median                   +0.0932         +0.0934            24            26            24            26
BM_sinsp_concatenate_paths_empty_path_stddev                  +10.4170        +10.3840             0             0             0             0
BM_sinsp_concatenate_paths_empty_path_cv                       +9.3804         +9.3493             0             0             0             0
BM_sinsp_concatenate_paths_absolute_path_mean                  +0.0791         +0.0793            54            59            54            59
BM_sinsp_concatenate_paths_absolute_path_median                +0.0893         +0.0895            54            59            54            59
BM_sinsp_concatenate_paths_absolute_path_stddev                -0.3247         -0.3247             2             1             2             1
BM_sinsp_concatenate_paths_absolute_path_cv                    -0.3742         -0.3743             0             0             0             0

Copy link

codecov bot commented May 12, 2025

Codecov Report

Attention: Patch coverage is 97.84946% with 2 lines in your changes missing coverage. Please review.

Project coverage is 77.28%. Comparing base (c0b1aea) to head (c817419).
Report is 12 commits behind head on master.

Files with missing lines Patch % Lines
userspace/libsinsp/sinsp_filtercheck_thread.cpp 50.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2402      +/-   ##
==========================================
+ Coverage   77.26%   77.28%   +0.01%     
==========================================
  Files         227      227              
  Lines       30323    30348      +25     
  Branches     4644     4644              
==========================================
+ Hits        23429    23453      +24     
- Misses       6894     6895       +1     
Flag Coverage Δ
libsinsp 77.28% <97.84%> (+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.

@FedeDP
Copy link
Contributor

FedeDP commented May 12, 2025

/milestone 0.22.0
/hold

@poiana poiana added this to the 0.22.0 milestone May 12, 2025
Copy link
Contributor

@FedeDP FedeDP 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 May 13, 2025

LGTM label has been added.

Git tree hash: 3c19a7b1de3ea86def623aab1de1bef54e5d1a05

@throws a sinsp_exception containing the error string is thrown in case
of failure.
*/
inline const threadinfo_map_t::ptr_t& get_thread_ref(int64_t tid,
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a bit out of the loop, so I might be missing some context, but do we have an alternative for people using the inspector to reach in and get a thread_info? Because I don't see one being added in this PR and I also don't see a way to get access to the thread_manager either...

I know the main use for Falco is to get events, but we actually do use this method in StackRox and this would break our use case.

Copy link
Contributor

Choose a reason for hiding this comment

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

Never mind, I just noticed m_thread_manager is declared public.

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it is available publicly. The goal here is to remove the big amount of APIs provided by sinsp as a mirror of internal components APIs. We are doing this is order to make sinsp more maintanable and reduce the mental burden while making changes.

Copy link
Contributor

Choose a reason for hiding this comment

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

"reduce the mental burden while making changes" +1 and much appreciated @ekoops ❤️

@ekoops ekoops requested a review from Molter73 May 13, 2025 17:03
Copy link
Contributor

@incertum incertum 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 May 20, 2025
@poiana
Copy link
Contributor

poiana commented May 20, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ekoops, FedeDP, incertum

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

@FedeDP
Copy link
Contributor

FedeDP commented May 20, 2025

/unhold

@poiana poiana merged commit 41f053c into falcosecurity:master May 20, 2025
47 checks passed
@github-project-automation github-project-automation bot moved this from In progress to Done in Falco Roadmap May 20, 2025
@ekoops ekoops deleted the ekoops/remove-get-thread-ref branch May 21, 2025 07:38
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.

5 participants