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): async event queue capacity setter #1815

Merged
merged 1 commit into from
May 13, 2024

Conversation

mrgian
Copy link
Contributor

@mrgian mrgian commented Apr 29, 2024

What type of PR is this?

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

/kind bug

/kind cleanup

/kind design

/kind documentation

/kind failing-test

/kind feature

Any specific area of the project related to this PR?

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

/area API-version

/area build

/area CI

/area driver-kmod

/area driver-bpf

/area driver-modern-bpf

/area libscap-engine-bpf

/area libscap-engine-gvisor

/area libscap-engine-kmod

/area libscap-engine-modern-bpf

/area libscap-engine-nodriver

/area libscap-engine-noop

/area libscap-engine-source-plugin

/area libscap-engine-savefile

/area libscap

/area libpman

/area libsinsp

/area tests

/area proposals

Does this PR require a change in the driver versions?

/version driver-API-version-major

/version driver-API-version-minor

/version driver-API-version-patch

/version driver-SCHEMA-version-major

/version driver-SCHEMA-version-minor

/version driver-SCHEMA-version-patch

What this PR does / why we need it:
We are using this queue more and more, especially by plugins sending asynchronous events.
For this reason the hardcoded maximum queue size of 1000 elements is becoming restrictive.
This PR increases the async event queue maximum size to 30000.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE

Copy link
Contributor

@Molter73 Molter73 left a comment

Choose a reason for hiding this comment

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

Hi @mrgian! Thanks for your PR.

Personally, I wouldn't mess with defaults. I'd recommend creating a setter for it since this will likely have a performance impact on Falco and affect more than just your use case.

If other maintainers decide that it is OK to increase the default size for the async queue, I would still like to get a setter implemented, so that adopters can roll it back at runtime.

On the other hand, if a setter is not possible to implement, turning this parameter into a compile time value could also work for adopters, but a runtime configuration setter might be more flexible.

@mrgian
Copy link
Contributor Author

mrgian commented Apr 29, 2024

Hi @Molter73
Makes sense and I agree!
I'm converting this PR to draft while I think of an implementation.

@mrgian mrgian marked this pull request as draft April 29, 2024 13:50
@FedeDP
Copy link
Contributor

FedeDP commented Apr 30, 2024

/milestone 0.17.0

@poiana poiana added this to the 0.17.0 milestone Apr 30, 2024
@poiana poiana added size/S and removed size/XS labels May 2, 2024
@mrgian mrgian marked this pull request as ready for review May 2, 2024 12:59
@poiana poiana requested a review from Andreagit97 May 2, 2024 13:00
userspace/libsinsp/sinsp.cpp Outdated Show resolved Hide resolved
@mrgian mrgian force-pushed the increase-async-event-queue branch from b8cd300 to a0c516d Compare May 6, 2024 09:35
@mrgian mrgian changed the title update(libsinsp): increase async event queue size new(libsinsp): async event queue capacity setter May 6, 2024
std::scoped_lock<Mtx> lk(m_mtx);
if(m_queue.size() <= capacity)
{
m_capacity = capacity;
Copy link
Contributor

Choose a reason for hiding this comment

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

Am I missing something here or why do we not have a call m_queue.set_capacity to actually change the capacity? Or is it set later? In that case I would find the method name set_capacity confusing.

Copy link
Contributor

Choose a reason for hiding this comment

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

The capacity here is just artificially set by us to bound the queue's size -- we don't really care about what the underlying priority queue's capacity actually is, and I don't even think we can/should interfere with that

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh interesting, hmmm isn't the standard approach to set and bound the capacity of the actual queue at init time and let the queue handle scenarios if its full. That's basically what we now do for the Falco outputs queue. WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah I agree -- the only problem is that the queue is owned by the inspector currently, so in order for the value to be expressed at construction time we'd need a mechanism for either passing the value at the inspector init-time (a bit overkill) or for swapping the queue with another one. If we get to that, I'd rather prefer having a queue that allows resizing at runtime. It's not much cost in terms of synchronization, plus in the real world we'll always resize it when empty anyways (e.g. before opening the inspector).

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd rather prefer having a queue that allows resizing at runtime

If that's a requirement, perhaps leave a note in the code base.

@mrgian mrgian force-pushed the increase-async-event-queue branch from a0c516d to 866337e Compare May 13, 2024 14:23
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.

/approve

@poiana
Copy link
Contributor

poiana commented May 13, 2024

LGTM label has been added.

Git tree hash: 38a9e8b0ab8c6d67ed7883cf6db41ec09fb50f7c

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.

/approve

@poiana
Copy link
Contributor

poiana commented May 13, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: incertum, jasondellaluce, mrgian

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

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

@poiana poiana merged commit e0fd864 into falcosecurity:master May 13, 2024
34 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.

6 participants