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

do not copy ConnectionStats until we have to #28173

Merged
merged 1 commit into from
Aug 8, 2024

Conversation

brycekahle
Copy link
Member

What does this PR do?

Uses *ConnectionStats arguments rather than forcing copies. Creates a copy only when storing for "long-term" usage (outside of the data pipeline for closed connections).

Motivation

Reduced allocations, because the ConnectionStats object is way too large to fit into a register.

Additional Notes

Extracted from changes in #28040

Possible Drawbacks / Trade-offs

Describe how to test/QA your changes

@brycekahle brycekahle added changelog/no-changelog team/networks qa/done QA done before merge and regressions are covered by tests labels Aug 2, 2024
@brycekahle brycekahle added this to the 7.57.0 milestone Aug 2, 2024
@brycekahle brycekahle requested review from a team as code owners August 2, 2024 19:39
@@ -302,6 +302,17 @@ func (c ConnectionStats) IsExpired(now uint64, timeout uint64) bool {
return c.LastUpdateEpoch+timeout <= now
}

// IsEmpty returns whether the connection has any statistics
func (c ConnectionStats) IsEmpty() bool {
// TODO why does this not include TCPEstablished and TCPClosed?
Copy link
Contributor

Choose a reason for hiding this comment

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

I have no objection with adding those fields here, do you @hmahmood?

Copy link
Contributor

Choose a reason for hiding this comment

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

happy to do that in a different PR though

Copy link
Contributor

Choose a reason for hiding this comment

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

actually we may set the closed flags on otherwise totally empty connections in kernelspace... so this could end up returning false a lot more

Copy link
Contributor

Choose a reason for hiding this comment

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

This function was mostly checking for whether the connection exchanged any data, and almost exclusively for code that is storing closed connections in state.go. As opposed to something like IsZero which does check for those other two fields.

Copy link
Contributor

@derekwbrown derekwbrown left a comment

Choose a reason for hiding this comment

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

approved for (1) wkit file

@brycekahle
Copy link
Member Author

/merge

@dd-devflow
Copy link

dd-devflow bot commented Aug 8, 2024

🚂 MergeQueue: pull request added to the queue

The median merge time in main is 22m.

Use /merge -c to cancel this operation!

@dd-mergequeue dd-mergequeue bot merged commit a6f6ab0 into main Aug 8, 2024
324 checks passed
@dd-mergequeue dd-mergequeue bot deleted the bryce.kahle/no-copy-conn-stats branch August 8, 2024 23:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog/no-changelog component/system-probe qa/done QA done before merge and regressions are covered by tests team/networks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants