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

logtail: avoid bytes.Buffer allocation #11858

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

Conversation

dsnet
Copy link
Member

@dsnet dsnet commented Apr 23, 2024

Re-use a pre-allocated bytes.Buffer struct and
shallow the copy the result of bytes.NewBuffer into it to avoid allocating the struct.

Note that we're only reusing the bytes.Buffer struct itself and not the underling []byte temporarily stored within it.

Updates #cleanup
Updates tailscale/corp#18514
Updates golang/go#67004

Re-use a pre-allocated bytes.Buffer struct and
shallow the copy the result of bytes.NewBuffer into it
to avoid allocating the struct.

Note that we're only reusing the bytes.Buffer struct itself
and not the underling []byte temporarily stored within it.

Updates #cleanup
Updates tailscale/corp#18514
Updates golang/go#67004

Signed-off-by: Joe Tsai <joetsai@digital-static.net>
@dsnet dsnet requested review from raggi, bradfitz and maisem April 23, 2024 22:50
Copy link
Member

@bradfitz bradfitz left a comment

Choose a reason for hiding this comment

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

Ideally with an alloc test to lock it in and show it worked?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants