-
Notifications
You must be signed in to change notification settings - Fork 7
Reuse request buffers #185
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
base: main
Are you sure you want to change the base?
Conversation
f4895bb to
d1ad494
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements buffer pooling to reuse request buffers across the codebase, reducing memory allocations and garbage collection pressure. The changes introduce sync.Pool for managing reusable byte slices in protocol handlers and HTTP clients.
Key changes:
- Modified protocol handlers (Gemini, Gopher, Finger) to use pooled buffers instead of creating new allocations per request
- Updated HTTP client code in
fed/send.goto return buffer data with cleanup callbacks instead of response objects - Replaced
bytes.Bufferwith pooled[]byteinLineWriterfor more efficient buffer management
Reviewed Changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| front/text/line.go | Replaces bytes.Buffer with pooled []byte slice and adds buffer return on goroutine cleanup |
| front/gopher/gopher.go | Extracts request reading into separate function using pooled buffers |
| front/gemini/gemini.go | Extracts request reading into separate function using pooled buffers |
| front/finger/finger.go | Extracts request reading into separate function using pooled buffers |
| fed/send.go | Changes return signature to provide buffer data with cleanup callback instead of http.Response |
| fed/resolve.go | Updates to use new send() signature with buffer cleanup callbacks |
| fed/inbox.go | Updates to use pooled buffers for reading request bodies |
| fed/followers.go | Updates to use new resolver signature with cleanup callbacks |
| fed/deliver.go | Updates to use new send() signature with cleanup callback |
| fed/listener.go | Adds Buffers field to Listener struct |
| ap/resolver.go | Updates Get() interface signature to return status, body, cleanup function |
| cmd/tootik/main.go | Initializes buffer pools for all protocol listeners |
| test/register_test.go | Adds buffer pool initialization to all test cases |
| fed/resolve_test.go | Updates tests to use buffer pools instead of MaxResponseBodySize config |
| cluster/server.go | Initializes buffer pools for test server setup |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
No description provided.