Skip to content

feat(userspace/libsisnp)!: clean sinsp_parser component #2380

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

Merged
merged 3 commits into from
May 5, 2025

Conversation

ekoops
Copy link
Contributor

@ekoops ekoops commented Apr 29, 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 partially cleans the sinsp_parser component by replacing the usage of pointers with references, both in public and private APIs, to enforce the non-nullness contract. Moreover, it replaces a bunch of NULL with nullptr.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

feat(userspace/libsinsp)!: use refs in `sinsp_parser`'s public APIs

Copy link

github-actions bot commented Apr 29, 2025

Perf diff from master - unit tests

     5.54%     +0.80%  [.] sinsp_parser::reset
    35.05%     -0.35%  [.] sinsp_thread_manager::create_thread_dependencies
     2.39%     -0.27%  [.] sinsp_evt::load_params
     3.80%     -0.21%  [.] next_event_from_file
     0.98%     -0.20%  [.] sinsp::fetch_next_event
     6.35%     +0.19%  [.] sinsp::next
     1.21%     +0.16%  [.] next
     1.28%     -0.16%  [.] std::_Hashtable<unsigned long, std::pair<unsigned long const, std::shared_ptr<ppm_evt_hdr> >, std::allocator<std::pair<unsigned long const, std::shared_ptr<ppm_evt_hdr> > >, std::__detail::_Select1st, std::equal_to<unsigned long>, std::hash<unsigned 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
     1.53%     -0.16%  [.] 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
     2.41%     +0.15%  [.] gzfile_read

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.0014         +0.0015           149           149           149           149
BM_sinsp_split_median                                          +0.0023         +0.0023           149           149           149           149
BM_sinsp_split_stddev                                          -0.1934         -0.1940             1             0             1             0
BM_sinsp_split_cv                                              -0.1946         -0.1952             0             0             0             0
BM_sinsp_concatenate_paths_relative_path_mean                  +0.0266         +0.0266            56            57            56            57
BM_sinsp_concatenate_paths_relative_path_median                +0.0221         +0.0221            56            57            56            57
BM_sinsp_concatenate_paths_relative_path_stddev                +2.6693         +2.6687             0             1             0             1
BM_sinsp_concatenate_paths_relative_path_cv                    +2.5742         +2.5737             0             0             0             0
BM_sinsp_concatenate_paths_empty_path_mean                     +0.0044         +0.0044            24            24            24            24
BM_sinsp_concatenate_paths_empty_path_median                   +0.0042         +0.0042            24            24            24            24
BM_sinsp_concatenate_paths_empty_path_stddev                   -0.1849         -0.1888             0             0             0             0
BM_sinsp_concatenate_paths_empty_path_cv                       -0.1885         -0.1924             0             0             0             0
BM_sinsp_concatenate_paths_absolute_path_mean                  +0.0410         +0.0410            58            61            58            61
BM_sinsp_concatenate_paths_absolute_path_median                +0.0421         +0.0421            58            61            58            61
BM_sinsp_concatenate_paths_absolute_path_stddev                +0.6426         +0.6408             0             0             0             0
BM_sinsp_concatenate_paths_absolute_path_cv                    +0.5779         +0.5762             0             0             0             0

Copy link

codecov bot commented Apr 29, 2025

Codecov Report

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

Project coverage is 77.15%. Comparing base (607ee60) to head (7f0b35d).
Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
userspace/libsinsp/sinsp_filtercheck_fd.cpp 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2380      +/-   ##
==========================================
- Coverage   77.15%   77.15%   -0.01%     
==========================================
  Files         231      231              
  Lines       30347    30345       -2     
  Branches     4656     4657       +1     
==========================================
- Hits        23415    23412       -3     
- Misses       6932     6933       +1     
Flag Coverage Δ
libsinsp 77.15% <71.42%> (-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.

@leogr leogr requested review from FedeDP and mstemm May 2, 2025 12:26
leogr
leogr previously approved these changes May 2, 2025
@poiana poiana added the lgtm label May 2, 2025
@poiana
Copy link
Contributor

poiana commented May 2, 2025

LGTM label has been added.

Git tree hash: 4cdf194a4b1d1e118900b4c6d1950aaf420bda74

@leogr leogr requested a review from gnosek May 2, 2025 12:26
ekoops added 3 commits May 2, 2025 15:12
Replace pointers with references in `sinsp_parser`'s private APIs
wherever possible.

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
Explicitely enforce, by accepting references, the non-nullness of the
input parameters in the `sinsp_parser` public APIs.

BREAKING CHANGE: update `sinsp_parser::process_event()`,
`sinsp_parser::event_cleanup()`, `sinsp_parser::reset()`,
`sinsp_parser::retrieve_enter_event()` and
`sinsp_parser::parse_dirfd()` signatures

Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
Signed-off-by: Leonardo Di Giovanna <leonardodigiovanna1@gmail.com>
@ekoops ekoops force-pushed the ekoops/parser-ref branch from 079e52f to 7f0b35d Compare May 2, 2025 13:12
@poiana poiana removed the lgtm label May 2, 2025
@poiana poiana requested a review from leogr May 2, 2025 13:12
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 5, 2025

[APPROVALNOTIFIER] This PR is APPROVED

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

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

@poiana poiana added the approved label May 5, 2025
@poiana
Copy link
Contributor

poiana commented May 5, 2025

LGTM label has been added.

Git tree hash: 6e388c40eb8e88d2313fdf79c4efebd5ec70dbe3

@FedeDP
Copy link
Contributor

FedeDP commented May 5, 2025

/milestone 0.21.0

@poiana poiana added this to the 0.21.0 milestone May 5, 2025
@github-project-automation github-project-automation bot moved this from Todo to In progress in Falco Roadmap May 5, 2025
@poiana poiana merged commit 838f057 into falcosecurity:master May 5, 2025
45 of 47 checks passed
@github-project-automation github-project-automation bot moved this from In progress to Done in Falco Roadmap May 5, 2025
@ekoops ekoops deleted the ekoops/parser-ref branch May 5, 2025 10:33
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