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

Optimize read to max #1714

Merged
merged 13 commits into from
Aug 30, 2023
Merged

Optimize read to max #1714

merged 13 commits into from
Aug 30, 2023

Conversation

ahrav
Copy link
Collaborator

@ahrav ahrav commented Aug 28, 2023

Description:

Use the std lib's CopyBuffer to speed up the copying process. We lose some granularity with this approach but the performance gains I think are well worth the tradeoff.

Screenshot 2023-08-29 at 4 42 50 PM

Checklist:

  • Tests passing (make test-community)?
  • Lint passing (make lint this requires golangci-lint)?

@ahrav ahrav requested a review from a team August 28, 2023 19:19
@ahrav ahrav marked this pull request as ready for review August 28, 2023 19:47
@ahrav ahrav requested a review from a team as a code owner August 28, 2023 19:47
pkg/handlers/archive.go Outdated Show resolved Hide resolved
pkg/handlers/archive.go Show resolved Hide resolved
pkg/handlers/archive.go Outdated Show resolved Hide resolved
@ahrav ahrav requested a review from mcastorina August 29, 2023 15:48
pkg/handlers/archive.go Outdated Show resolved Hide resolved
@ahrav ahrav requested a review from mcastorina August 29, 2023 17:26
Copy link
Collaborator

@mcastorina mcastorina left a comment

Choose a reason for hiding this comment

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

very nice!

Comment on lines 206 to 211
if fileContent.Len() == maxSize {
logger.V(2).Info("Max archive size reached.")
return fileContent.Bytes()[:maxSize], nil
}

return fileContent.Bytes(), nil
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could this be simplified now to

if fileContent.Len() == maxSize {
    logger.V(2).Info("Max archive size reached.")
}

return fileContent.Bytes(), nil

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oh yep yep, nice.

@ahrav ahrav merged commit 4dc5eb7 into main Aug 30, 2023
10 checks passed
@ahrav ahrav deleted the optimize-read-to-max branch August 30, 2023 00:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants