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

new(libsinsp): add len() filter transformer #2131

Merged
merged 6 commits into from
Oct 31, 2024

Conversation

LucaGuerra
Copy link
Contributor

@LucaGuerra LucaGuerra commented Oct 23, 2024

What type of PR is this?

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

/kind feature

Any specific area of the project related to this PR?

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

/area libsinsp

Does this PR require a change in the driver versions?

No

What this PR does / why we need it:

This introduces a new len() transformer which acts like you'd expect:

  • len(some_list) evaluates to the number of elements in the list
  • len(some_string) evaluates to the length of the string (excluding null terminator of course)
  • len(some_buffer) evaluates to the number of bytes in the buffer

This is also a handy way to check if lists are empty, since we couldn't do it before, which was apparent after a discussion with @leogr and @jasondellaluce .

Which issue(s) this PR fixes:

Fixes #2127

Special notes for your reviewer:

  • The implementation slightly changes the transformer interface which now takes the element flags as well
  • Do you see any potential corner cases with plugins?

Does this PR introduce a user-facing change?:

new(libsinsp): add len() filter transformer

@poiana
Copy link
Contributor

poiana commented Oct 23, 2024

[APPROVALNOTIFIER] This PR is APPROVED

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

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link

github-actions bot commented Oct 23, 2024

Perf diff from master - unit tests

     5.26%     -1.03%  [.] sinsp_parser::process_event
     4.49%     +0.95%  [.] next
     3.17%     +0.84%  [.] gzfile_read
     3.94%     -0.79%  [.] sinsp_evt::load_params
     6.15%     +0.71%  [.] sinsp::next
     1.70%     -0.62%  [.] libsinsp::sinsp_suppress::process_event
     1.32%     -0.56%  [.] sinsp_parser::event_cleanup
     5.20%     +0.55%  [.] sinsp_evt::get_type
     3.44%     +0.54%  [.] sinsp_thread_manager::get_thread_ref
     2.63%     +0.48%  [.] sinsp_thread_manager::find_thread

Heap diff from master - unit tests

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

Heap diff from master - scap file

peak heap memory consumption: -32B
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.0285         -0.0285           154           149           153           149
BM_sinsp_split_median                                          -0.0282         -0.0281           153           149           153           149
BM_sinsp_split_stddev                                          +0.9625         +0.9624             1             3             1             3
BM_sinsp_split_cv                                              +1.0201         +1.0199             0             0             0             0
BM_sinsp_concatenate_paths_relative_path_mean                  -0.0018         -0.0018            57            57            57            57
BM_sinsp_concatenate_paths_relative_path_median                -0.0019         -0.0020            57            57            57            57
BM_sinsp_concatenate_paths_relative_path_stddev                -0.2067         -0.2036             0             0             0             0
BM_sinsp_concatenate_paths_relative_path_cv                    -0.2054         -0.2022             0             0             0             0
BM_sinsp_concatenate_paths_empty_path_mean                     +0.0432         +0.0432            24            25            24            25
BM_sinsp_concatenate_paths_empty_path_median                   +0.0405         +0.0404            24            25            24            25
BM_sinsp_concatenate_paths_empty_path_stddev                   -0.2387         -0.2389             0             0             0             0
BM_sinsp_concatenate_paths_empty_path_cv                       -0.2702         -0.2704             0             0             0             0
BM_sinsp_concatenate_paths_absolute_path_mean                  -0.0302         -0.0302            56            55            56            55
BM_sinsp_concatenate_paths_absolute_path_median                -0.0389         -0.0389            56            54            56            54
BM_sinsp_concatenate_paths_absolute_path_stddev                +5.7276         +5.7165             0             1             0             1
BM_sinsp_concatenate_paths_absolute_path_cv                    +5.9373         +5.9259             0             0             0             0
BM_sinsp_split_container_image_mean                            -0.0110         -0.0110           398           393           398           393
BM_sinsp_split_container_image_median                          -0.0125         -0.0124           398           393           398           393
BM_sinsp_split_container_image_stddev                          +0.3031         +0.3030             2             2             2             2
BM_sinsp_split_container_image_cv                              +0.3177         +0.3176             0             0             0             0

Copy link

codecov bot commented Oct 23, 2024

Codecov Report

Attention: Patch coverage is 87.64940% with 31 lines in your changes missing coverage. Please review.

Project coverage is 74.60%. Comparing base (701e991) to head (5263f40).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
userspace/libsinsp/test/filter_transformer.ut.cpp 87.89% 23 Missing ⚠️
userspace/libsinsp/sinsp_filter_transformer.cpp 81.81% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2131      +/-   ##
==========================================
+ Coverage   74.46%   74.60%   +0.13%     
==========================================
  Files         254      254              
  Lines       33340    33458     +118     
  Branches     5724     5720       -4     
==========================================
+ Hits        24827    24961     +134     
+ Misses       8508     8470      -38     
- Partials        5       27      +22     
Flag Coverage Δ
libsinsp 74.60% <87.64%> (+0.13%) ⬆️

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.

@FedeDP
Copy link
Contributor

FedeDP commented Oct 23, 2024

/milestone 0.19.0

@poiana poiana added this to the 0.19.0 milestone Oct 23, 2024
@poiana poiana added size/XXL and removed size/XL labels Oct 30, 2024
LucaGuerra and others added 5 commits October 30, 2024 15:40
Signed-off-by: Luca Guerra <luca@guerra.sh>
Signed-off-by: Luca Guerra <luca@guerra.sh>
Co-authored-by: Jason Dellaluce <jasondellaluce@gmail.com>
Signed-off-by: Luca Guerra <luca@guerra.sh>
…), t(list[i]))...

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

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

@jasondellaluce jasondellaluce left a comment

Choose a reason for hiding this comment

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

Just last few concerns/questions

userspace/libsinsp/sinsp_filter_transformer.cpp Outdated Show resolved Hide resolved
userspace/libsinsp/sinsp_filter_transformer.h Show resolved Hide resolved
Signed-off-by: Luca Guerra <luca@guerra.sh>
@LucaGuerra
Copy link
Contributor Author

Thanks! Addressed comments

@poiana
Copy link
Contributor

poiana commented Oct 31, 2024

LGTM label has been added.

Git tree hash: a224ada55b3058be76302af4ac6ad6a1508ff483

@poiana poiana merged commit 5f32757 into falcosecurity:master Oct 31, 2024
46 of 47 checks passed
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.

New transformer: len()
5 participants