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

refactor: smart pointer usage #3184

Merged

Conversation

federico-sysdig
Copy link
Contributor

What type of PR is this?
/kind cleanup

Any specific area of the project related to this PR?
No specific area.

What this PR does / why we need it:
There are some usages of smart pointers that can be simplified a but and, occasionally, made more efficient.

  1. Use the overloaded dereference operator directly on the smart pointer without invoking get(), i.e. prefer *ptr rather than *(ptr.get()).
  2. Create objects stored in smart pointers with make_unique or make_shared rather than using new. For shared_ptrs this has the performance advantage of storing the pointer's control block with the object itself, improving memory locality, beneficial for cache reasons, and using a single allocation call.
  3. Prefer using automatic objects - i.e. stored on the stack - than heap allocated ones. This effectively removes the usage of the smart pointer.

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE

Copy link

github-actions bot commented May 5, 2024

This PR may bring feature or behavior changes in the Falco engine and may require the engine version to be bumped.

Please double check userspace/engine/falco_engine_version.h file. See versioning for FALCO_ENGINE_VERSION.

/hold

@poiana poiana requested review from FedeDP and Kaizhe May 5, 2024 21:55
Signed-off-by: Federico Aponte <federico.aponte@sysdig.com>
@federico-sysdig federico-sysdig force-pushed the refactor-smart-pointer-usage branch from 4c5eb5e to 1dcff5a Compare May 5, 2024 21:58
@poiana
Copy link
Contributor

poiana commented May 6, 2024

LGTM label has been added.

Git tree hash: 5dc02d7a46f468ea47bc0189c2c2046dfdf348ad

@poiana poiana added the approved label May 6, 2024
@FedeDP
Copy link
Contributor

FedeDP commented May 6, 2024

/milestone 0.38.0

@poiana poiana added this to the 0.38.0 milestone May 6, 2024
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 May 6, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: FedeDP, federico-sysdig, jasondellaluce

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,jasondellaluce]

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

FedeDP commented May 6, 2024

/unhold

@poiana poiana merged commit 62d1c4f into falcosecurity:master May 6, 2024
34 of 35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants