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

cleanup(build): move NOMINMAX definition at compile time for windows builds #2199

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

Conversation

FedeDP
Copy link
Contributor

@FedeDP FedeDP commented Dec 13, 2024

What type of PR is this?

/kind cleanup

Any specific area of the project related to this PR?

/area build

What this PR does / why we need it:

We define NOMINMAX in multiple places to avoid windows.h re-defining min and max macros under the hood.
Since this is super error prone because windows headers can be included in so many places (even by included headers from deps), i though it was a good idea to just add a compile definition for it.

Another (possibly better) solution would have been to drop NOMINMAX and use std::min<type> (and same for max); in that case, the macro would not be able to replace our code. But, there is always a but, at least re2 uses std::min() without the small trick to avoid the replacement, therefore we cannot do that.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE

@FedeDP
Copy link
Contributor Author

FedeDP commented Dec 13, 2024

/cc @geraldcombs care to give this a look?

@poiana poiana added the size/S label Dec 13, 2024
@FedeDP
Copy link
Contributor Author

FedeDP commented Dec 13, 2024

/milestone 0.20.0

@poiana poiana added this to the 0.20.0 milestone Dec 13, 2024
@FedeDP
Copy link
Contributor Author

FedeDP commented Dec 13, 2024

/hold for Gerald review :)

Copy link

github-actions bot commented Dec 13, 2024

Perf diff from master - unit tests

     9.51%     +0.99%  [.] sinsp_parser::reset
    10.09%     -0.55%  [.] sinsp::next
     2.32%     -0.51%  [.] scap_event_decode_params
     8.27%     -0.50%  [.] sinsp_evt::get_type
     2.83%     +0.36%  [.] sinsp_thread_manager::find_thread
     0.18%     +0.29%  [.] sinsp_evt::get_num_params
     0.62%     -0.26%  [.] sinsp_split[abi:cxx11]
     0.56%     -0.25%  [.] sinsp_evt::is_filtered_out
     1.07%     -0.25%  [.] sinsp_parser::parse_context_switch
     1.20%     +0.23%  [.] 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

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.0091         -0.0091           152           150           152           150
BM_sinsp_split_median                                          -0.0099         -0.0099           152           150           152           150
BM_sinsp_split_stddev                                          -0.4724         -0.4724             2             1             2             1
BM_sinsp_split_cv                                              -0.4676         -0.4676             0             0             0             0
BM_sinsp_concatenate_paths_relative_path_mean                  +0.0839         +0.0839            57            61            57            61
BM_sinsp_concatenate_paths_relative_path_median                +0.0822         +0.0822            57            61            57            61
BM_sinsp_concatenate_paths_relative_path_stddev                -0.4551         -0.4547             0             0             0             0
BM_sinsp_concatenate_paths_relative_path_cv                    -0.4972         -0.4968             0             0             0             0
BM_sinsp_concatenate_paths_empty_path_mean                     +0.0103         +0.0103            24            24            24            24
BM_sinsp_concatenate_paths_empty_path_median                   -0.0014         -0.0014            24            24            24            24
BM_sinsp_concatenate_paths_empty_path_stddev                  +11.9592        +11.9407             0             1             0             1
BM_sinsp_concatenate_paths_empty_path_cv                      +11.8270        +11.8087             0             0             0             0
BM_sinsp_concatenate_paths_absolute_path_mean                  +0.1350         +0.1350            56            63            56            63
BM_sinsp_concatenate_paths_absolute_path_median                +0.1365         +0.1365            56            63            56            63
BM_sinsp_concatenate_paths_absolute_path_stddev                -0.6673         -0.6673             1             0             1             0
BM_sinsp_concatenate_paths_absolute_path_cv                    -0.7069         -0.7068             0             0             0             0
BM_sinsp_split_container_image_mean                            -0.0032         -0.0032           382           381           382           381
BM_sinsp_split_container_image_median                          -0.0030         -0.0030           383           381           383           381
BM_sinsp_split_container_image_stddev                          +0.2718         +0.2727             2             2             2             2
BM_sinsp_split_container_image_cv                              +0.2758         +0.2767             0             0             0             0

