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

net: Cache value of local address #15931

Merged
merged 1 commit into from
Jan 5, 2024

Conversation

graphcareful
Copy link
Contributor

@graphcareful graphcareful commented Jan 3, 2024

  • Performance testing has shown excessive CPU time is spent when local_address() is called within a tight loop, this has been tracked down to the fact that ss::file_desc::local_address() invokes a system call, getsockname.

  • To mitigate this issue, the connection class now caches the value of local address upon instantiation.

  • Relates to: audit logging perf overhead #15898

Backports Required

  • none - not a bug fix
  • none - this is a backport
  • none - issue does not exist in previous branches
  • none - papercut/not impactful enough to backport
  • v23.3.x
  • v23.2.x
  • v23.1.x

Release Notes

Improvements

  • Caches the connections local address preventing the need to make a system calls to grab this value when auditing events.

@piyushredpanda piyushredpanda modified the milestones: v23.3.x-next, v23.3.2 Jan 4, 2024
StephanDollberg
StephanDollberg previously approved these changes Jan 4, 2024
Copy link
Member

@StephanDollberg StephanDollberg left a comment

Choose a reason for hiding this comment

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

PR body and the commit say:

Fixes: #15898

That would close the issue but I think this commit only partially addresses a subset of the issues?

src/v/net/connection.h Outdated Show resolved Hide resolved
@@ -133,6 +133,7 @@ connection::connection(
, _hook(hook)
, _name(std::move(name))
, _fd(std::move(f))
, _local_addr(_fd.local_address())
Copy link
Member

Choose a reason for hiding this comment

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

Doing this always is fine I guess as most connections are kafka rpc connections so we will need this sooner than later anyway?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The logic is that the local address will never change for the duration of the instance, therefore it is safe to cache

@graphcareful
Copy link
Contributor Author

That would close the issue but I think this commit only partially addresses a subset of the issues?

Removing the fixes part in the msg

- Performance testing has shown excessive CPU time is spent when
local_address() is called within a tight loop, this has been tracked
down to the fact that ss::file_desc::local_address() invokes a system
call, getsockname.

- To mitigate this issue, the connection class now caches the value of
local address upon instantiation.

- Partially fixes: redpanda-data#15898
@piyushredpanda
Copy link
Contributor

Failure is #15893

@piyushredpanda piyushredpanda merged commit c094966 into redpanda-data:dev Jan 5, 2024
18 of 20 checks passed
@vbotbuildovich
Copy link
Collaborator

/backport v23.3.x

Copy link
Member

@dotnwat dotnwat left a comment

Choose a reason for hiding this comment

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

👍

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.

None yet

7 participants