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/tests): assorted fixes (memory layout, synchronization) #2013

Merged

Conversation

LucaGuerra
Copy link
Contributor

What type of PR is this?

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

/kind bug

Any specific area of the project related to this PR?

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

/area libsinsp

/area tests

Does this PR require a change in the driver versions?

No

What this PR does / why we need it:

I noticed a couple inconsistencies in libsinsp tests:

  1. in a spot we had auto for a string literal which may be interpreted as char [N] and trip asan. Use a const char* instead.
  2. In an attempt to reduce flakiness in our async key value tests, I introduced a bit more thread safety in some of our tests, especially when there were no synchronization primitives and the use of two threads.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE

Signed-off-by: Luca Guerra <luca@guerra.sh>
…ce tests

Signed-off-by: Luca Guerra <luca@guerra.sh>
Copy link

Perf diff from master - unit tests

     4.17%     +1.16%  [.] sinsp_parser::process_event
    10.29%     -0.81%  [.] sinsp_parser::reset
     3.28%     -0.81%  [.] scap_event_decode_params
     1.17%     -0.63%  [.] thread_group_info::get_first_thread
     0.89%     +0.60%  [.] sinsp_parser::parse_context_switch
     0.67%     -0.57%  [.] 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> >::_M_emplace<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const, libsinsp::state::dynamic_struct::field_info> >
     4.01%     +0.55%  [.] sinsp_evt::load_params
     0.78%     +0.49%  [.] sinsp_evt::get_direction
     1.19%     -0.45%  [.] sinsp_filter_check::parse_field_name
     0.45%     +0.44%  [.] sinsp_split[abi:cxx11]

Perf diff from master - scap file

    28.22%     -7.11%  [.] sinsp_filter_check::tostring
     4.08%     +4.09%  [.] sinsp_filter_check::get_field_info
     4.08%     +3.66%  [.] 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
    12.22%     +2.26%  [.] sinsp_evt_formatter::tostring_withformat
     7.84%     +2.09%  [.] sinsp_thread_manager::get_thread_ref
    20.21%     +0.49%  [.] sinsp_filter_check::extract_nocache
     3.52%     +0.36%  [.] libsinsp::runc::match_container_id
     3.61%     +0.33%  [.] std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >::emplace_back<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >
     3.98%     +0.15%  [.] sinsp_parser::event_cleanup
     4.08%     +0.12%  [.] 0x00000000000a77d4

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

Copy link

codecov bot commented Aug 20, 2024

Codecov Report

Attention: Patch coverage is 96.77419% with 1 line in your changes missing coverage. Please review.

Project coverage is 74.13%. Comparing base (df21b63) to head (da4dfbe).
Report is 9 commits behind head on master.

Files Patch % Lines
...rspace/libsinsp/test/async_key_value_source.ut.cpp 96.42% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2013      +/-   ##
==========================================
+ Coverage   74.12%   74.13%   +0.01%     
==========================================
  Files         253      253              
  Lines       30805    30814       +9     
  Branches     5415     5415              
==========================================
+ Hits        22834    22844      +10     
- Misses       7967     7968       +1     
+ Partials        4        2       -2     
Flag Coverage Δ
libsinsp 74.13% <96.77%> (+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.

@LucaGuerra
Copy link
Contributor Author

/milestone 0.18.0

@poiana poiana added this to the 0.18.0 milestone Aug 20, 2024
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.

Nice!

/approve

@poiana
Copy link
Contributor

poiana commented Aug 20, 2024

LGTM label has been added.

Git tree hash: 2fcbd72cc487207834ff07e1521c94be3b008ee1

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 poiana merged commit a356d08 into falcosecurity:master Aug 21, 2024
44 of 46 checks passed
@poiana
Copy link
Contributor

poiana commented Aug 21, 2024

[APPROVALNOTIFIER] This PR is APPROVED

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

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 [FedeDP,LucaGuerra,incertum]

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.

4 participants