Copy link

codecov bot commented Dec 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.19%. Comparing base (9e3fb93) to head (bf89dae).
Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2199      +/-   ##
==========================================
- Coverage   75.19%   75.19%   -0.01%     
==========================================
  Files         261      261              
  Lines       33878    33878              
  Branches     5800     5800              
==========================================
- Hits        25476    25475       -1     
- Misses       8402     8403       +1     
Flag Coverage Δ
libsinsp 75.19% <ø> (-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

github-actions bot commented Dec 13, 2024

X64 kernel testing matrix

KERNEL CMAKE-CONFIGURE KMOD BUILD KMOD SCAP-OPEN BPF-PROBE BUILD BPF-PROBE SCAP-OPEN MODERN-BPF SCAP-OPEN
amazonlinux2-4.19 🟢 🟢 🟢 🟢 🟢 🟡
amazonlinux2-5.10 🟢 🟢 🟢 🟢 🟢 🟢
amazonlinux2-5.15 🟢 🟢 🟢 🟢 🟢 🟢
amazonlinux2-5.4 🟢 🟢 🟢 🟢 🟢 🟡
amazonlinux2022-5.15 🟢 🟢 🟢 🟢 🟢 🟢
amazonlinux2023-6.1 🟢 🟢 🟢 🟢 🟢 🟢
archlinux-6.0 🟢 🟢 🟢 🟢 🟢 🟢
archlinux-6.7 🟢 🟢 🟢 🟢 🟢 🟢
centos-3.10 🟢 🟢 🟢 🟡 🟡 🟡
centos-4.18 🟢 🟢 🟢 🟢 🟢 🟢
centos-5.14 🟢 🟢 🟢 🟢 🟢 🟢
fedora-5.17 🟢 🟢 🟢 🟢 🟢 🟢
fedora-5.8 🟢 🟢 🟢 🟢 🟢 🟢
fedora-6.2 🟢 🟢 🟢 🟢 🟢 🟢
oraclelinux-3.10 🟢 🟢 🟢 🟡 🟡 🟡
oraclelinux-4.14 🟢 🟢 🟢 🟢 🟢 🟡
oraclelinux-5.15 🟢 🟢 🟢 🟢 🟢 🟢
oraclelinux-5.4 🟢 🟢 🟢 🟢 🟢 🟡
ubuntu-4.15 🟢 🟢 🟢 🟢 🟢 🟡
ubuntu-5.8 🟢 🟢 🟢 🟢 🟢 🟡
ubuntu-6.5 🟢 🟢 🟢 🟢 🟢 🟢

ARM64 kernel testing matrix

KERNEL CMAKE-CONFIGURE KMOD BUILD KMOD SCAP-OPEN BPF-PROBE BUILD BPF-PROBE SCAP-OPEN MODERN-BPF SCAP-OPEN
amazonlinux2-5.4 🟢 🟢 🟢 🟢 🟢 🟡
amazonlinux2022-5.15 🟢 🟢 🟢 🟢 🟢 🟢
fedora-6.2 🟢 🟢 🟢 🟢 🟢 🟢
oraclelinux-4.14 🟢 🟢 🟢 🟡 🟡 🟡
oraclelinux-5.15 🟢 🟢 🟢 🟢 🟢 🟢
ubuntu-6.5 🟢 🟢 🟢 🟢 🟢 🟢

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 Dec 13, 2024

[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

…ows buils.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
@FedeDP FedeDP force-pushed the cleanup/drop_NOMINMAX branch from 1ba9887 to bf89dae Compare December 13, 2024 16:39
@geraldcombs
Copy link
Contributor

LGTM. We've been doing something similar in the Wireshark sources for many years without any issues.

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