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(driver/bpf): close maps on cleanup #1959

Merged
merged 3 commits into from
Jul 16, 2024

Conversation

therealbobo
Copy link
Contributor

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:

Some internal maps of the bpf engine were not closed on cleanup. This fixes it.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE

Copy link

Please double check driver/API_VERSION file. See versioning.

/hold

@FedeDP
Copy link
Contributor

FedeDP commented Jul 15, 2024

/milestone 0.18.0

@poiana poiana added this to the 0.18.0 milestone Jul 15, 2024
Copy link

Perf diff from master - unit tests

     4.27%     +1.61%  [.] sinsp_evt::get_type
     3.34%     -0.94%  [.] sinsp_thread_manager::get_thread_ref
     9.46%     +0.93%  [.] sinsp_parser::reset
     1.74%     +0.91%  [.] sinsp::fetch_next_event
     4.17%     -0.89%  [.] gzfile_read
     2.59%     -0.86%  [.] 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
     4.12%     +0.61%  [.] sinsp_parser::process_event
     7.24%     -0.53%  [.] sinsp::next
     0.31%     +0.49%  [.] std::_Hashtable<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, libsinsp::state::dynamic_struct::field_info>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, libsinsp::state::dynamic_struct::field_info> >, std::__detail::_Select1st, std::equal_to<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::hash<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true> >::find
     1.51%     -0.46%  [.] 0x00000000000e8390

Perf diff from master - scap file

    15.08%     -5.98%  [.] sinsp_filter_check::tostring
    13.82%     -5.35%  [.] sinsp_thread_manager::find_thread
    12.29%     -4.47%  [.] 0x00000000000a70d0
    14.62%     -3.52%  [.] sinsp_filter_check::extract_nocache
    18.30%     +3.15%  [.] sinsp_evt_formatter::tostring_withformat
     3.64%     +2.20%  [.] 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
     7.44%     -1.83%  [.] sinsp::next
     7.40%     -1.80%  [.] sinsp_evt::get_thread_info
     3.69%     +0.21%  [.] sinsp_filter_check::apply_transformers
     3.73%     +0.14%  [.] main

Heap diff from master - unit tests

total runtime: 0.02s.
calls to allocation functions: 272 (11826/s)
temporary memory allocations: 693 (30130/s)
peak heap memory consumption: 0B
peak RSS (including heaptrack overhead): 0B
total memory leaked: 0B

Heap diff from master - scap file

total runtime: 0.00s.
calls to allocation functions: 0 (0/s)
temporary memory allocations: 4 (4/s)
peak heap memory consumption: 0B
peak RSS (including heaptrack overhead): 0B
total memory leaked: 0B

Copy link

Perf diff from master - unit tests

     7.21%     -1.52%  [.] sinsp::next
     1.50%     -0.81%  [.] 0x00000000000e8390
     1.21%     -0.56%  [.] sinsp_filter_check::parse_field_name
     0.63%     +0.53%  [.] scap_event_encode_params_v
     0.84%     -0.53%  [.] sinsp_threadinfo::sinsp_threadinfo
     2.58%     -0.50%  [.] 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
     0.68%     +0.46%  [.] sinsp_parser::event_cleanup
     1.00%     +0.41%  [.] sinsp_evt::get_ts
     0.74%     +0.40%  [.] 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> >::find
     9.42%     +0.40%  [.] sinsp_parser::reset

Perf diff from master - scap file

    14.87%    +11.60%  [.] sinsp_filter_check::extract_nocache
    15.34%     -4.27%  [.] sinsp_filter_check::tostring
    11.31%     -4.06%  [.] sinsp_filter_check_thread::extract_single
     7.57%     +3.95%  [.] sinsp::next
    15.14%     -2.20%  [.] sinsp_filter_check_event::extract_single
     6.13%     -1.49%  [.] sinsp_split
    18.62%     -1.39%  [.] sinsp_evt_formatter::tostring_withformat
     3.50%     +0.31%  [.] sinsp_parser::process_event
     3.79%     -0.04%  [.] main
     3.72%     -0.03%  [.] std::_Hashtable<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::shared_ptr<sinsp_container_info const> >, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::shared_ptr<sinsp_container_info const> > >, std::__detail::_Select1st, std::equal_to<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::hash<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true> >::find

Heap diff from master - unit tests

total runtime: -0.04s.
calls to allocation functions: -119 (3216/s)
temporary memory allocations: 479 (-12945/s)
peak heap memory consumption: 0B
peak RSS (including heaptrack overhead): 0B
total memory leaked: 0B

Heap diff from master - scap file

total runtime: -0.04s.
calls to allocation functions: 0 (0/s)
temporary memory allocations: 6 (-139/s)
peak heap memory consumption: 0B
peak RSS (including heaptrack overhead): 0B
total memory leaked: 0B

Copy link

Perf diff from master - unit tests

     9.34%     +2.82%  [.] sinsp_parser::reset
     7.15%     -1.24%  [.] sinsp::next
     4.21%     +1.10%  [.] sinsp_evt::get_type
     5.46%     -0.97%  [.] sinsp_thread_manager::find_thread
     1.72%     +0.72%  [.] sinsp::fetch_next_event
     4.06%     +0.71%  [.] sinsp_parser::process_event
     2.56%     -0.69%  [.] 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
     3.76%     -0.66%  [.] sinsp_evt::load_params
     4.11%     -0.62%  [.] gzfile_read
     1.49%     -0.53%  [.] 0x00000000000e8390

Perf diff from master - scap file

    13.68%     -8.22%  [.] sinsp_evt_formatter::tostring_withformat
    11.12%     -6.40%  [.] sinsp_filter_check_event::extract_single
     9.19%     -4.98%  [.] 0x00000000000a70d0
    11.27%     -4.87%  [.] sinsp_filter_check::tostring
    10.33%     -4.11%  [.] sinsp_thread_manager::find_thread
    10.93%     +3.86%  [.] sinsp_filter_check::extract_nocache
     2.57%     +3.26%  [.] sinsp_parser::process_event
     2.72%     +2.91%  [.] 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
     8.31%     -2.64%  [.] sinsp_filter_check_thread::extract_single
     5.56%     -2.37%  [.] sinsp::next

Heap diff from master - unit tests

total runtime: -0.09s.
calls to allocation functions: -196 (2279/s)
temporary memory allocations: 406 (-4720/s)
peak heap memory consumption: 0B
peak RSS (including heaptrack overhead): 0B
total memory leaked: 0B

Heap diff from master - scap file

total runtime: -0.02s.
calls to allocation functions: 0 (0/s)
temporary memory allocations: 1 (-52/s)
peak heap memory consumption: 0B
peak RSS (including heaptrack overhead): 0B
total memory leaked: 0B

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 Jul 15, 2024

LGTM label has been added.

Git tree hash: 9ea3fa0e7aa7d8847cc3737a35670aa167a3fc92

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 Jul 15, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Andreagit97, FedeDP, therealbobo

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

@Andreagit97
Copy link
Member

/unhold

@poiana poiana merged commit 60317a6 into falcosecurity:master Jul 16, 2024
42 of 46 checks passed
@FedeDP
Copy link
Contributor

FedeDP commented Aug 1, 2024

/milestone 0.17.3

@poiana poiana modified the milestones: 0.18.0, 0.17.3 Aug 1, 2024
@LucaGuerra LucaGuerra mentioned this pull request Aug 1, 2024
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.

4 participants