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(userspace/libsinsp): do not immediately process async events whose timestamp is in the future in case a SCAP_TIMEOUT is received #2250

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

Conversation

FedeDP
Copy link
Contributor

@FedeDP FedeDP commented Jan 22, 2025

What type of PR is this?

/kind bug

Any specific area of the project related to this PR?

/area libsinsp

Does this PR require a change in the driver versions?

What this PR does / why we need it:

Right now, when a SCAP_TIMEOUT is received from the scap_engine, if the async queue contains any event, it gets popped and processed without further investigation about the event's timestamp.
With the proposed patch, the async queue gets scanned considering now as timestamp; this way, we honor the requested timestamp by the async event generator: if it is in the future, we hold the event until that time in the future has arrived.

This PR was originally made as part of the work for #2207, but since it could be extracted, here i am :)

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

fix(userspace/libsinsp): do not immediately process async events whose timestamp is in the future in case a SCAP_TIMEOUT is received

…e timestamp is in the future in case a SCAP_TIMEOUT is received.

Instead, they'll be processed at the future time, as requested by the async event generator.

Signed-off-by: Federico Di Pierro <[email protected]>
@FedeDP
Copy link
Contributor Author

FedeDP commented Jan 22, 2025

/milestone 0.21.0

@poiana poiana added this to the 0.21.0 milestone Jan 22, 2025
@poiana poiana added the size/S label Jan 22, 2025
Copy link

Perf diff from master - unit tests

     5.30%     +0.89%  [.] next_event_from_file
     1.14%     +0.75%  [.] libsinsp::sinsp_suppress::process_event
    10.59%     +0.66%  [.] sinsp::next
     8.16%     -0.61%  [.] sinsp_evt::get_type
     3.80%     -0.60%  [.] sinsp_evt::load_params
    10.75%     -0.47%  [.] sinsp_parser::reset
     3.04%     -0.44%  [.] sinsp_thread_manager::find_thread
     3.16%     -0.43%  [.] sinsp_thread_manager::get_thread_ref
     1.78%     +0.34%  [.] 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
     0.88%     +0.33%  [.] sinsp_evt::get_syscall_return_value

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.0590         +0.0590           144           153           144           153
BM_sinsp_split_median                                          +0.0643         +0.0643           144           153           144           153
BM_sinsp_split_stddev                                          +1.1572         +1.1566             1             2             1             2
BM_sinsp_split_cv                                              +1.0370         +1.0365             0             0             0             0
BM_sinsp_concatenate_paths_relative_path_mean                  +0.0553         +0.0553            57            60            57            60
BM_sinsp_concatenate_paths_relative_path_median                +0.0557         +0.0557            57            60            57            60
BM_sinsp_concatenate_paths_relative_path_stddev                +8.9541         +8.9572             0             2             0             2
BM_sinsp_concatenate_paths_relative_path_cv                    +8.4323         +8.4353             0             0             0             0
BM_sinsp_concatenate_paths_empty_path_mean                     +0.0148         +0.0148            25            25            25            25
BM_sinsp_concatenate_paths_empty_path_median                   +0.0119         +0.0119            25            25            25            25
BM_sinsp_concatenate_paths_empty_path_stddev                   +0.3239         +0.3238             0             0             0             0
BM_sinsp_concatenate_paths_empty_path_cv                       +0.3045         +0.3044             0             0             0             0
BM_sinsp_concatenate_paths_absolute_path_mean                  +0.0457         +0.0457            56            59            56            59
BM_sinsp_concatenate_paths_absolute_path_median                -0.0003         -0.0003            56            56            56            56
BM_sinsp_concatenate_paths_absolute_path_stddev                +8.7887         +8.7887             0             4             0             4
BM_sinsp_concatenate_paths_absolute_path_cv                    +8.3607         +8.3608             0             0             0             0
BM_sinsp_split_container_image_mean                            +0.0015         +0.0015           389           389           389           389
BM_sinsp_split_container_image_median                          +0.0004         +0.0004           389           389           389           389
BM_sinsp_split_container_image_stddev                          +0.1865         +0.1859             3             4             3             4
BM_sinsp_split_container_image_cv                              +0.1847         +0.1841             0             0             0             0

@FedeDP
Copy link
Contributor Author

FedeDP commented Jan 22, 2025

/cc @jasondellaluce

@poiana poiana requested a review from jasondellaluce January 22, 2025 07:54
Copy link

codecov bot commented Jan 22, 2025

Codecov Report

Attention: Patch coverage is 14.28571% with 6 lines in your changes missing coverage. Please review.

Project coverage is 75.16%. Comparing base (6c46ed3) to head (efc25f0).

Files with missing lines Patch % Lines
userspace/libsinsp/sinsp.cpp 14.28% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2250      +/-   ##
==========================================
- Coverage   75.16%   75.16%   -0.01%     
==========================================
  Files         278      278              
  Lines       34478    34479       +1     
  Branches     5922     5924       +2     
==========================================
  Hits        25916    25916              
- Misses       8562     8563       +1     
Flag Coverage Δ
libsinsp 75.16% <14.28%> (-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.

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 Jan 22, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Andreagit97, 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

@FedeDP
Copy link
Contributor Author

FedeDP commented Jan 22, 2025

/hold for a review by Jason

@FedeDP
Copy link
Contributor Author

FedeDP commented Jan 24, 2025

/unhold

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

Successfully merging this pull request may close these issues.

3 participants